From: Wei Liu <wei.liu@kernel.org>
To: "Michael Kelley (LINUX)" <mikelley@microsoft.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
KY Srinivasan <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-hardening@vger.kernel.org"
<linux-hardening@vger.kernel.org>
Subject: Re: [PATCH][next] Drivers: hv: vmbus: Use struct_size() helper in kmalloc()
Date: Thu, 3 Feb 2022 12:42:53 +0000 [thread overview]
Message-ID: <20220203124253.h33oehbhninoadca@liuwe-devbox-debian-v2> (raw)
In-Reply-To: <MWHPR21MB1593A23CA620CEE3557023F8D7219@MWHPR21MB1593.namprd21.prod.outlook.com>
On Thu, Jan 27, 2022 at 04:01:28PM +0000, Michael Kelley (LINUX) wrote:
> From: Gustavo A. R. Silva <gustavoars@kernel.org> Sent: Tuesday, January 25, 2022 10:02 AM
> >
> > Make use of the struct_size() helper instead of an open-coded version,
> > in order to avoid any potential type mistakes or integer overflows that,
> > in the worst scenario, could lead to heap overflows.
> >
> > Also, address the following sparse warnings:
> > drivers/hv/vmbus_drv.c:1132:31: warning: using sizeof on a flexible structure
> >
> > Link: https://github.com/KSPP/linux/issues/174
> > ---
> > drivers/hv/vmbus_drv.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index 17bf55fe3169..cd193456cd84 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -1129,7 +1129,7 @@ void vmbus_on_msg_dpc(unsigned long data)
> > }
> >
> > if (entry->handler_type == VMHT_BLOCKING) {
> > - ctx = kmalloc(sizeof(*ctx) + payload_size, GFP_ATOMIC);
> > + ctx = kmalloc(struct_size(ctx, msg.payload, payload_size), GFP_ATOMIC);
> > if (ctx == NULL)
> > return;
> >
> > --
> > 2.27.0
>
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
>
Applied to hyperv-next. Thanks.
prev parent reply other threads:[~2022-02-03 12:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 18:01 [PATCH][next] Drivers: hv: vmbus: Use struct_size() helper in kmalloc() Gustavo A. R. Silva
2022-01-27 16:01 ` Michael Kelley (LINUX)
2022-02-03 12:42 ` Wei Liu [this message]
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=20220203124253.h33oehbhninoadca@liuwe-devbox-debian-v2 \
--to=wei.liu@kernel.org \
--cc=decui@microsoft.com \
--cc=gustavoars@kernel.org \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=sthemmin@microsoft.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;
as well as URLs for NNTP newsgroup(s).