diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-21 15:41:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-21 15:41:19 -0400 |
commit | a8fe1500986c32b46b36118aa250f6badca11bfc (patch) | |
tree | d5517e16e633fa0c54248f27b5921e8ac4e4a459 /net | |
parent | 94ebd235c493f43681f609b0e02733337053e8f0 (diff) | |
parent | f0d3d9894e43fc68d47948e2c6f03e32da88b799 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6: (26 commits)
selinux: include vmalloc.h for vmalloc_user
secmark: fix config problem when CONFIG_NF_CONNTRACK_SECMARK is not set
selinux: implement mmap on /selinux/policy
SELinux: allow userspace to read policy back out of the kernel
SELinux: drop useless (and incorrect) AVTAB_MAX_SIZE
SELinux: deterministic ordering of range transition rules
kernel: roundup should only reference arguments once
kernel: rounddown helper function
secmark: export secctx, drop secmark in procfs
conntrack: export lsm context rather than internal secid via netlink
security: secid_to_secctx returns len when data is NULL
secmark: make secmark object handling generic
secmark: do not return early if there was no error
AppArmor: Ensure the size of the copy is < the buffer allocated to hold it
TOMOYO: Print URL information before panic().
security: remove unused parameter from security_task_setscheduler()
tpm: change 'tpm_suspend_pcr' to be module parameter
selinux: fix up style problem on /selinux/status
selinux: change to new flag variable
selinux: really fix dependency causing parallel compile failure.
...
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 28 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 44 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_standalone.c | 28 | ||||
-rw-r--r-- | net/netfilter/xt_CT.c | 1 | ||||
-rw-r--r-- | net/netfilter/xt_SECMARK.c | 35 |
5 files changed, 103 insertions, 33 deletions
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c index 244f7cb08d68..37f8adb68c79 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/proc_fs.h> | 11 | #include <linux/proc_fs.h> |
12 | #include <linux/seq_file.h> | 12 | #include <linux/seq_file.h> |
13 | #include <linux/percpu.h> | 13 | #include <linux/percpu.h> |
14 | #include <linux/security.h> | ||
14 | #include <net/net_namespace.h> | 15 | #include <net/net_namespace.h> |
15 | 16 | ||
16 | #include <linux/netfilter.h> | 17 | #include <linux/netfilter.h> |
@@ -87,6 +88,29 @@ static void ct_seq_stop(struct seq_file *s, void *v) | |||
87 | rcu_read_unlock(); | 88 | rcu_read_unlock(); |
88 | } | 89 | } |
89 | 90 | ||
91 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | ||
92 | static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | ||
93 | { | ||
94 | int ret; | ||
95 | u32 len; | ||
96 | char *secctx; | ||
97 | |||
98 | ret = security_secid_to_secctx(ct->secmark, &secctx, &len); | ||
99 | if (ret) | ||
100 | return ret; | ||
101 | |||
102 | ret = seq_printf(s, "secctx=%s ", secctx); | ||
103 | |||
104 | security_release_secctx(secctx, len); | ||
105 | return ret; | ||
106 | } | ||
107 | #else | ||
108 | static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | ||
109 | { | ||
110 | return 0; | ||
111 | } | ||
112 | #endif | ||
113 | |||
90 | static int ct_seq_show(struct seq_file *s, void *v) | 114 | static int ct_seq_show(struct seq_file *s, void *v) |
91 | { | 115 | { |
92 | struct nf_conntrack_tuple_hash *hash = v; | 116 | struct nf_conntrack_tuple_hash *hash = v; |
@@ -148,10 +172,8 @@ static int ct_seq_show(struct seq_file *s, void *v) | |||
148 | goto release; | 172 | goto release; |
149 | #endif | 173 | #endif |
150 | 174 | ||
151 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | 175 | if (ct_show_secctx(s, ct)) |
152 | if (seq_printf(s, "secmark=%u ", ct->secmark)) | ||
153 | goto release; | 176 | goto release; |
154 | #endif | ||
155 | 177 | ||
156 | if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use))) | 178 | if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use))) |
157 | goto release; | 179 | goto release; |
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 5bae1cd15eea..146476c6441a 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/rculist_nulls.h> | 22 | #include <linux/rculist_nulls.h> |
23 | #include <linux/types.h> | 23 | #include <linux/types.h> |
24 | #include <linux/timer.h> | 24 | #include <linux/timer.h> |
25 | #include <linux/security.h> | ||
25 | #include <linux/skbuff.h> | 26 | #include <linux/skbuff.h> |
26 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
27 | #include <linux/netlink.h> | 28 | #include <linux/netlink.h> |
@@ -245,16 +246,31 @@ nla_put_failure: | |||
245 | 246 | ||
246 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | 247 | #ifdef CONFIG_NF_CONNTRACK_SECMARK |
247 | static inline int | 248 | static inline int |
248 | ctnetlink_dump_secmark(struct sk_buff *skb, const struct nf_conn *ct) | 249 | ctnetlink_dump_secctx(struct sk_buff *skb, const struct nf_conn *ct) |
249 | { | 250 | { |
250 | NLA_PUT_BE32(skb, CTA_SECMARK, htonl(ct->secmark)); | 251 | struct nlattr *nest_secctx; |
251 | return 0; | 252 | int len, ret; |
253 | char *secctx; | ||
254 | |||
255 | ret = security_secid_to_secctx(ct->secmark, &secctx, &len); | ||
256 | if (ret) | ||
257 | return ret; | ||
258 | |||
259 | ret = -1; | ||
260 | nest_secctx = nla_nest_start(skb, CTA_SECCTX | NLA_F_NESTED); | ||
261 | if (!nest_secctx) | ||
262 | goto nla_put_failure; | ||
263 | |||
264 | NLA_PUT_STRING(skb, CTA_SECCTX_NAME, secctx); | ||
265 | nla_nest_end(skb, nest_secctx); | ||
252 | 266 | ||
267 | ret = 0; | ||
253 | nla_put_failure: | 268 | nla_put_failure: |
254 | return -1; | 269 | security_release_secctx(secctx, len); |
270 | return ret; | ||
255 | } | 271 | } |
256 | #else | 272 | #else |
257 | #define ctnetlink_dump_secmark(a, b) (0) | 273 | #define ctnetlink_dump_secctx(a, b) (0) |
258 | #endif | 274 | #endif |
259 | 275 | ||
260 | #define master_tuple(ct) &(ct->master->tuplehash[IP_CT_DIR_ORIGINAL].tuple) | 276 | #define master_tuple(ct) &(ct->master->tuplehash[IP_CT_DIR_ORIGINAL].tuple) |
@@ -391,7 +407,7 @@ ctnetlink_fill_info(struct sk_buff *skb, u32 pid, u32 seq, | |||
391 | ctnetlink_dump_protoinfo(skb, ct) < 0 || | 407 | ctnetlink_dump_protoinfo(skb, ct) < 0 || |
392 | ctnetlink_dump_helpinfo(skb, ct) < 0 || | 408 | ctnetlink_dump_helpinfo(skb, ct) < 0 || |
393 | ctnetlink_dump_mark(skb, ct) < 0 || | 409 | ctnetlink_dump_mark(skb, ct) < 0 || |
394 | ctnetlink_dump_secmark(skb, ct) < 0 || | 410 | ctnetlink_dump_secctx(skb, ct) < 0 || |
395 | ctnetlink_dump_id(skb, ct) < 0 || | 411 | ctnetlink_dump_id(skb, ct) < 0 || |
396 | ctnetlink_dump_use(skb, ct) < 0 || | 412 | ctnetlink_dump_use(skb, ct) < 0 || |
397 | ctnetlink_dump_master(skb, ct) < 0 || | 413 | ctnetlink_dump_master(skb, ct) < 0 || |
@@ -437,6 +453,17 @@ ctnetlink_counters_size(const struct nf_conn *ct) | |||
437 | ; | 453 | ; |
438 | } | 454 | } |
439 | 455 | ||
456 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | ||
457 | static int ctnetlink_nlmsg_secctx_size(const struct nf_conn *ct) | ||
458 | { | ||
459 | int len; | ||
460 | |||
461 | security_secid_to_secctx(ct->secmark, NULL, &len); | ||
462 | |||
463 | return sizeof(char) * len; | ||
464 | } | ||
465 | #endif | ||
466 | |||
440 | static inline size_t | 467 | static inline size_t |
441 | ctnetlink_nlmsg_size(const struct nf_conn *ct) | 468 | ctnetlink_nlmsg_size(const struct nf_conn *ct) |
442 | { | 469 | { |
@@ -453,7 +480,8 @@ ctnetlink_nlmsg_size(const struct nf_conn *ct) | |||
453 | + nla_total_size(0) /* CTA_HELP */ | 480 | + nla_total_size(0) /* CTA_HELP */ |
454 | + nla_total_size(NF_CT_HELPER_NAME_LEN) /* CTA_HELP_NAME */ | 481 | + nla_total_size(NF_CT_HELPER_NAME_LEN) /* CTA_HELP_NAME */ |
455 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | 482 | #ifdef CONFIG_NF_CONNTRACK_SECMARK |
456 | + nla_total_size(sizeof(u_int32_t)) /* CTA_SECMARK */ | 483 | + nla_total_size(0) /* CTA_SECCTX */ |
484 | + nla_total_size(ctnetlink_nlmsg_secctx_size(ct)) /* CTA_SECCTX_NAME */ | ||
457 | #endif | 485 | #endif |
458 | #ifdef CONFIG_NF_NAT_NEEDED | 486 | #ifdef CONFIG_NF_NAT_NEEDED |
459 | + 2 * nla_total_size(0) /* CTA_NAT_SEQ_ADJ_ORIG|REPL */ | 487 | + 2 * nla_total_size(0) /* CTA_NAT_SEQ_ADJ_ORIG|REPL */ |
@@ -556,7 +584,7 @@ ctnetlink_conntrack_event(unsigned int events, struct nf_ct_event *item) | |||
556 | 584 | ||
557 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | 585 | #ifdef CONFIG_NF_CONNTRACK_SECMARK |
558 | if ((events & (1 << IPCT_SECMARK) || ct->secmark) | 586 | if ((events & (1 << IPCT_SECMARK) || ct->secmark) |
559 | && ctnetlink_dump_secmark(skb, ct) < 0) | 587 | && ctnetlink_dump_secctx(skb, ct) < 0) |
560 | goto nla_put_failure; | 588 | goto nla_put_failure; |
561 | #endif | 589 | #endif |
562 | 590 | ||
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index eb973fcd67ab..0fb65705b44b 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/seq_file.h> | 15 | #include <linux/seq_file.h> |
16 | #include <linux/percpu.h> | 16 | #include <linux/percpu.h> |
17 | #include <linux/netdevice.h> | 17 | #include <linux/netdevice.h> |
18 | #include <linux/security.h> | ||
18 | #include <net/net_namespace.h> | 19 | #include <net/net_namespace.h> |
19 | #ifdef CONFIG_SYSCTL | 20 | #ifdef CONFIG_SYSCTL |
20 | #include <linux/sysctl.h> | 21 | #include <linux/sysctl.h> |
@@ -108,6 +109,29 @@ static void ct_seq_stop(struct seq_file *s, void *v) | |||
108 | rcu_read_unlock(); | 109 | rcu_read_unlock(); |
109 | } | 110 | } |
110 | 111 | ||
112 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | ||
113 | static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | ||
114 | { | ||
115 | int ret; | ||
116 | u32 len; | ||
117 | char *secctx; | ||
118 | |||
119 | ret = security_secid_to_secctx(ct->secmark, &secctx, &len); | ||
120 | if (ret) | ||
121 | return ret; | ||
122 | |||
123 | ret = seq_printf(s, "secctx=%s ", secctx); | ||
124 | |||
125 | security_release_secctx(secctx, len); | ||
126 | return ret; | ||
127 | } | ||
128 | #else | ||
129 | static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) | ||
130 | { | ||
131 | return 0; | ||
132 | } | ||
133 | #endif | ||
134 | |||
111 | /* return 0 on success, 1 in case of error */ | 135 | /* return 0 on success, 1 in case of error */ |
112 | static int ct_seq_show(struct seq_file *s, void *v) | 136 | static int ct_seq_show(struct seq_file *s, void *v) |
113 | { | 137 | { |
@@ -168,10 +192,8 @@ static int ct_seq_show(struct seq_file *s, void *v) | |||
168 | goto release; | 192 | goto release; |
169 | #endif | 193 | #endif |
170 | 194 | ||
171 | #ifdef CONFIG_NF_CONNTRACK_SECMARK | 195 | if (ct_show_secctx(s, ct)) |
172 | if (seq_printf(s, "secmark=%u ", ct->secmark)) | ||
173 | goto release; | 196 | goto release; |
174 | #endif | ||
175 | 197 | ||
176 | #ifdef CONFIG_NF_CONNTRACK_ZONES | 198 | #ifdef CONFIG_NF_CONNTRACK_ZONES |
177 | if (seq_printf(s, "zone=%u ", nf_ct_zone(ct))) | 199 | if (seq_printf(s, "zone=%u ", nf_ct_zone(ct))) |
diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c index 0cb6053f02fd..782e51986a6f 100644 --- a/net/netfilter/xt_CT.c +++ b/net/netfilter/xt_CT.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/gfp.h> | 10 | #include <linux/gfp.h> |
11 | #include <linux/skbuff.h> | 11 | #include <linux/skbuff.h> |
12 | #include <linux/selinux.h> | ||
13 | #include <linux/netfilter_ipv4/ip_tables.h> | 12 | #include <linux/netfilter_ipv4/ip_tables.h> |
14 | #include <linux/netfilter_ipv6/ip6_tables.h> | 13 | #include <linux/netfilter_ipv6/ip6_tables.h> |
15 | #include <linux/netfilter/x_tables.h> | 14 | #include <linux/netfilter/x_tables.h> |
diff --git a/net/netfilter/xt_SECMARK.c b/net/netfilter/xt_SECMARK.c index 23b2d6c486b5..9faf5e050b79 100644 --- a/net/netfilter/xt_SECMARK.c +++ b/net/netfilter/xt_SECMARK.c | |||
@@ -14,8 +14,8 @@ | |||
14 | */ | 14 | */ |
15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/security.h> | ||
17 | #include <linux/skbuff.h> | 18 | #include <linux/skbuff.h> |
18 | #include <linux/selinux.h> | ||
19 | #include <linux/netfilter/x_tables.h> | 19 | #include <linux/netfilter/x_tables.h> |
20 | #include <linux/netfilter/xt_SECMARK.h> | 20 | #include <linux/netfilter/xt_SECMARK.h> |
21 | 21 | ||
@@ -39,9 +39,8 @@ secmark_tg(struct sk_buff *skb, const struct xt_action_param *par) | |||
39 | 39 | ||
40 | switch (mode) { | 40 | switch (mode) { |
41 | case SECMARK_MODE_SEL: | 41 | case SECMARK_MODE_SEL: |
42 | secmark = info->u.sel.selsid; | 42 | secmark = info->secid; |
43 | break; | 43 | break; |
44 | |||
45 | default: | 44 | default: |
46 | BUG(); | 45 | BUG(); |
47 | } | 46 | } |
@@ -50,33 +49,33 @@ secmark_tg(struct sk_buff *skb, const struct xt_action_param *par) | |||
50 | return XT_CONTINUE; | 49 | return XT_CONTINUE; |
51 | } | 50 | } |
52 | 51 | ||
53 | static int checkentry_selinux(struct xt_secmark_target_info *info) | 52 | static int checkentry_lsm(struct xt_secmark_target_info *info) |
54 | { | 53 | { |
55 | int err; | 54 | int err; |
56 | struct xt_secmark_target_selinux_info *sel = &info->u.sel; | ||
57 | 55 | ||
58 | sel->selctx[SECMARK_SELCTX_MAX - 1] = '\0'; | 56 | info->secctx[SECMARK_SECCTX_MAX - 1] = '\0'; |
57 | info->secid = 0; | ||
59 | 58 | ||
60 | err = selinux_string_to_sid(sel->selctx, &sel->selsid); | 59 | err = security_secctx_to_secid(info->secctx, strlen(info->secctx), |
60 | &info->secid); | ||
61 | if (err) { | 61 | if (err) { |
62 | if (err == -EINVAL) | 62 | if (err == -EINVAL) |
63 | pr_info("invalid SELinux context \'%s\'\n", | 63 | pr_info("invalid security context \'%s\'\n", info->secctx); |
64 | sel->selctx); | ||
65 | return err; | 64 | return err; |
66 | } | 65 | } |
67 | 66 | ||
68 | if (!sel->selsid) { | 67 | if (!info->secid) { |
69 | pr_info("unable to map SELinux context \'%s\'\n", sel->selctx); | 68 | pr_info("unable to map security context \'%s\'\n", info->secctx); |
70 | return -ENOENT; | 69 | return -ENOENT; |
71 | } | 70 | } |
72 | 71 | ||
73 | err = selinux_secmark_relabel_packet_permission(sel->selsid); | 72 | err = security_secmark_relabel_packet(info->secid); |
74 | if (err) { | 73 | if (err) { |
75 | pr_info("unable to obtain relabeling permission\n"); | 74 | pr_info("unable to obtain relabeling permission\n"); |
76 | return err; | 75 | return err; |
77 | } | 76 | } |
78 | 77 | ||
79 | selinux_secmark_refcount_inc(); | 78 | security_secmark_refcount_inc(); |
80 | return 0; | 79 | return 0; |
81 | } | 80 | } |
82 | 81 | ||
@@ -100,16 +99,16 @@ static int secmark_tg_check(const struct xt_tgchk_param *par) | |||
100 | 99 | ||
101 | switch (info->mode) { | 100 | switch (info->mode) { |
102 | case SECMARK_MODE_SEL: | 101 | case SECMARK_MODE_SEL: |
103 | err = checkentry_selinux(info); | ||
104 | if (err <= 0) | ||
105 | return err; | ||
106 | break; | 102 | break; |
107 | |||
108 | default: | 103 | default: |
109 | pr_info("invalid mode: %hu\n", info->mode); | 104 | pr_info("invalid mode: %hu\n", info->mode); |
110 | return -EINVAL; | 105 | return -EINVAL; |
111 | } | 106 | } |
112 | 107 | ||
108 | err = checkentry_lsm(info); | ||
109 | if (err) | ||
110 | return err; | ||
111 | |||
113 | if (!mode) | 112 | if (!mode) |
114 | mode = info->mode; | 113 | mode = info->mode; |
115 | return 0; | 114 | return 0; |
@@ -119,7 +118,7 @@ static void secmark_tg_destroy(const struct xt_tgdtor_param *par) | |||
119 | { | 118 | { |
120 | switch (mode) { | 119 | switch (mode) { |
121 | case SECMARK_MODE_SEL: | 120 | case SECMARK_MODE_SEL: |
122 | selinux_secmark_refcount_dec(); | 121 | security_secmark_refcount_dec(); |
123 | } | 122 | } |
124 | } | 123 | } |
125 | 124 | ||