projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
017fb83
)
cdrom: Fix spectre-v1 gadget
author
Jordy Zomer
<jordyzomer@google.com>
Sat, 17 Jun 2023 11:38:28 +0000
(12:38 +0100)
committer
Jens Axboe
<axboe@kernel.dk>
Thu, 22 Jun 2023 13:48:08 +0000
(07:48 -0600)
This patch fixes a spectre-v1 gadget in cdrom.
The gadget could be triggered by speculatively
bypassing the cdi->capacity check.
Signed-off-by: Jordy Zomer <jordyzomer@google.com>
Link:
https://lore.kernel.org/all/20230612110040.849318-2-jordyzomer@google.com
Reviewed-by: Phillip Potter <phil@philpotter.co.uk>
Link:
https://lore.kernel.org/all/ZI1+1OG9Ut1MqsUC@equinox
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
Link:
https://lore.kernel.org/r/20230617113828.1230-2-phil@philpotter.co.uk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/cdrom/cdrom.c
patch
|
blob
|
history
diff --git
a/drivers/cdrom/cdrom.c
b/drivers/cdrom/cdrom.c
index bd8cd59c758af202079ec1381d349d63339ab67e..cc283980598333c47161b8d5139135373940cd2e 100644
(file)
--- a/
drivers/cdrom/cdrom.c
+++ b/
drivers/cdrom/cdrom.c
@@
-264,6
+264,7
@@
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/mm.h>
+#include <linux/nospec.h>
#include <linux/slab.h>
#include <linux/cdrom.h>
#include <linux/sysctl.h>
@@
-2311,6
+2312,9
@@
static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi,
if (arg >= cdi->capacity)
return -EINVAL;
+ /* Prevent arg from speculatively bypassing the length check */
+ barrier_nospec();
+
info = kmalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;