[PATCH] KEYS: fix dereferencing NULL payload with nonzero length
From: Eric Biggers <hidden>
Date: 2017-05-31 19:11:12
Also in:
keyrings, lkml, stable
On Mon, Apr 03, 2017 at 02:30:41PM -0700, Eric Biggers wrote:
On Mon, Apr 03, 2017 at 08:20:44PM +0100, David Howells wrote:quoted
Eric Biggers [off-list ref] wrote:quoted
quoted
quoted
- if (_payload) { + if (plen) {"if (_payload && plen)" would be better. DavidNo, that doesn't solve the problem. The problem is that userspace can pass in a NULL payload with nonzero length, causing the kernel to dereference a NULL pointer for some key types. For example:Okay, in that case, I think there should be an else-statement that clears plen if !_payload. DavidI think it's preferable to return EFAULT in the case in question. Most syscalls work like that, i.e. if you say you have 100 bytes (or any number > 0) at address NULL you'll get EFAULT. Also note that anyone doing this before would have been either crashing the kernel or getting EINVAL. So starting to return EFAULT would be very unlikely to break anything. - Eric
David, can you please apply this? Or if you haven't applied it because you prefer the other solution then please explain your reasoning. It's really not acceptable for unprivileged users to be able to trivially oops the kernel. Eric -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html