Skip to content

Commit

Permalink
KEYS: fix keyctl_set_reqkey_keyring() to not leak thread keyrings
Browse files Browse the repository at this point in the history
commit c9f838d104fed6f2f61d68164712e3204bf5271b upstream.

This fixes CVE-2017-7472.

Running the following program as an unprivileged user exhausts kernel
memory by leaking thread keyrings:

	#include <keyutils.h>

	int main()
	{
		for (;;)
			keyctl_set_reqkey_keyring(KEY_REQKEY_DEFL_THREAD_KEYRING);
	}

Fix it by only creating a new thread keyring if there wasn't one before.
To make things more consistent, make install_thread_keyring_to_cred()
and install_process_keyring_to_cred() both return 0 if the corresponding
keyring is already present.

Fixes: d84f4f9 ("CRED: Inaugurate COW credentials")
Signed-off-by: Eric Biggers <[email protected]>
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>
  • Loading branch information
ebiggers authored and AndroiableDroid committed Jan 12, 2018
1 parent b460e01 commit 32f6996
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 32f6996

Please sign in to comment.