Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4268
b: refs/heads/master
c: a4014d8
h: refs/heads/master
v: v3
  • Loading branch information
David Howells authored and Linus Torvalds committed Jul 8, 2005
1 parent e76750d commit dbabead
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 682d4fc93105ebf0bdfbb04a4b85047999b17844
refs/heads/master: a4014d8f61a6a136d22422cf8aa978e6495dbad9
15 changes: 8 additions & 7 deletions trunk/security/keys/keyring.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int keyring_duplicate(struct key *keyring, const struct key *source)
int loop, ret;

const unsigned limit =
(PAGE_SIZE - sizeof(*klist)) / sizeof(struct key);
(PAGE_SIZE - sizeof(*klist)) / sizeof(struct key *);

ret = 0;

Expand All @@ -150,7 +150,7 @@ static int keyring_duplicate(struct key *keyring, const struct key *source)
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;
Expand All @@ -163,7 +163,7 @@ static int keyring_duplicate(struct key *keyring, const struct key *source)
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);
Expand Down Expand Up @@ -783,7 +783,7 @@ int __key_link(struct key *keyring, struct key *key)
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;

Expand Down Expand Up @@ -895,7 +895,8 @@ int key_unlink(struct key *keyring, struct key *key)

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;
Expand All @@ -905,12 +906,12 @@ int key_unlink(struct key *keyring, struct key *key)
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,
Expand Down

0 comments on commit dbabead

Please sign in to comment.