From: Kshitij Paranjape <kshitijvparanjape@gmail.com>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Doug Gilbert <dgilbert@interlog.com>,
"James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com,
khalid@kernel.org, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev,
Kshitij Paranjape <kshitijvparanjape@gmail.com>,
stable@vger.kernel.org,
syzbot+270f1c719ee7baab9941@syzkaller.appspotmail.com
Subject: [PATCH] scsi: fix shift out-of-bounds in sg_build_indirect The num variable is set to 0. The variable num gets its value from scatter_elem_sz. However the minimum value of scatter_elem_sz is PAGE_SHIFT. So setting num to PAGE_SIZE when num < PAGE_SIZE.
Date: Mon, 6 Oct 2025 23:16:58 +0530 [thread overview]
Message-ID: <20251006174658.217497-1-kshitijvparanjape@gmail.com> (raw)
Cc: <stable@vger.kernel.org>
Reported-by: syzbot+270f1c719ee7baab9941@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=270f1c719ee7baab9941
Signed-off-by: Kshitij Paranjape <kshitijvparanjape@gmail.com>
---
drivers/scsi/sg.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index effb7e768165..9ae41bb256d7 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1888,6 +1888,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
if (num < PAGE_SIZE) {
scatter_elem_sz = PAGE_SIZE;
scatter_elem_sz_prev = PAGE_SIZE;
+ num = scatter_elem_sz;
} else
scatter_elem_sz_prev = num;
}
--
2.43.0
next reply other threads:[~2025-10-06 17:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-06 17:46 Kshitij Paranjape [this message]
2025-10-06 18:00 ` [PATCH] scsi: fix shift out-of-bounds in sg_build_indirect The num variable is set to 0. The variable num gets its value from scatter_elem_sz. However the minimum value of scatter_elem_sz is PAGE_SHIFT. So setting num to PAGE_SIZE when num < PAGE_SIZE vivek yadav
2025-10-06 19:23 ` Khalid Aziz
2025-10-06 19:41 ` Khalid Aziz
2025-10-07 1:42 ` David Hunter
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=20251006174658.217497-1-kshitijvparanjape@gmail.com \
--to=kshitijvparanjape@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=david.hunter.linux@gmail.com \
--cc=dgilbert@interlog.com \
--cc=khalid@kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=skhan@linuxfoundation.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+270f1c719ee7baab9941@syzkaller.appspotmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox