Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx+linux-hardening@kernel.org>
To: Alejandro Colomar <alx@kernel.org>
Cc: sashiko-reviews@lists.linux.dev, linux-hardening@vger.kernel.org,
	 devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 09/19] string: Make strstarts() a legacy alias for strprefix()
Date: Sat, 14 Nov 2026 18:52:32 +0100	[thread overview]
Message-ID: <avifcIDnASrpmwJF@devuan> (raw)
In-Reply-To: <aviDEUMYSy19Ce2P@devuan>

[-- Attachment #1: Type: text/plain, Size: 2708 bytes --]

> Date: 2026-11-14 16:51:58+0100
> From: Alejandro Colomar <alx@kernel.org>
>
> > Date: 2026-11-14 15:33:19+0000
> > From: sashiko-bot@kernel.org
> >
> > Thank you for your contribution! Sashiko AI review found 1 potential
> > issue to consider:
> > - [High] string: strstarts() macro expansion shadowed by local strprefix
> >   variable
> > --
> > 
> > commit e4b277f22320c7ff4dbc9e8cc88221ad43eb8ba6
> > Author: Alejandro Colomar <alx@kernel.org>
> > 
> > string: Make strstarts() a legacy alias for strprefix()
> > 
> > This commit replaces the inline strstarts() function with a macro alias for
> > strprefix().
> > 
> > > diff --git a/include/linux/string.h b/include/linux/string.h
> > > index 013c6169def05..0a466360dbb39 100644
> > > --- a/include/linux/string.h
> > > +++ b/include/linux/string.h
> > > @@ -609,6 +609,7 @@ static inline const char *strprefix(const char *s, const char *prefix)
> > >  	return strncmp(s, prefix, len) == 0 ? s + len : NULL;
> > >  }
> > >  #define strprefix(s, pfx)  const_cast(CQChar_of(s) *, strprefix(s, pfx))
> > > +#define strstarts(s, pfx)  strprefix(s, pfx)  // legacy alias
> > 
> > [Severity: High]
> > Does expanding strstarts() to strprefix() break the build when a caller has
> > a local variable named strprefix?
> > 
> > drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c:hp_populate_security_buffer() {
> > 	u16 *auth = authbuf;
> > 	char *strprefix = NULL;
> > 	int ret = 0;
> > 
> > 	if (strstarts(authentication, BEAM_PREFIX)) {
> >     ...
> > }
> > 
> > Because the strprefix() macro expands to a call to the inline function
> > strprefix() in the caller's scope, the local pointer variable strprefix
> > shadows the function identifier and breaks compilation when
> > CONFIG_HP_BIOSCFG is enabled.  A later patch in this series, commit
> > "platform/x86: hp-bioscfg: Rename local variable", renames that variable to
> > prefix and should be ordered before this commit to keep the series
> > bisectable.
> 
> This reivew is wrong.  A local variable cannot shadow a macro.  Also,
> a function-like macro is only expanded if it's followed by an opening
> parenthesis.  In the case of spmobj-attributes.c, the local variable
> doesn't have a parenthesis, and thus doesn't trigger expansion.

After looking at it a second time, while the report from sashiko is
wrong, the code is actually wrong, and reordering the commits would be
appropriate.  I'll reorder them in v7.

> 
> > 
> > -- 
> > Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794667407.git.alx@kernel.org?part=9
> 
> -- 
> <https://www.alejandro-colomar.es>



-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-11-14 17:52 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 15:21 [PATCH v6 00/19] Add strprefix() and fix a bug with it Alejandro Colomar
2026-11-14 15:21 ` [PATCH v6 01/19] string: Add streq() Alejandro Colomar
2026-11-14 15:22 ` [PATCH v6 02/19] string: Add strprefix() Alejandro Colomar
2026-11-14 15:28   ` Joe Perches
2026-11-14 17:03     ` Alejandro Colomar
2026-11-14 15:53   ` Joe Perches
2026-11-14 16:59     ` Alejandro Colomar
2026-11-14 18:24       ` Joe Perches
2026-11-14 15:22 ` [PATCH v6 03/19] string: Document corner-case misbehavior in str_has_prefix() for empty prefix Alejandro Colomar
2026-11-14 15:22 ` [PATCH v6 04/19] device property: Fix fwnode_name_eq() for empty node names Alejandro Colomar
2026-11-14 15:22 ` [PATCH v6 05/19] stddef: Add const_cast() Alejandro Colomar
2026-11-14 15:22 ` [PATCH v6 06/19] string: Add [C]QChar_of() and QVoid_of() Alejandro Colomar
2026-11-14 15:22 ` [PATCH v6 07/19] string: Make strprefix() const-qualifier-generic Alejandro Colomar
2026-11-14 15:22 ` [PATCH v6 08/19] perf map: Use bool for return type instead of int Alejandro Colomar
2026-11-14 15:22 ` [PATCH v6 09/19] string: Make strstarts() a legacy alias for strprefix() Alejandro Colomar
2026-11-14 15:33   ` sashiko-bot
2026-11-14 15:51     ` Alejandro Colomar
2026-11-14 17:52       ` Alejandro Colomar [this message]
2026-11-14 15:23 ` [PATCH v6 10/19] platform/x86: hp-bioscfg: Rename local variable Alejandro Colomar
2026-11-14 16:04   ` Joe Perches
2026-11-14 17:08     ` Alejandro Colomar
2026-11-14 15:23 ` [PATCH v6 11/19] treewide: s/strstarts/strprefix/g Alejandro Colomar
2026-11-14 15:23 ` [PATCH v6 12/19] string: Remove strstarts() Alejandro Colomar
2026-11-14 15:29   ` sashiko-bot
2026-11-14 15:45     ` Alejandro Colomar
2026-11-14 15:23 ` [PATCH v6 13/19] s390/test_unwind: Use bool for booleans Alejandro Colomar
2026-11-14 15:23 ` [PATCH v6 14/19] treewide: Replace boolean uses of str_has_prefix() by strprefix() Alejandro Colomar
2026-11-14 15:23 ` [PATCH v6 15/19] treewide: Replace some " Alejandro Colomar
2026-11-14 15:34   ` sashiko-bot
2026-11-14 15:47     ` Alejandro Colomar
2026-11-14 15:23 ` [PATCH v6 16/19] string: Add strsuffix() Alejandro Colomar
2026-11-14 15:24 ` [PATCH v6 17/19] string: Make strends() a legacy alias for strsuffix() Alejandro Colomar
2026-11-14 15:24 ` [PATCH v6 18/19] treewide: s/\<strends\>/strsuffix/g Alejandro Colomar
2026-11-14 15:24 ` [PATCH v6 19/19] string: Remove strends() Alejandro Colomar

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=avifcIDnASrpmwJF@devuan \
    --to=alx+linux-hardening@kernel.org \
    --cc=alx@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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