Commit 1ae4de0c authored by Eric Paris's avatar Eric Paris Committed by James Morris

secmark: export secctx, drop secmark in procfs

The current secmark code exports a secmark= field which just indicates if
there is special labeling on a packet or not.  We drop this field as it
isn't particularly useful and instead export a new field secctx= which is
the actual human readable text label.
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
Acked-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 1cc63249
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/security.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <linux/netfilter.h> #include <linux/netfilter.h>
...@@ -87,6 +88,29 @@ static void ct_seq_stop(struct seq_file *s, void *v) ...@@ -87,6 +88,29 @@ static void ct_seq_stop(struct seq_file *s, void *v)
rcu_read_unlock(); rcu_read_unlock();
} }
#ifdef CONFIG_NF_CONNTRACK_SECMARK
static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
{
int ret;
u32 len;
char *secctx;
ret = security_secid_to_secctx(ct->secmark, &secctx, &len);
if (ret)
return ret;
ret = seq_printf(s, "secctx=%s ", secctx);
security_release_secctx(secctx, len);
return ret;
}
#else
static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
{
return 0;
}
#endif
static int ct_seq_show(struct seq_file *s, void *v) static int ct_seq_show(struct seq_file *s, void *v)
{ {
struct nf_conntrack_tuple_hash *hash = v; struct nf_conntrack_tuple_hash *hash = v;
...@@ -148,10 +172,8 @@ static int ct_seq_show(struct seq_file *s, void *v) ...@@ -148,10 +172,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
goto release; goto release;
#endif #endif
#ifdef CONFIG_NF_CONNTRACK_SECMARK if (ct_show_secctx(s, ct))
if (seq_printf(s, "secmark=%u ", ct->secmark))
goto release; goto release;
#endif
if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use))) if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)))
goto release; goto release;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/security.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
#include <linux/sysctl.h> #include <linux/sysctl.h>
...@@ -108,6 +109,29 @@ static void ct_seq_stop(struct seq_file *s, void *v) ...@@ -108,6 +109,29 @@ static void ct_seq_stop(struct seq_file *s, void *v)
rcu_read_unlock(); rcu_read_unlock();
} }
#ifdef CONFIG_NF_CONNTRACK_SECMARK
static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
{
int ret;
u32 len;
char *secctx;
ret = security_secid_to_secctx(ct->secmark, &secctx, &len);
if (ret)
return ret;
ret = seq_printf(s, "secctx=%s ", secctx);
security_release_secctx(secctx, len);
return ret;
}
#else
static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
{
return 0;
}
#endif
/* return 0 on success, 1 in case of error */ /* return 0 on success, 1 in case of error */
static int ct_seq_show(struct seq_file *s, void *v) static int ct_seq_show(struct seq_file *s, void *v)
{ {
...@@ -168,10 +192,8 @@ static int ct_seq_show(struct seq_file *s, void *v) ...@@ -168,10 +192,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
goto release; goto release;
#endif #endif
#ifdef CONFIG_NF_CONNTRACK_SECMARK if (ct_show_secctx(s, ct))
if (seq_printf(s, "secmark=%u ", ct->secmark))
goto release; goto release;
#endif
#ifdef CONFIG_NF_CONNTRACK_ZONES #ifdef CONFIG_NF_CONNTRACK_ZONES
if (seq_printf(s, "zone=%u ", nf_ct_zone(ct))) if (seq_printf(s, "zone=%u ", nf_ct_zone(ct)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment