Devicetree
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: sashiko-reviews@lists.linux.dev, linux-hardening@vger.kernel.org
Cc: devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
	 robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 15/19] treewide: Replace some uses of str_has_prefix() by strprefix()
Date: Sat, 14 Nov 2026 16:47:58 +0100	[thread overview]
Message-ID: <aviCffxC8LvSWW87@devuan> (raw)
In-Reply-To: <sashiko-outbox-214722@kernel.org>

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

> Date: 2026-11-14 15:34:40+0000
> From: sashiko-bot@kernel.org
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [High] tracing: NULL pointer dereference in trace_set_options()
> --
> 
> commit c09c1b839b46a18b156e43281c4fb679a76cfe40
> Author: Alejandro Colomar <alx@kernel.org>
> 
> treewide: Replace some uses of str_has_prefix() by strprefix()
> 
> This commit replaces several callers of str_has_prefix() across the tree
> with strprefix() to avoid manual pointer arithmetic.
> 
> > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> > index 4ccdefb5c3efe..f9f3faaede094 100644
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -4085,19 +4085,18 @@ int set_tracer_flag(struct trace_array *tr, u64 mask, int enabled)
> >  
> >  int trace_set_options(struct trace_array *tr, char *option)
> >  {
> > -	char *cmp;
> > +	char *cmp, *p;
> >  	int neg = 0;
> >  	int ret;
> >  	size_t orig_len = strlen(option);
> > -	int len;
> >  
> >  	cmp = strstrip(option);
> >  
> > -	len = str_has_prefix(cmp, "no");
> > -	if (len)
> > +	p = strprefix(cmp, "no");
> > +	if (p)
> >  		neg = 1;
> >  
> > -	cmp += len;
> > +	cmp = p;

Ouch!  I meant to write 'cmp = p ?: cmp;'.

Will fix for v7.

> 
> [Severity: High]
> Does this set cmp to NULL when the option does not start with "no"?
> strprefix() returns NULL on a non-match, and "cmp = p;" runs outside the
> "if (p)" check, causing a NULL pointer dereference when cmp is passed to
> match_string() right below.
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794667407.git.alx@kernel.org?part=15

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

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

  reply	other threads:[~2026-11-14 15:48 UTC|newest]

Thread overview: 29+ 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 15:53   ` 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 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 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 [this message]
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=aviCffxC8LvSWW87@devuan \
    --to=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