Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dm ioct: prevent potential specter 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>
  • Loading branch information
JordyZomer authored and intel-lab-lkp committed Jan 29, 2022
1 parent eaac0b5 commit 494fed5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/md/dm-ioctl.c
Expand Up @@ -1788,6 +1788,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;
}
Expand Down

0 comments on commit 494fed5

Please sign in to comment.