mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dm ioct: prevent potential specter v1 gadget
@ 2022-01-29 14:37 Jordy Zomer
  2022-01-29 14:58 ` [PATCH v2] " Jordy Zomer
  2022-01-29 17:01 ` [PATCH] " kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Jordy Zomer @ 2022-01-29 14:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jordy Zomer, Alasdair Kergon, Mike Snitzer, dm-devel

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>
---
 drivers/md/dm-ioctl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 21fe8652b095..0c1f9983f080 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -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;
 }
-- 
2.27.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-29 17:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-29 14:37 [PATCH] dm ioct: prevent potential specter v1 gadget Jordy Zomer
2022-01-29 14:58 ` [PATCH v2] " Jordy Zomer
2022-01-29 17:01 ` [PATCH] " kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome