android_kernel_samsung_a7y1.../security
Hillf Danton 6eeb4b5587 keys: Fix missing null pointer check in request_key_auth_describe()
[ Upstream commit d41a3effbb53b1bcea41e328d16a4d046a508381 ]

If a request_key authentication token key gets revoked, there's a window in
which request_key_auth_describe() can see it with a NULL payload - but it
makes no check for this and something like the following oops may occur:

	BUG: Kernel NULL pointer dereference at 0x00000038
	Faulting instruction address: 0xc0000000004ddf30
	Oops: Kernel access of bad area, sig: 11 [#1]
	...
	NIP [...] request_key_auth_describe+0x90/0xd0
	LR [...] request_key_auth_describe+0x54/0xd0
	Call Trace:
	[...] request_key_auth_describe+0x54/0xd0 (unreliable)
	[...] proc_keys_show+0x308/0x4c0
	[...] seq_read+0x3d0/0x540
	[...] proc_reg_read+0x90/0x110
	[...] __vfs_read+0x3c/0x70
	[...] vfs_read+0xb4/0x1b0
	[...] ksys_read+0x7c/0x130
	[...] system_call+0x5c/0x70

Fix this by checking for a NULL pointer when describing such a key.

Also make the read routine check for a NULL pointer to be on the safe side.

[DH: Modified to not take already-held rcu lock and modified to also check
 in the read routine]

Fixes: 04c567d9313e ("[PATCH] Keys: Fix race between two instantiators of a key")
Reported-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Signed-off-by: Hillf Danton <hdanton@sina.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-04-06 21:37:05 +02:00
..
apparmor apparmor: enforce nullbyte at end of tag string 2020-04-06 19:16:20 +02:00
defex_lsm Revert "security: defex: set Defex to Permissive status" 2020-04-06 19:40:02 +05:30
dsms A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
integrity A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
keys keys: Fix missing null pointer check in request_key_auth_describe() 2020-04-06 21:37:05 +02:00
mstdrv A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
proca A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
samsung A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sdp A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
selinux selinux: fix memory leak in policydb_init() 2020-04-06 20:27:38 +02:00
smack A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tima_uevent A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tomoyo A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tz_iccc A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
yama A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
commoncap.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
device_cgroup.c device_cgroup: fix RCU imbalance in error case 2020-04-06 15:57:12 +02:00
inode.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
lsm_audit.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
min_addr.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
security.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30