aboutsummaryrefslogtreecommitdiffstats
path: root/net/ax25
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-05-24 14:55:00 -0400
committerEric W. Biederman <ebiederm@xmission.com>2012-08-15 00:49:42 -0400
commitd13fda8564a67341aad257465cf319bdb2327e33 (patch)
treeb67146926931195117b1401b03097933c857b4cf /net/ax25
parent523a6a945f3cf5f1d337e50634687a577a732a5f (diff)
userns: Convert net/ax25 to use kuid_t where appropriate
Cc: Ralf Baechle <ralf@linux-mips.org> Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'net/ax25')
-rw-r--r--net/ax25/ax25_uid.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/net/ax25/ax25_uid.c b/net/ax25/ax25_uid.c
index e3c579ba6325..957999e43ff7 100644
--- a/net/ax25/ax25_uid.c
+++ b/net/ax25/ax25_uid.c
@@ -51,14 +51,14 @@ int ax25_uid_policy;
51 51
52EXPORT_SYMBOL(ax25_uid_policy); 52EXPORT_SYMBOL(ax25_uid_policy);
53 53
54ax25_uid_assoc *ax25_findbyuid(uid_t uid) 54ax25_uid_assoc *ax25_findbyuid(kuid_t uid)
55{ 55{
56 ax25_uid_assoc *ax25_uid, *res = NULL; 56 ax25_uid_assoc *ax25_uid, *res = NULL;
57 struct hlist_node *node; 57 struct hlist_node *node;
58 58
59 read_lock(&ax25_uid_lock); 59 read_lock(&ax25_uid_lock);
60 ax25_uid_for_each(ax25_uid, node, &ax25_uid_list) { 60 ax25_uid_for_each(ax25_uid, node, &ax25_uid_list) {
61 if (ax25_uid->uid == uid) { 61 if (uid_eq(ax25_uid->uid, uid)) {
62 ax25_uid_hold(ax25_uid); 62 ax25_uid_hold(ax25_uid);
63 res = ax25_uid; 63 res = ax25_uid;
64 break; 64 break;
@@ -84,7 +84,7 @@ int ax25_uid_ioctl(int cmd, struct sockaddr_ax25 *sax)
84 read_lock(&ax25_uid_lock); 84 read_lock(&ax25_uid_lock);
85 ax25_uid_for_each(ax25_uid, node, &ax25_uid_list) { 85 ax25_uid_for_each(ax25_uid, node, &ax25_uid_list) {
86 if (ax25cmp(&sax->sax25_call, &ax25_uid->call) == 0) { 86 if (ax25cmp(&sax->sax25_call, &ax25_uid->call) == 0) {
87 res = ax25_uid->uid; 87 res = from_kuid_munged(current_user_ns(), ax25_uid->uid);
88 break; 88 break;
89 } 89 }
90 } 90 }
@@ -93,9 +93,14 @@ int ax25_uid_ioctl(int cmd, struct sockaddr_ax25 *sax)
93 return res; 93 return res;
94 94
95 case SIOCAX25ADDUID: 95 case SIOCAX25ADDUID:
96 {
97 kuid_t sax25_kuid;
96 if (!capable(CAP_NET_ADMIN)) 98 if (!capable(CAP_NET_ADMIN))
97 return -EPERM; 99 return -EPERM;
98 user = ax25_findbyuid(sax->sax25_uid); 100 sax25_kuid = make_kuid(current_user_ns(), sax->sax25_uid);
101 if (!uid_valid(sax25_kuid))
102 return -EINVAL;
103 user = ax25_findbyuid(sax25_kuid);
99 if (user) { 104 if (user) {
100 ax25_uid_put(user); 105 ax25_uid_put(user);
101 return -EEXIST; 106 return -EEXIST;
@@ -106,7 +111,7 @@ int ax25_uid_ioctl(int cmd, struct sockaddr_ax25 *sax)
106 return -ENOMEM; 111 return -ENOMEM;
107 112
108 atomic_set(&ax25_uid->refcount, 1); 113 atomic_set(&ax25_uid->refcount, 1);
109 ax25_uid->uid = sax->sax25_uid; 114 ax25_uid->uid = sax25_kuid;
110 ax25_uid->call = sax->sax25_call; 115 ax25_uid->call = sax->sax25_call;
111 116
112 write_lock(&ax25_uid_lock); 117 write_lock(&ax25_uid_lock);
@@ -114,7 +119,7 @@ int ax25_uid_ioctl(int cmd, struct sockaddr_ax25 *sax)
114 write_unlock(&ax25_uid_lock); 119 write_unlock(&ax25_uid_lock);
115 120
116 return 0; 121 return 0;
117 122 }
118 case SIOCAX25DELUID: 123 case SIOCAX25DELUID:
119 if (!capable(CAP_NET_ADMIN)) 124 if (!capable(CAP_NET_ADMIN))
120 return -EPERM; 125 return -EPERM;
@@ -172,7 +177,9 @@ static int ax25_uid_seq_show(struct seq_file *seq, void *v)
172 struct ax25_uid_assoc *pt; 177 struct ax25_uid_assoc *pt;
173 178
174 pt = hlist_entry(v, struct ax25_uid_assoc, uid_node); 179 pt = hlist_entry(v, struct ax25_uid_assoc, uid_node);
175 seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(buf, &pt->call)); 180 seq_printf(seq, "%6d %s\n",
181 from_kuid_munged(seq_user_ns(seq), pt->uid),
182 ax2asc(buf, &pt->call));
176 } 183 }
177 return 0; 184 return 0;
178} 185}