mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jordy Zomer <jordyzomer@google.com>
To: linux-kernel@vger.kernel.org
Cc: phil@philpotter.co.uk, Jordy Zomer <jordyzomer@google.com>
Subject: [PATCH 1/1] cdrom: Fix spectre-v1 gadget
Date: Fri,  9 Jun 2023 13:13:55 +0000	[thread overview]
Message-ID: <20230609131355.71130-2-jordyzomer@google.com> (raw)
In-Reply-To: <20230609131355.71130-1-jordyzomer@google.com>

This patch fixes a spectre-v1 gadget in cdrom.
The gadget could be triggered by,
 speculatviely bypassing the cdi->capacity check.

Signed-off-by: Jordy Zomer <jordyzomer@google.com>
---
 drivers/cdrom/cdrom.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 416f723a2dbb..3c349bc0a269 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -233,6 +233,7 @@
 
 -------------------------------------------------------------------------*/
 
+#include "asm/barrier.h"
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #define REVISION "Revision: 3.20"
@@ -2329,6 +2330,8 @@ static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi,
 	if (arg >= cdi->capacity)
 		return -EINVAL;
 
+	arg = array_index_mask_nospec(arg, cdi->capacity);
+
 	info = kmalloc(sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
-- 
2.41.0.162.gfafddb0af9-goog


  reply	other threads:[~2023-06-09 13:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09 13:13 [PATCH 0/1] " Jordy Zomer
2023-06-09 13:13 ` Jordy Zomer [this message]
2023-06-09 17:19   ` [PATCH 1/1] " kernel test robot
2023-06-09 23:46   ` Pawan Gupta
2023-06-10 19:10   ` Phillip Potter
2023-06-12  9:35     ` Jordy Zomer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230609131355.71130-2-jordyzomer@google.com \
    --to=jordyzomer@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phil@philpotter.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®