Linux Hardening
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Kees Cook <keescook@chromium.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2][next] RDMA/core: Use size_{add,mul}() in calls to struct_size()
Date: Sun, 17 Sep 2023 19:58:26 -0600	[thread overview]
Message-ID: <93f70187-3992-ee22-843e-e3912d169875@embeddedor.com> (raw)
In-Reply-To: <20230918124120.GE103601@unreal>



On 9/18/23 06:41, Leon Romanovsky wrote:
> On Sun, Sep 17, 2023 at 01:59:26PM -0600, Gustavo A. R. Silva wrote:
>>
>>
>> On 9/18/23 04:49, Leon Romanovsky wrote:
>>> On Fri, Sep 15, 2023 at 12:06:21PM -0600, Gustavo A. R. Silva wrote:
>>>>
>>>>
>>>> On 9/14/23 21:29, Kees Cook wrote:
>>>>> On Mon, Sep 11, 2023 at 05:27:59PM -0600, Gustavo A. R. Silva wrote:
>>>>>> Harden calls to struct_size() with size_add() and size_mul().
>>>>>
>>>>> Specifically, make sure that open-coded arithmetic cannot cause an
>>>>> overflow/wraparound. (i.e. it will stay saturated at SIZE_MAX.)
>>>>
>>>> Yep; I have another patch where I explain this in similar terms.
>>>>
>>>> I'll send it, shortly.
>>>
>>> You missed other places with similar arithmetic.
>>> drivers/infiniband/core/device.c:       pdata_rcu = kzalloc(struct_size(pdata_rcu, pdata,
>>> drivers/infiniband/core/device.c-                                       rdma_end_port(device) + 1),
>>> drivers/infiniband/core/device.c-                           GFP_KERNEL);
>>>
>>> drivers/infiniband/core/sa_query.c:     sa_dev = kzalloc(struct_size(sa_dev, port, e - s + 1), GFP_KERNEL);
>>> drivers/infiniband/core/user_mad.c:     umad_dev = kzalloc(struct_size(umad_dev, ports, e - s + 1), GFP_KERNEL);
>>
>> I haven't sent all my patches.
> 
> Please sent one patch for whole drivers/infiniband/core/ folder as your
> title: "RDMA/core ..." suggests.

OK. Done:

https://lore.kernel.org/linux-hardening/ZQdt4NsJFwwOYxUR@work/

Thanks
--
Gustavo

      reply	other threads:[~2023-09-18 17:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 23:27 [PATCH v2][next] RDMA/core: Use size_{add,mul}() in calls to struct_size() Gustavo A. R. Silva
2023-09-15  3:29 ` Kees Cook
2023-09-15 18:06   ` Gustavo A. R. Silva
2023-09-18 10:49     ` Leon Romanovsky
2023-09-17 19:59       ` Gustavo A. R. Silva
2023-09-18 12:41         ` Leon Romanovsky
2023-09-18  1:58           ` Gustavo A. R. Silva [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=93f70187-3992-ee22-843e-e3912d169875@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=keescook@chromium.org \
    --cc=leon@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@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