diff options
Diffstat (limited to 'security/keys/proc.c')
-rw-r--r-- | security/keys/proc.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/security/keys/proc.c b/security/keys/proc.c index 30d1ddfd9cef..217b6855e815 100644 --- a/security/keys/proc.c +++ b/security/keys/proc.c | |||
@@ -88,14 +88,14 @@ __initcall(key_proc_init); | |||
88 | */ | 88 | */ |
89 | #ifdef CONFIG_KEYS_DEBUG_PROC_KEYS | 89 | #ifdef CONFIG_KEYS_DEBUG_PROC_KEYS |
90 | 90 | ||
91 | static struct rb_node *key_serial_next(struct rb_node *n) | 91 | static struct rb_node *key_serial_next(struct seq_file *p, struct rb_node *n) |
92 | { | 92 | { |
93 | struct user_namespace *user_ns = current_user_ns(); | 93 | struct user_namespace *user_ns = seq_user_ns(p); |
94 | 94 | ||
95 | n = rb_next(n); | 95 | n = rb_next(n); |
96 | while (n) { | 96 | while (n) { |
97 | struct key *key = rb_entry(n, struct key, serial_node); | 97 | struct key *key = rb_entry(n, struct key, serial_node); |
98 | if (key->user->user_ns == user_ns) | 98 | if (kuid_has_mapping(user_ns, key->user->uid)) |
99 | break; | 99 | break; |
100 | n = rb_next(n); | 100 | n = rb_next(n); |
101 | } | 101 | } |
@@ -107,9 +107,9 @@ static int proc_keys_open(struct inode *inode, struct file *file) | |||
107 | return seq_open(file, &proc_keys_ops); | 107 | return seq_open(file, &proc_keys_ops); |
108 | } | 108 | } |
109 | 109 | ||
110 | static struct key *find_ge_key(key_serial_t id) | 110 | static struct key *find_ge_key(struct seq_file *p, key_serial_t id) |
111 | { | 111 | { |
112 | struct user_namespace *user_ns = current_user_ns(); | 112 | struct user_namespace *user_ns = seq_user_ns(p); |
113 | struct rb_node *n = key_serial_tree.rb_node; | 113 | struct rb_node *n = key_serial_tree.rb_node; |
114 | struct key *minkey = NULL; | 114 | struct key *minkey = NULL; |
115 | 115 | ||
@@ -132,7 +132,7 @@ static struct key *find_ge_key(key_serial_t id) | |||
132 | return NULL; | 132 | return NULL; |
133 | 133 | ||
134 | for (;;) { | 134 | for (;;) { |
135 | if (minkey->user->user_ns == user_ns) | 135 | if (kuid_has_mapping(user_ns, minkey->user->uid)) |
136 | return minkey; | 136 | return minkey; |
137 | n = rb_next(&minkey->serial_node); | 137 | n = rb_next(&minkey->serial_node); |
138 | if (!n) | 138 | if (!n) |
@@ -151,7 +151,7 @@ static void *proc_keys_start(struct seq_file *p, loff_t *_pos) | |||
151 | 151 | ||
152 | if (*_pos > INT_MAX) | 152 | if (*_pos > INT_MAX) |
153 | return NULL; | 153 | return NULL; |
154 | key = find_ge_key(pos); | 154 | key = find_ge_key(p, pos); |
155 | if (!key) | 155 | if (!key) |
156 | return NULL; | 156 | return NULL; |
157 | *_pos = key->serial; | 157 | *_pos = key->serial; |
@@ -168,7 +168,7 @@ static void *proc_keys_next(struct seq_file *p, void *v, loff_t *_pos) | |||
168 | { | 168 | { |
169 | struct rb_node *n; | 169 | struct rb_node *n; |
170 | 170 | ||
171 | n = key_serial_next(v); | 171 | n = key_serial_next(p, v); |
172 | if (n) | 172 | if (n) |
173 | *_pos = key_node_serial(n); | 173 | *_pos = key_node_serial(n); |
174 | return n; | 174 | return n; |
@@ -254,8 +254,8 @@ static int proc_keys_show(struct seq_file *m, void *v) | |||
254 | atomic_read(&key->usage), | 254 | atomic_read(&key->usage), |
255 | xbuf, | 255 | xbuf, |
256 | key->perm, | 256 | key->perm, |
257 | key->uid, | 257 | from_kuid_munged(seq_user_ns(m), key->uid), |
258 | key->gid, | 258 | from_kgid_munged(seq_user_ns(m), key->gid), |
259 | key->type->name); | 259 | key->type->name); |
260 | 260 | ||
261 | #undef showflag | 261 | #undef showflag |
@@ -270,26 +270,26 @@ static int proc_keys_show(struct seq_file *m, void *v) | |||
270 | 270 | ||
271 | #endif /* CONFIG_KEYS_DEBUG_PROC_KEYS */ | 271 | #endif /* CONFIG_KEYS_DEBUG_PROC_KEYS */ |
272 | 272 | ||
273 | static struct rb_node *__key_user_next(struct rb_node *n) | 273 | static struct rb_node *__key_user_next(struct user_namespace *user_ns, struct rb_node *n) |
274 | { | 274 | { |
275 | while (n) { | 275 | while (n) { |
276 | struct key_user *user = rb_entry(n, struct key_user, node); | 276 | struct key_user *user = rb_entry(n, struct key_user, node); |
277 | if (user->user_ns == current_user_ns()) | 277 | if (kuid_has_mapping(user_ns, user->uid)) |
278 | break; | 278 | break; |
279 | n = rb_next(n); | 279 | n = rb_next(n); |
280 | } | 280 | } |
281 | return n; | 281 | return n; |
282 | } | 282 | } |
283 | 283 | ||
284 | static struct rb_node *key_user_next(struct rb_node *n) | 284 | static struct rb_node *key_user_next(struct user_namespace *user_ns, struct rb_node *n) |
285 | { | 285 | { |
286 | return __key_user_next(rb_next(n)); | 286 | return __key_user_next(user_ns, rb_next(n)); |
287 | } | 287 | } |
288 | 288 | ||
289 | static struct rb_node *key_user_first(struct rb_root *r) | 289 | static struct rb_node *key_user_first(struct user_namespace *user_ns, struct rb_root *r) |
290 | { | 290 | { |
291 | struct rb_node *n = rb_first(r); | 291 | struct rb_node *n = rb_first(r); |
292 | return __key_user_next(n); | 292 | return __key_user_next(user_ns, n); |
293 | } | 293 | } |
294 | 294 | ||
295 | /* | 295 | /* |
@@ -309,10 +309,10 @@ static void *proc_key_users_start(struct seq_file *p, loff_t *_pos) | |||
309 | 309 | ||
310 | spin_lock(&key_user_lock); | 310 | spin_lock(&key_user_lock); |
311 | 311 | ||
312 | _p = key_user_first(&key_user_tree); | 312 | _p = key_user_first(seq_user_ns(p), &key_user_tree); |
313 | while (pos > 0 && _p) { | 313 | while (pos > 0 && _p) { |
314 | pos--; | 314 | pos--; |
315 | _p = key_user_next(_p); | 315 | _p = key_user_next(seq_user_ns(p), _p); |
316 | } | 316 | } |
317 | 317 | ||
318 | return _p; | 318 | return _p; |
@@ -321,7 +321,7 @@ static void *proc_key_users_start(struct seq_file *p, loff_t *_pos) | |||
321 | static void *proc_key_users_next(struct seq_file *p, void *v, loff_t *_pos) | 321 | static void *proc_key_users_next(struct seq_file *p, void *v, loff_t *_pos) |
322 | { | 322 | { |
323 | (*_pos)++; | 323 | (*_pos)++; |
324 | return key_user_next((struct rb_node *)v); | 324 | return key_user_next(seq_user_ns(p), (struct rb_node *)v); |
325 | } | 325 | } |
326 | 326 | ||
327 | static void proc_key_users_stop(struct seq_file *p, void *v) | 327 | static void proc_key_users_stop(struct seq_file *p, void *v) |
@@ -334,13 +334,13 @@ static int proc_key_users_show(struct seq_file *m, void *v) | |||
334 | { | 334 | { |
335 | struct rb_node *_p = v; | 335 | struct rb_node *_p = v; |
336 | struct key_user *user = rb_entry(_p, struct key_user, node); | 336 | struct key_user *user = rb_entry(_p, struct key_user, node); |
337 | unsigned maxkeys = (user->uid == 0) ? | 337 | unsigned maxkeys = uid_eq(user->uid, GLOBAL_ROOT_UID) ? |
338 | key_quota_root_maxkeys : key_quota_maxkeys; | 338 | key_quota_root_maxkeys : key_quota_maxkeys; |
339 | unsigned maxbytes = (user->uid == 0) ? | 339 | unsigned maxbytes = uid_eq(user->uid, GLOBAL_ROOT_UID) ? |
340 | key_quota_root_maxbytes : key_quota_maxbytes; | 340 | key_quota_root_maxbytes : key_quota_maxbytes; |
341 | 341 | ||
342 | seq_printf(m, "%5u: %5d %d/%d %d/%d %d/%d\n", | 342 | seq_printf(m, "%5u: %5d %d/%d %d/%d %d/%d\n", |
343 | user->uid, | 343 | from_kuid_munged(seq_user_ns(m), user->uid), |
344 | atomic_read(&user->usage), | 344 | atomic_read(&user->usage), |
345 | atomic_read(&user->nkeys), | 345 | atomic_read(&user->nkeys), |
346 | atomic_read(&user->nikeys), | 346 | atomic_read(&user->nikeys), |