From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Joe Perches <joe@perches.com>, Kees Cook <keescook@chromium.org>
Cc: Johannes Berg <johannes.berg@intel.com>,
Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
Luca Coelho <luciano.coelho@intel.com>,
Intel Linux Wireless <linuxwifi@intel.com>,
Kalle Valo <kvalo@codeaurora.org>,
"David S. Miller" <davem@davemloft.net>,
linux-wireless <linux-wireless@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iwlwifi: d3: use struct_size() in kzalloc()
Date: Fri, 24 Aug 2018 06:58:05 -0500 [thread overview]
Message-ID: <f6818e31-d2da-82b4-b862-1ffb322f9365@embeddedor.com> (raw)
In-Reply-To: <d0ee04ea40bfc2aecd71b3ed1e1d388911b7d6cb.camel@perches.com>
Hi Joe,
On 8/23/18 11:33 PM, Joe Perches wrote:
> On Thu, 2018-08-23 at 20:03 -0700, Kees Cook wrote:
>> On Thu, Aug 23, 2018 at 6:15 PM, Gustavo A. R. Silva
>> <gustavo@embeddedor.com> wrote:
>>> One of the more common cases of allocation size calculations is finding
>>> the size of a structure that has a zero-sized array at the end, along
>>> with memory for some number of elements for that array. For example:
>>>
>>> struct foo {
>>> int stuff;
>>> void *entry[];
>>> };
>
> Question for Gustavo.
>
> Did you find any existing instances that are miscalculated?
>
I found the following bug:
https://lore.kernel.org/patchwork/patch/977357/
> I believe there are some cases like:
>
> size = sizeof(struct foo) + count * sizeof(something);
> ptr = kmalloc(size);
> memset(ptr + sizeof(struct foo), 0, size - sizeof(struct foo));
>
> where something could go wrong and not be detected.
>
It might be worth it to write a Coccinelle script for this.
--
Gustavo
next prev parent reply other threads:[~2018-08-24 11:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-24 1:15 Gustavo A. R. Silva
2018-08-24 3:03 ` Kees Cook
2018-08-24 4:33 ` Joe Perches
2018-08-24 11:58 ` Gustavo A. R. Silva [this message]
2018-09-04 6:26 ` Luciano Coelho
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=f6818e31-d2da-82b4-b862-1ffb322f9365@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=davem@davemloft.net \
--cc=emmanuel.grumbach@intel.com \
--cc=joe@perches.com \
--cc=johannes.berg@intel.com \
--cc=keescook@chromium.org \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linuxwifi@intel.com \
--cc=luciano.coelho@intel.com \
--cc=netdev@vger.kernel.org \
/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®