]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - security/keys/proc.c
Merge branch 'linux-next' of git://git.infradead.org/ubifs-2.6
[linux-2.6-omap-h63xx.git] / security / keys / proc.c
index 694126003ed3bcfaacc980e3210540de38cda107..7f508def50e319a5110032a7e169a19a5ec02fab 100644 (file)
@@ -70,19 +70,15 @@ static int __init key_proc_init(void)
        struct proc_dir_entry *p;
 
 #ifdef CONFIG_KEYS_DEBUG_PROC_KEYS
-       p = create_proc_entry("keys", 0, NULL);
+       p = proc_create("keys", 0, NULL, &proc_keys_fops);
        if (!p)
                panic("Cannot create /proc/keys\n");
-
-       p->proc_fops = &proc_keys_fops;
 #endif
 
-       p = create_proc_entry("key-users", 0, NULL);
+       p = proc_create("key-users", 0, NULL, &proc_key_users_fops);
        if (!p)
                panic("Cannot create /proc/key-users\n");
 
-       p->proc_fops = &proc_key_users_fops;
-
        return 0;
 
 } /* end key_proc_init() */
@@ -140,8 +136,12 @@ static int proc_keys_show(struct seq_file *m, void *v)
        int rc;
 
        /* check whether the current task is allowed to view the key (assuming
-        * non-possession) */
-       rc = key_task_permission(make_key_ref(key, 0), current, KEY_VIEW);
+        * non-possession)
+        * - the caller holds a spinlock, and thus the RCU read lock, making our
+        *   access to __current_cred() safe
+        */
+       rc = key_task_permission(make_key_ref(key, 0), current_cred(),
+                                KEY_VIEW);
        if (rc < 0)
                return 0;
 
@@ -246,6 +246,10 @@ static int proc_key_users_show(struct seq_file *m, void *v)
 {
        struct rb_node *_p = v;
        struct key_user *user = rb_entry(_p, struct key_user, node);
+       unsigned maxkeys = (user->uid == 0) ?
+               key_quota_root_maxkeys : key_quota_maxkeys;
+       unsigned maxbytes = (user->uid == 0) ?
+               key_quota_root_maxbytes : key_quota_maxbytes;
 
        seq_printf(m, "%5u: %5d %d/%d %d/%d %d/%d\n",
                   user->uid,
@@ -253,10 +257,9 @@ static int proc_key_users_show(struct seq_file *m, void *v)
                   atomic_read(&user->nkeys),
                   atomic_read(&user->nikeys),
                   user->qnkeys,
-                  KEYQUOTA_MAX_KEYS,
+                  maxkeys,
                   user->qnbytes,
-                  KEYQUOTA_MAX_BYTES
-                  );
+                  maxbytes);
 
        return 0;