aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-11-13 18:39:25 -0500
committerJames Morris <jmorris@namei.org>2008-11-13 18:39:25 -0500
commitd76b0d9b2d87cfc95686e148767cbf7d0e22bdc0 (patch)
tree1a2956614018d245facb256ffb8662568cdabcd4 /net
parent1d045980e1eff4800472f0e81df9460640c8eee9 (diff)
CRED: Use creds in file structs
Attach creds to file structs and discard f_uid/f_gid. file_operations::open() methods (such as hppfs_open()) should use file->f_cred rather than current_cred(). At the moment file->f_cred will be current_cred() at this point. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: James Morris <jmorris@namei.org> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/netfilter/ipt_LOG.c4
-rw-r--r--net/ipv6/netfilter/ip6t_LOG.c4
-rw-r--r--net/netfilter/nfnetlink_log.c5
-rw-r--r--net/netfilter/xt_owner.c16
-rw-r--r--net/sched/cls_flow.c4
5 files changed, 17 insertions, 16 deletions
diff --git a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
index fc6ce04a3e35..7b5dbe118c09 100644
--- a/net/ipv4/netfilter/ipt_LOG.c
+++ b/net/ipv4/netfilter/ipt_LOG.c
@@ -340,8 +340,8 @@ static void dump_packet(const struct nf_loginfo *info,
340 read_lock_bh(&skb->sk->sk_callback_lock); 340 read_lock_bh(&skb->sk->sk_callback_lock);
341 if (skb->sk->sk_socket && skb->sk->sk_socket->file) 341 if (skb->sk->sk_socket && skb->sk->sk_socket->file)
342 printk("UID=%u GID=%u ", 342 printk("UID=%u GID=%u ",
343 skb->sk->sk_socket->file->f_uid, 343 skb->sk->sk_socket->file->f_cred->fsuid,
344 skb->sk->sk_socket->file->f_gid); 344 skb->sk->sk_socket->file->f_cred->fsgid);
345 read_unlock_bh(&skb->sk->sk_callback_lock); 345 read_unlock_bh(&skb->sk->sk_callback_lock);
346 } 346 }
347 347
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
index caa441d09567..871d157cec4e 100644
--- a/net/ipv6/netfilter/ip6t_LOG.c
+++ b/net/ipv6/netfilter/ip6t_LOG.c
@@ -364,8 +364,8 @@ static void dump_packet(const struct nf_loginfo *info,
364 read_lock_bh(&skb->sk->sk_callback_lock); 364 read_lock_bh(&skb->sk->sk_callback_lock);
365 if (skb->sk->sk_socket && skb->sk->sk_socket->file) 365 if (skb->sk->sk_socket && skb->sk->sk_socket->file)
366 printk("UID=%u GID=%u ", 366 printk("UID=%u GID=%u ",
367 skb->sk->sk_socket->file->f_uid, 367 skb->sk->sk_socket->file->f_cred->fsuid,
368 skb->sk->sk_socket->file->f_gid); 368 skb->sk->sk_socket->file->f_cred->fsgid);
369 read_unlock_bh(&skb->sk->sk_callback_lock); 369 read_unlock_bh(&skb->sk->sk_callback_lock);
370 } 370 }
371 371
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 41e0105d3828..38f9efd90e8d 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -474,8 +474,9 @@ __build_packet_message(struct nfulnl_instance *inst,
474 if (skb->sk) { 474 if (skb->sk) {
475 read_lock_bh(&skb->sk->sk_callback_lock); 475 read_lock_bh(&skb->sk->sk_callback_lock);
476 if (skb->sk->sk_socket && skb->sk->sk_socket->file) { 476 if (skb->sk->sk_socket && skb->sk->sk_socket->file) {
477 __be32 uid = htonl(skb->sk->sk_socket->file->f_uid); 477 struct file *file = skb->sk->sk_socket->file;
478 __be32 gid = htonl(skb->sk->sk_socket->file->f_gid); 478 __be32 uid = htonl(file->f_cred->fsuid);
479 __be32 gid = htonl(file->f_cred->fsgid);
479 /* need to unlock here since NLA_PUT may goto */ 480 /* need to unlock here since NLA_PUT may goto */
480 read_unlock_bh(&skb->sk->sk_callback_lock); 481 read_unlock_bh(&skb->sk->sk_callback_lock);
481 NLA_PUT_BE32(inst->skb, NFULA_UID, uid); 482 NLA_PUT_BE32(inst->skb, NFULA_UID, uid);
diff --git a/net/netfilter/xt_owner.c b/net/netfilter/xt_owner.c
index f19ebd9b78f5..22b2a5e881ea 100644
--- a/net/netfilter/xt_owner.c
+++ b/net/netfilter/xt_owner.c
@@ -34,12 +34,12 @@ owner_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
34 return false; 34 return false;
35 35
36 if (info->match & IPT_OWNER_UID) 36 if (info->match & IPT_OWNER_UID)
37 if ((filp->f_uid != info->uid) ^ 37 if ((filp->f_cred->fsuid != info->uid) ^
38 !!(info->invert & IPT_OWNER_UID)) 38 !!(info->invert & IPT_OWNER_UID))
39 return false; 39 return false;
40 40
41 if (info->match & IPT_OWNER_GID) 41 if (info->match & IPT_OWNER_GID)
42 if ((filp->f_gid != info->gid) ^ 42 if ((filp->f_cred->fsgid != info->gid) ^
43 !!(info->invert & IPT_OWNER_GID)) 43 !!(info->invert & IPT_OWNER_GID))
44 return false; 44 return false;
45 45
@@ -60,12 +60,12 @@ owner_mt6_v0(const struct sk_buff *skb, const struct xt_match_param *par)
60 return false; 60 return false;
61 61
62 if (info->match & IP6T_OWNER_UID) 62 if (info->match & IP6T_OWNER_UID)
63 if ((filp->f_uid != info->uid) ^ 63 if ((filp->f_cred->fsuid != info->uid) ^
64 !!(info->invert & IP6T_OWNER_UID)) 64 !!(info->invert & IP6T_OWNER_UID))
65 return false; 65 return false;
66 66
67 if (info->match & IP6T_OWNER_GID) 67 if (info->match & IP6T_OWNER_GID)
68 if ((filp->f_gid != info->gid) ^ 68 if ((filp->f_cred->fsgid != info->gid) ^
69 !!(info->invert & IP6T_OWNER_GID)) 69 !!(info->invert & IP6T_OWNER_GID))
70 return false; 70 return false;
71 71
@@ -93,14 +93,14 @@ owner_mt(const struct sk_buff *skb, const struct xt_match_param *par)
93 (XT_OWNER_UID | XT_OWNER_GID)) == 0; 93 (XT_OWNER_UID | XT_OWNER_GID)) == 0;
94 94
95 if (info->match & XT_OWNER_UID) 95 if (info->match & XT_OWNER_UID)
96 if ((filp->f_uid >= info->uid_min && 96 if ((filp->f_cred->fsuid >= info->uid_min &&
97 filp->f_uid <= info->uid_max) ^ 97 filp->f_cred->fsuid <= info->uid_max) ^
98 !(info->invert & XT_OWNER_UID)) 98 !(info->invert & XT_OWNER_UID))
99 return false; 99 return false;
100 100
101 if (info->match & XT_OWNER_GID) 101 if (info->match & XT_OWNER_GID)
102 if ((filp->f_gid >= info->gid_min && 102 if ((filp->f_cred->fsgid >= info->gid_min &&
103 filp->f_gid <= info->gid_max) ^ 103 filp->f_cred->fsgid <= info->gid_max) ^
104 !(info->invert & XT_OWNER_GID)) 104 !(info->invert & XT_OWNER_GID))
105 return false; 105 return false;
106 106
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index 0ebaff637e31..0ef4e3065bcd 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -260,14 +260,14 @@ static u32 flow_get_rtclassid(const struct sk_buff *skb)
260static u32 flow_get_skuid(const struct sk_buff *skb) 260static u32 flow_get_skuid(const struct sk_buff *skb)
261{ 261{
262 if (skb->sk && skb->sk->sk_socket && skb->sk->sk_socket->file) 262 if (skb->sk && skb->sk->sk_socket && skb->sk->sk_socket->file)
263 return skb->sk->sk_socket->file->f_uid; 263 return skb->sk->sk_socket->file->f_cred->fsuid;
264 return 0; 264 return 0;
265} 265}
266 266
267static u32 flow_get_skgid(const struct sk_buff *skb) 267static u32 flow_get_skgid(const struct sk_buff *skb)
268{ 268{
269 if (skb->sk && skb->sk->sk_socket && skb->sk->sk_socket->file) 269 if (skb->sk && skb->sk->sk_socket && skb->sk->sk_socket->file)
270 return skb->sk->sk_socket->file->f_gid; 270 return skb->sk->sk_socket->file->f_cred->fsgid;
271 return 0; 271 return 0;
272} 272}
273 273