提交 db5d95ad 编写于 作者: J Jordy Zomer 提交者: Yongqiang Liu

dm ioctl: prevent potential spectre v1 gadget

stable inclusion
from stable-4.19.238
commit 7ae2c5b89da3cfaf856df880af27d3bb32a74b3d
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5A6BA
CVE: NA

--------------------------------

[ Upstream commit cd9c88da ]

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: NJordy Zomer <jordy@pwning.systems>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 394ec9b5
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/dm-ioctl.h> #include <linux/dm-ioctl.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/nospec.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
...@@ -1669,6 +1670,7 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags) ...@@ -1669,6 +1670,7 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags)
if (unlikely(cmd >= ARRAY_SIZE(_ioctls))) if (unlikely(cmd >= ARRAY_SIZE(_ioctls)))
return NULL; return NULL;
cmd = array_index_nospec(cmd, ARRAY_SIZE(_ioctls));
*ioctl_flags = _ioctls[cmd].flags; *ioctl_flags = _ioctls[cmd].flags;
return _ioctls[cmd].fn; return _ioctls[cmd].fn;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册