From: Greg KH <gregkh@linuxfoundation.org>
To: Chen Yufeng <chenyufeng@iie.ac.cn>
Cc: bootc@bootc.net, martin.petersen@oracle.com,
Thinh.Nguyen@synopsys.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] drivers: Two potential integer overflow in sbp_make_tpg() and usbg_make_tpg()
Date: Thu, 10 Apr 2025 19:01:39 +0200 [thread overview]
Message-ID: <2025041025-cozy-pug-fa22@gregkh> (raw)
In-Reply-To: <20250410140550.1647-1-chenyufeng@iie.ac.cn>
On Thu, Apr 10, 2025 at 10:05:49PM +0800, Chen Yufeng wrote:
> The variable tpgt in sbp_make_tpg() and usbg_make_tpg() is defined as
> unsigned long and is assigned to tpgt->tport_tpgt, which is defined as u16.
> This may cause an integer overflow when tpgt is greater than USHRT_MAX
> (65535).
Can that actually ever happen?
If so, why not just fix up "tpgt" to be u16?
> My fix is based on the implementation of tcm_qla2xxx_make_tpg() in
> drivers/scsi/qla2xxx/tcm_qla2xxx.c which limits tpgt to USHRT_MAX.
Again, why not restrict the size of the variable to start with?
>
> This patch is similar to
> commit 59c816c1f24d ("vhost/scsi: potential memory corruption").
>
> Signed-off-by: Chen Yufeng <chenyufeng@iie.ac.cn>
> ---
> drivers/target/sbp/sbp_target.c | 2 +-
> drivers/usb/gadget/function/f_tcm.c | 2 +-
You have to split this into two different patches as it goes through two
different trees before we could take it.
thanks,
greg k-h
next prev parent reply other threads:[~2025-04-10 17:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 14:05 [PATCH] drivers: Two potential integer overflow in sbp_make_tpg() and usbg_make_tpg() Chen Yufeng
2025-04-10 17:01 ` Greg KH [this message]
2025-04-15 3:19 ` Chen Yufeng
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=2025041025-cozy-pug-fa22@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=Thinh.Nguyen@synopsys.com \
--cc=bootc@bootc.net \
--cc=chenyufeng@iie.ac.cn \
--cc=linux-scsi@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox