KEYS: Fix __key_link_end() quota fixup on error

Fix __key_link_end()'s attempt to fix up the quota if an error occurs.

There are two erroneous cases: Firstly, we always decrease the quota if
the preallocated replacement keyring needs cleaning up, irrespective of
whether or not we should (we may have replaced a pointer rather than
adding another pointer).

Secondly, we never clean up the quota if we added a pointer without the
keyring storage being extended (we allocate multiple pointers at a time,
even if we're not going to use them all immediately).

We handle this by setting the bottom bit of the preallocation pointer in
__key_link_begin() to indicate that the quota needs fixing up, which is
then passed to __key_link() (which clears the whole thing) and
__key_link_end().

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Цей коміт міститься в:
David Howells
2011-01-25 16:34:28 +00:00
зафіксовано Linus Torvalds
джерело f5c66d70ac
коміт ceb73c1204
4 змінених файлів з 27 додано та 20 видалено

Переглянути файл

@@ -352,8 +352,8 @@ static int construct_alloc_key(struct key_type *type,
struct key_user *user,
struct key **_key)
{
struct keyring_list *prealloc;
const struct cred *cred = current_cred();
unsigned long prealloc;
struct key *key;
key_ref_t key_ref;
int ret;