diff options
author | Jordy Zomer <jordy@jordyzomer.github.io> | 2022-01-29 15:58:39 +0100 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2022-02-22 11:04:41 -0500 |
commit | cd9c88da171a62c4b0f1c70e50c75845969fbc18 (patch) | |
tree | e6af6dfa8a8a35becda7882bb15f6439ef7fab36 | |
parent | a8b9d116cda047f38ba29ce26df49c57479ffaa2 (diff) |
dm ioctl: prevent potential spectre v1 gadget
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>
-rw-r--r-- | drivers/md/dm-ioctl.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 21fe8652b095..901abd6dea41 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -18,6 +18,7 @@ #include <linux/dm-ioctl.h> #include <linux/hdreg.h> #include <linux/compat.h> +#include <linux/nospec.h> #include <linux/uaccess.h> #include <linux/ima.h> @@ -1788,6 +1789,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; } |