From: Joe Perches <joe@perches.com>
To: Kees Cook <keescook@chromium.org>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>
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: Thu, 23 Aug 2018 21:33:19 -0700 [thread overview]
Message-ID: <d0ee04ea40bfc2aecd71b3ed1e1d388911b7d6cb.camel@perches.com> (raw)
In-Reply-To: <CAGXu5jJxbFzKsV1=xHiKtcx+61QBsK0LYMrwo1vGNWgALzqakw@mail.gmail.com>
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 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.
next prev parent reply other threads:[~2018-08-24 4:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-24 1:15 [PATCH] iwlwifi: d3: use struct_size() in kzalloc() Gustavo A. R. Silva
2018-08-24 3:03 ` Kees Cook
2018-08-24 4:33 ` Joe Perches [this message]
2018-08-24 11:58 ` Gustavo A. R. Silva
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=d0ee04ea40bfc2aecd71b3ed1e1d388911b7d6cb.camel@perches.com \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=emmanuel.grumbach@intel.com \
--cc=gustavo@embeddedor.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;
as well as URLs for NNTP newsgroup(s).