mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 06:14:39 +01:00
cdrom: Fix spectre-v1 gadget
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 <[email protected]> Link: https://lore.kernel.org/all/[email protected] Reviewed-by: Phillip Potter <[email protected]> Link: https://lore.kernel.org/all/ZI1+1OG9Ut1MqsUC@equinox Signed-off-by: Phillip Potter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
1 parent
017fb83ee0
commit
8270cb10c0
1 file changed
+4
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user