Skip to content

Commit d13fda8

Browse files
committed
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>
1 parent 523a6a9 commit d13fda8

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

‎include/net/ax25.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ enum {
157157
typedef struct ax25_uid_assoc {
158158
struct hlist_node uid_node;
159159
atomic_t refcount;
160-
uid_t uid;
160+
kuid_t uid;
161161
ax25_address call;
162162
} ax25_uid_assoc;
163163

@@ -434,7 +434,7 @@ extern unsigned long ax25_display_timer(struct timer_list *);
434434

435435
/* ax25_uid.c */
436436
extern int ax25_uid_policy;
437-
extern ax25_uid_assoc *ax25_findbyuid(uid_t);
437+
extern ax25_uid_assoc *ax25_findbyuid(kuid_t);
438438
extern int __must_check ax25_uid_ioctl(int, struct sockaddr_ax25 *);
439439
extern const struct file_operations ax25_uid_fops;
440440
extern void ax25_uid_free(void);

‎init/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,6 @@ config UIDGID_CONVERTED
952952
depends on NET_KEY = n
953953
depends on INET_DIAG = n
954954
depends on DNS_RESOLVER = n
955-
depends on AX25 = n
956955

957956
# Filesystems
958957
depends on USB_GADGETFS = n

‎net/ax25/ax25_uid.c‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ int ax25_uid_policy;
5151

5252
EXPORT_SYMBOL(ax25_uid_policy);
5353

54-
ax25_uid_assoc *ax25_findbyuid(uid_t uid)
54+
ax25_uid_assoc *ax25_findbyuid(kuid_t uid)
5555
{
5656
ax25_uid_assoc *ax25_uid, *res = NULL;
5757
struct hlist_node *node;
5858

5959
read_lock(&ax25_uid_lock);
6060
ax25_uid_for_each(ax25_uid, node, &ax25_uid_list) {
61-
if (ax25_uid->uid == uid) {
61+
if (uid_eq(ax25_uid->uid, uid)) {
6262
ax25_uid_hold(ax25_uid);
6363
res = ax25_uid;
6464
break;
@@ -84,7 +84,7 @@ int ax25_uid_ioctl(int cmd, struct sockaddr_ax25 *sax)
8484
read_lock(&ax25_uid_lock);
8585
ax25_uid_for_each(ax25_uid, node, &ax25_uid_list) {
8686
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);
8888
break;
8989
}
9090
}
@@ -93,9 +93,14 @@ int ax25_uid_ioctl(int cmd, struct sockaddr_ax25 *sax)
9393
return res;
9494

9595
case SIOCAX25ADDUID:
96+
{
97+
kuid_t sax25_kuid;
9698
if (!capable(CAP_NET_ADMIN))
9799
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);
99104
if (user) {
100105
ax25_uid_put(user);
101106
return -EEXIST;
@@ -106,15 +111,15 @@ int ax25_uid_ioctl(int cmd, struct sockaddr_ax25 *sax)
106111
return -ENOMEM;
107112

108113
atomic_set(&ax25_uid->refcount, 1);
109-
ax25_uid->uid = sax->sax25_uid;
114+
ax25_uid->uid = sax25_kuid;
110115
ax25_uid->call = sax->sax25_call;
111116

112117
write_lock(&ax25_uid_lock);
113118
hlist_add_head(&ax25_uid->uid_node, &ax25_uid_list);
114119
write_unlock(&ax25_uid_lock);
115120

116121
return 0;
117-
122+
}
118123
case SIOCAX25DELUID:
119124
if (!capable(CAP_NET_ADMIN))
120125
return -EPERM;
@@ -172,7 +177,9 @@ static int ax25_uid_seq_show(struct seq_file *seq, void *v)
172177
struct ax25_uid_assoc *pt;
173178

174179
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));
176183
}
177184
return 0;
178185
}

0 commit comments

Comments
 (0)