[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251211175101.GA3405942@google.com>
Date: Thu, 11 Dec 2025 17:51:01 +0000
From: Sami Tolvanen <samitolvanen@...gle.com>
To: Daniel Gomez <da.gomez@...nel.org>
Cc: Dan Carpenter <dan.carpenter@...aro.org>,
"Luck, Tony" <tony.luck@...el.com>, Chris Li <sparse@...isli.org>,
Eric Biggers <ebiggers@...nel.org>, Kees Cook <kees@...nel.org>,
Luis Chamberlain <mcgrof@...nel.org>,
Rusty Russell <rusty@...tcorp.com.au>,
Petr Pavlu <petr.pavlu@...e.com>,
"linux-modules@...r.kernel.org" <linux-modules@...r.kernel.org>,
Malcolm Priestley <tvboxspy@...il.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Hans Verkuil <hverkuil@...nel.org>,
Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-media@...r.kernel.org" <linux-media@...r.kernel.org>,
"linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>
Subject: Re: [PATCH 3/3] module: Add compile-time check for embedded NUL
characters
On Fri, Dec 12, 2025 at 02:30:48AM +0900, Daniel Gomez wrote:
>
>
> On 12/12/2025 02.03, Sami Tolvanen wrote:
> > On Thu, Dec 11, 2025 at 12:28 AM Dan Carpenter <dan.carpenter@...aro.org> wrote:
> >>
> >> On Wed, Dec 10, 2025 at 02:29:45PM -0800, Luck, Tony wrote:
> >>>> diff --git a/expand.c b/expand.c
> >>>> index f14e7181..71221d35 100644
> >>>> --- a/expand.c
> >>>> +++ b/expand.c
> >>>> @@ -535,6 +535,8 @@ static int expand_compare(struct expression *expr)
> >>>> expr->taint = 0;
> >>>> return 0;
> >>>> }
> >>>> + if (left->flags & CEF_ICE && right->flags & CEF_ICE)
> >>>> + expr->flags |= CEF_SET_ICE;
> >>>> if (simplify_cmp_binop(expr, left->ctype))
> >>>> return 0;
> >>>> if (simplify_float_cmp(expr, left->ctype))
> >>
> >> I'm not an expert in the C standard, but this feels correct to me.
> >
> > It only fixes comparisons though, the problem still exists for other
> > expressions. For example, while `_Static_assert(__builtin_strlen("")
> > == 0);` works with this change,
> > `_Static_assert(!__builtin_strlen(""));` still fails. Perhaps there's
> > a better way to fix this than changing each expression expansion
> > function to handle this flag?
>
> Maybe the flag fix just needs to be applied to the evaluation? Other op
> structs do the same. But Dan's patch did not implement evaluate. E.g.:
>
> static struct symbol_op constant_p_op = {
> .evaluate = evaluate_to_int_const_expr,
> .expand = expand_constant_p
> };
Nice catch! This seems to fix the issue for me:
diff --git a/builtin.c b/builtin.c
index 9149c43d..7573abf8 100644
--- a/builtin.c
+++ b/builtin.c
@@ -616,6 +616,7 @@ static int expand_strlen(struct expression *expr, int cost)
}
static struct symbol_op strlen_op = {
+ .evaluate = evaluate_to_int_const_expr,
.expand = expand_strlen,
};
I wonder if there are any other __builtin_* functions that need this too?
Looks like __builtin_object_size doesn't have this either.
Sami
Powered by blists - more mailing lists