All of lore.kernel.org
 help / color / mirror / Atom feed
From: JiangJianJun <jiangjianjun3@huawei.com>
To: <jejb@linux.ibm.com>, <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<louhongxiang@huawei.com>, <haowenchao2@huawei.com>,
	<lixiaokeng@huawei.com>
Subject: [PATCH] scsi: sr: fix signed integer overflow
Date: Mon, 18 Dec 2023 17:50:54 +0800	[thread overview]
Message-ID: <20231218095054.12228-1-jiangjianjun3@huawei.com> (raw)

Checking the range of the parameter speed, avoid integer overflow.

Signed-off-by: JiangJianJun <jiangjianjun3@huawei.com>
---
 drivers/scsi/sr_ioctl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 5b0b35e60e61..d5b2cd80d171 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -430,6 +430,8 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed)
 	Scsi_CD *cd = cdi->handle;
 	struct packet_command cgc;
 
+	if (speed < 0 || speed > (INT_MAX / 177))
+		return -EINVAL;
 	if (speed == 0)
 		speed = 0xffff;	/* set to max */
 	else
-- 
2.39.3


                 reply	other threads:[~2023-12-18  9:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20231218095054.12228-1-jiangjianjun3@huawei.com \
    --to=jiangjianjun3@huawei.com \
    --cc=haowenchao2@huawei.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lixiaokeng@huawei.com \
    --cc=louhongxiang@huawei.com \
    --cc=martin.petersen@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.