Skip to content

Commit 11f1544

Browse files
dm ioctl: prevent potential spectre v1 gadget
jira VULN-49983 CVE-2022-49122 commit-author Jordy Zomer <[email protected]> commit cd9c88d 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 <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> (cherry picked from commit cd9c88d) Signed-off-by: Pratham Patel <[email protected]>
1 parent bfee1c4 commit 11f1544

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/md/dm-ioctl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/dm-ioctl.h>
1919
#include <linux/hdreg.h>
2020
#include <linux/compat.h>
21+
#include <linux/nospec.h>
2122

2223
#include <linux/uaccess.h>
2324

@@ -1731,6 +1732,7 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags)
17311732
if (unlikely(cmd >= ARRAY_SIZE(_ioctls)))
17321733
return NULL;
17331734

1735+
cmd = array_index_nospec(cmd, ARRAY_SIZE(_ioctls));
17341736
*ioctl_flags = _ioctls[cmd].flags;
17351737
return _ioctls[cmd].fn;
17361738
}

0 commit comments

Comments
 (0)