mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qian Cai <quic_qiancai@quicinc.com>
To: Kees Cook <keescook@chromium.org>
Cc: <linux-hardening@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fortify: Avoid shadowing previous locals
Date: Mon, 25 Oct 2021 16:15:28 -0400	[thread overview]
Message-ID: <cd68c514-544d-c29f-d435-78e31f6a173c@quicinc.com> (raw)
In-Reply-To: <202110251232.652ACB6@keescook>



On 10/25/21 3:34 PM, Kees Cook wrote:
> On Mon, Oct 25, 2021 at 02:37:28PM -0400, Qian Cai wrote:
>> __compiletime_strlen macro expansion will shadow p_size and p_len local
>> variables. Just rename those in __compiletime_strlen.
> 
> They don't escape their local context, though, right? i.e. I don't see a
> problem with the existing macro. Did you encounter a specific issue that
> this patch fixes?

Yes, this is pretty minor. There are also some extra compiling warnings (W=2)
from it.

./include/linux/fortify-string.h: In function 'strnlen':

./include/linux/fortify-string.h:17:9: warning: declaration of 'p_size' shadows a previous local [-Wshadow]

   17 |  size_t p_size = __builtin_object_size(p, 1); \

      |         ^~~~~~

./include/linux/fortify-string.h:77:17: note: in expansion of macro '__compiletime_strlen'
   77 |  size_t p_len = __compiletime_strlen(p);

      |                 ^~~~~~~~~~~~~~~~~~~~

./include/linux/fortify-string.h:76:9: note: shadowed declaration is here

   76 |  size_t p_size = __builtin_object_size(p, 1);

      |         ^~~~~~

./include/linux/fortify-string.h:19:10: warning: declaration of 'p_len' shadows a previous local [-Wshadow]

   19 |   size_t p_len = p_size - 1;  \

      |          ^~~~~

./include/linux/fortify-string.h:77:17: note: in expansion of macro '__compiletime_strlen'
   77 |  size_t p_len = __compiletime_strlen(p);

      |                 ^~~~~~~~~~~~~~~~~~~~

./include/linux/fortify-string.h:77:9: note: shadowed declaration is here

   77 |  size_t p_len = __compiletime_strlen(p);

      |         ^~~~~

  reply	other threads:[~2021-10-25 20:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 18:37 Qian Cai
2021-10-25 19:34 ` Kees Cook
2021-10-25 20:15   ` Qian Cai [this message]
2021-10-25 20:49     ` Kees Cook

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=cd68c514-544d-c29f-d435-78e31f6a173c@quicinc.com \
    --to=quic_qiancai@quicinc.com \
    --cc=keescook@chromium.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 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®