All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andy Shevchenko <andy@kernel.org>,
	linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] string: Add additional __realloc_size() annotations for "dup" helpers
Date: Thu, 2 May 2024 07:54:10 -0700	[thread overview]
Message-ID: <202405020745.725A922@keescook> (raw)
In-Reply-To: <CAHp75VetkKYhnOaoM880D+VTR96NscQfBGddgAwKz681Uk5ZJg@mail.gmail.com>

On Thu, May 02, 2024 at 12:45:33PM +0300, Andy Shevchenko wrote:
> On Thu, May 2, 2024 at 2:32 AM Kees Cook <keescook@chromium.org> wrote:
> >
> > Several other "dup"-style interfaces could use the __realloc_size()
> > attribute. (As a reminder to myself and others: "realloc" is used here
> > instead of "alloc" because the "alloc_size" attribute implies that the
> > memory contents are uninitialized. Since we're copying contents into the
> > resulting allocation, it must use "realloc_size" to avoid confusing the
> > compiler's optimization passes.)
> >
> > Add KUnit test coverage where possible. (KUnit still does not have the
> > ability to manipulate userspace memory.)
> 
> Makes sense to me,
> Reviewed-by: Andy Shevchenko <andy@kernel.org>
> 
> ...
> 
> > +               checker(len, kmemdup_array(test_phrases[idx], len, 1,   \
> > +                                          gfp), kfree(p));             \
> 
> Despite being longer, I would put gfp on the previous line for the
> sake of logical split (and additionally to be consistent with the
> below).
> 
> > +               checker(len, kmemdup(test_phrases[idx], len, gfp),      \
> > +                       kfree(p));                                      \

Oh good! This bothered me to no end too. I will adjust it. :) Thanks!

-Kees

-- 
Kees Cook

      reply	other threads:[~2024-05-02 14:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01 23:32 [PATCH] string: Add additional __realloc_size() annotations for "dup" helpers Kees Cook
2024-05-02  9:45 ` Andy Shevchenko
2024-05-02 14:54   ` Kees Cook [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=202405020745.725A922@keescook \
    --to=keescook@chromium.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.