dm ioctl: prevent potential spectre v1 gadget
[ Upstream commit cd9c88da17 ]
It appears like cmd could be a Spectre v1 gadget as it's supplied by a
user and used as an array index. Prevent the contents of kernel memory
from being leaked to userspace via speculative execution by using
array_index_nospec.
Signed-off-by: Jordy Zomer <jordy@pwning.systems>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f655b724b4
commit
71c8df33fd
1 changed files with 2 additions and 0 deletions
|
|
@ -17,6 +17,7 @@
|
|||
#include <linux/dm-ioctl.h>
|
||||
#include <linux/hdreg.h>
|
||||
#include <linux/compat.h>
|
||||
#include <linux/nospec.h>
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
|
|
@ -1696,6 +1697,7 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags)
|
|||
if (unlikely(cmd >= ARRAY_SIZE(_ioctls)))
|
||||
return NULL;
|
||||
|
||||
cmd = array_index_nospec(cmd, ARRAY_SIZE(_ioctls));
|
||||
*ioctl_flags = _ioctls[cmd].flags;
|
||||
return _ioctls[cmd].fn;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue