The patch titled

     Keys: Base keyring size on key pointer not key struct

has been added to the -mm tree.  Its filename is

     keys-base-keyring-size-on-key-pointer-not-key-struct.patch

Patches currently in -mm which might be from [EMAIL PROTECTED] are

frv-add-defconfig.patch
keys-base-keyring-size-on-key-pointer-not-key-struct.patch
make-max_fds-unsigned-to-avoid-sign-mismatch-in-comparison.patch
export-file_ra_state_init-again.patch
cachefs-filesystem.patch
cachefs-documentation.patch
add-page-becoming-writable-notification.patch
provide-a-filesystem-specific-syncable-page-bit.patch
make-afs-use-cachefs.patch
split-general-cache-manager-from-cachefs.patch
turn-cachefs-into-a-cache-backend.patch
rework-the-cachefs-documentation-to-reflect-fs-cache-split.patch
update-afs-client-to-reflect-cachefs-split.patch
make-page-becoming-writable-notification-a-vma-op-only-kafs-fix.patch



From: David Howells <[EMAIL PROTECTED]>

The attached patch makes the keyring functions calculate the new size of a
keyring's payload based on the size of pointer to the key struct, not the size
of the key struct itself.

Signed-Off-By: David Howells <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 security/keys/keyring.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff -puN 
security/keys/keyring.c~keys-base-keyring-size-on-key-pointer-not-key-struct 
security/keys/keyring.c
--- 
25/security/keys/keyring.c~keys-base-keyring-size-on-key-pointer-not-key-struct 
    Wed Jul  6 13:30:00 2005
+++ 25-akpm/security/keys/keyring.c     Wed Jul  6 13:30:00 2005
@@ -129,7 +129,7 @@ static int keyring_duplicate(struct key 
        int loop, ret;
 
        const unsigned limit =
-               (PAGE_SIZE - sizeof(*klist)) / sizeof(struct key);
+               (PAGE_SIZE - sizeof(*klist)) / sizeof(struct key *);
 
        ret = 0;
 
@@ -150,7 +150,7 @@ static int keyring_duplicate(struct key 
                        max = limit;
 
                ret = -ENOMEM;
-               size = sizeof(*klist) + sizeof(struct key) * max;
+               size = sizeof(*klist) + sizeof(struct key *) * max;
                klist = kmalloc(size, GFP_KERNEL);
                if (!klist)
                        goto error;
@@ -163,7 +163,7 @@ static int keyring_duplicate(struct key 
                klist->nkeys = sklist->nkeys;
                memcpy(klist->keys,
                       sklist->keys,
-                      sklist->nkeys * sizeof(struct key));
+                      sklist->nkeys * sizeof(struct key *));
 
                for (loop = klist->nkeys - 1; loop >= 0; loop--)
                        atomic_inc(&klist->keys[loop]->usage);
@@ -783,7 +783,7 @@ int __key_link(struct key *keyring, stru
                ret = -ENFILE;
                if (max > 65535)
                        goto error3;
-               size = sizeof(*klist) + sizeof(*key) * max;
+               size = sizeof(*klist) + sizeof(struct key *) * max;
                if (size > PAGE_SIZE)
                        goto error3;
 
@@ -895,7 +895,8 @@ int key_unlink(struct key *keyring, stru
 
 key_is_present:
        /* we need to copy the key list for RCU purposes */
-       nklist = kmalloc(sizeof(*klist) + sizeof(*key) * klist->maxkeys,
+       nklist = kmalloc(sizeof(*klist) +
+                        sizeof(struct key *) * klist->maxkeys,
                         GFP_KERNEL);
        if (!nklist)
                goto nomem;
@@ -905,12 +906,12 @@ key_is_present:
        if (loop > 0)
                memcpy(&nklist->keys[0],
                       &klist->keys[0],
-                      loop * sizeof(klist->keys[0]));
+                      loop * sizeof(struct key *));
 
        if (loop < nklist->nkeys)
                memcpy(&nklist->keys[loop],
                       &klist->keys[loop + 1],
-                      (nklist->nkeys - loop) * sizeof(klist->keys[0]));
+                      (nklist->nkeys - loop) * sizeof(struct key *));
 
        /* adjust the user's quota */
        key_payload_reserve(keyring,
_
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to