* [PATCH] builtin: mark __builtin_strlen() as integer constant expression
@ 2026-02-19 16:10 Daniel Gomez
2026-02-19 16:41 ` Sami Tolvanen
2026-02-19 16:53 ` Daniel Gomez
0 siblings, 2 replies; 10+ messages in thread
From: Daniel Gomez @ 2026-02-19 16:10 UTC (permalink / raw)
To: Chris Li, linux-sparse
Cc: Aaron Tomlin, Andy Shevchenko, Dan Carpenter, Daniel Gomez,
Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules,
Luck, Tony, Luis Chamberlain, Petr Pavlu, Sami Tolvanen,
Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
Commit ae83f3b72621 ("module: Add compile-time check for embedded
NUL characters") in the Linux kernel added static assert checks for
__builtin_strlen() inside MODULE_INFO() macros. But sparse does not mark
the result as CEF_SET_ICE during evaluation, making these assertions
fail with:
error: static assertion failed: "MODULE_INFO(...) contains embedded
NUL byte"
Fix by marking __builtin_strlen() as an integer constant expression at
eval time. This matches other builtins like __builtin_constant_p() or
__builtin_safe_p().
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
Discussion:
https://lore.kernel.org/all/aTc9s210am0YqMV4@agluck-desk3/
---
builtin.c | 1 +
1 file changed, 1 insertion(+)
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,
};
---
base-commit: fbdde3127b83e6d09e0ba808d7925dd84407f3c6
change-id: 20260219-fix-builtin-strlen-08eb3a02609b
Best regards,
--
Daniel Gomez <da.gomez@samsung.com>
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] builtin: mark __builtin_strlen() as integer constant expression 2026-02-19 16:10 [PATCH] builtin: mark __builtin_strlen() as integer constant expression Daniel Gomez @ 2026-02-19 16:41 ` Sami Tolvanen 2026-02-19 17:00 ` Daniel Gomez 2026-02-19 16:53 ` Daniel Gomez 1 sibling, 1 reply; 10+ messages in thread From: Sami Tolvanen @ 2026-02-19 16:41 UTC (permalink / raw) To: Daniel Gomez Cc: Chris Li, linux-sparse, Aaron Tomlin, Andy Shevchenko, Dan Carpenter, Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules, Luck, Tony, Luis Chamberlain, Petr Pavlu, Daniel Gomez Hi Daniel, On Thu, Feb 19, 2026 at 8:11 AM Daniel Gomez <da.gomez@kernel.org> wrote: > > From: Daniel Gomez <da.gomez@samsung.com> > > Commit ae83f3b72621 ("module: Add compile-time check for embedded > NUL characters") in the Linux kernel added static assert checks for > __builtin_strlen() inside MODULE_INFO() macros. But sparse does not mark > the result as CEF_SET_ICE during evaluation, making these assertions > fail with: > > error: static assertion failed: "MODULE_INFO(...) contains embedded > NUL byte" > > Fix by marking __builtin_strlen() as an integer constant expression at > eval time. This matches other builtins like __builtin_constant_p() or > __builtin_safe_p(). > > Signed-off-by: Daniel Gomez <da.gomez@samsung.com> > --- > Discussion: > https://lore.kernel.org/all/aTc9s210am0YqMV4@agluck-desk3/ It looks like Al had a more complete fix for this issue, but I guess it never ended up in the sparse repo? https://lore.kernel.org/all/aUV7kyjxlijuy5sC@agluck-desk3/ Sami ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] builtin: mark __builtin_strlen() as integer constant expression 2026-02-19 16:41 ` Sami Tolvanen @ 2026-02-19 17:00 ` Daniel Gomez 2026-02-19 17:06 ` Chris Li 0 siblings, 1 reply; 10+ messages in thread From: Daniel Gomez @ 2026-02-19 17:00 UTC (permalink / raw) To: Chris Li, Al Viro, Sami Tolvanen Cc: linux-sparse, Aaron Tomlin, Andy Shevchenko, Dan Carpenter, Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules, Luck, Tony, Luis Chamberlain, Petr Pavlu, Al Viro On 2026-02-19 08:41, Sami Tolvanen wrote: > Hi Daniel, > > On Thu, Feb 19, 2026 at 8:11 AM Daniel Gomez <da.gomez@kernel.org> wrote: > > > > From: Daniel Gomez <da.gomez@samsung.com> > > > > Commit ae83f3b72621 ("module: Add compile-time check for embedded > > NUL characters") in the Linux kernel added static assert checks for > > __builtin_strlen() inside MODULE_INFO() macros. But sparse does not mark > > the result as CEF_SET_ICE during evaluation, making these assertions > > fail with: > > > > error: static assertion failed: "MODULE_INFO(...) contains embedded > > NUL byte" > > > > Fix by marking __builtin_strlen() as an integer constant expression at > > eval time. This matches other builtins like __builtin_constant_p() or > > __builtin_safe_p(). > > > > Signed-off-by: Daniel Gomez <da.gomez@samsung.com> > > --- > > Discussion: > > https://lore.kernel.org/all/aTc9s210am0YqMV4@agluck-desk3/ > > It looks like Al had a more complete fix for this issue, but I guess > it never ended up in the sparse repo? > > https://lore.kernel.org/all/aUV7kyjxlijuy5sC@agluck-desk3/ > > Sami Chris, Al, Can you please take a look? If Al patch is the correct approach, any chance you can send it and fix this? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] builtin: mark __builtin_strlen() as integer constant expression 2026-02-19 17:00 ` Daniel Gomez @ 2026-02-19 17:06 ` Chris Li 2026-02-19 19:20 ` Andy Shevchenko 0 siblings, 1 reply; 10+ messages in thread From: Chris Li @ 2026-02-19 17:06 UTC (permalink / raw) To: Daniel Gomez Cc: Al Viro, Sami Tolvanen, linux-sparse, Aaron Tomlin, Andy Shevchenko, Dan Carpenter, Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules, Luck, Tony, Luis Chamberlain, Petr Pavlu On Thu, Feb 19, 2026 at 9:00 AM Daniel Gomez <da.gomez@kernel.org> wrote: > > Chris, Al, > > Can you please take a look? If Al patch is the correct approach, any > chance you can send it and fix this? I am asking in another thread should I pull Al's git repo instead. There are a few good commits there. Chris ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] builtin: mark __builtin_strlen() as integer constant expression 2026-02-19 17:06 ` Chris Li @ 2026-02-19 19:20 ` Andy Shevchenko 2026-02-20 8:06 ` Chris Li 0 siblings, 1 reply; 10+ messages in thread From: Andy Shevchenko @ 2026-02-19 19:20 UTC (permalink / raw) To: Chris Li Cc: Daniel Gomez, Al Viro, Sami Tolvanen, linux-sparse, Aaron Tomlin, Dan Carpenter, Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules, Luck, Tony, Luis Chamberlain, Petr Pavlu On Thu, Feb 19, 2026 at 09:06:23AM -0800, Chris Li wrote: > On Thu, Feb 19, 2026 at 9:00 AM Daniel Gomez <da.gomez@kernel.org> wrote: > > > > Can you please take a look? If Al patch is the correct approach, any > > chance you can send it and fix this? > > I am asking in another thread should I pull Al's git repo instead. > There are a few good commits there. Please, pull Al's work, My colleagues and I use his version of sparse for a few weeks without noticing any downsides. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] builtin: mark __builtin_strlen() as integer constant expression 2026-02-19 19:20 ` Andy Shevchenko @ 2026-02-20 8:06 ` Chris Li 2026-02-20 8:30 ` Andy Shevchenko 0 siblings, 1 reply; 10+ messages in thread From: Chris Li @ 2026-02-20 8:06 UTC (permalink / raw) To: Andy Shevchenko Cc: Daniel Gomez, Al Viro, Sami Tolvanen, linux-sparse, Aaron Tomlin, Dan Carpenter, Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules, Luck, Tony, Luis Chamberlain, Petr Pavlu On Thu, Feb 19, 2026 at 11:20 AM Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > > On Thu, Feb 19, 2026 at 09:06:23AM -0800, Chris Li wrote: > > On Thu, Feb 19, 2026 at 9:00 AM Daniel Gomez <da.gomez@kernel.org> wrote: > > > > > > Can you please take a look? If Al patch is the correct approach, any > > > chance you can send it and fix this? > > > > I am asking in another thread should I pull Al's git repo instead. > > There are a few good commits there. > > Please, pull Al's work, My colleagues and I use his version of sparse for a few > weeks without noticing any downsides. Thanks for the heads up. I just pulled Al's sparse repo. Sorry for the delay. Chris ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] builtin: mark __builtin_strlen() as integer constant expression 2026-02-20 8:06 ` Chris Li @ 2026-02-20 8:30 ` Andy Shevchenko 2026-02-20 19:34 ` Chris Li 0 siblings, 1 reply; 10+ messages in thread From: Andy Shevchenko @ 2026-02-20 8:30 UTC (permalink / raw) To: Chris Li Cc: Daniel Gomez, Al Viro, Sami Tolvanen, linux-sparse, Aaron Tomlin, Dan Carpenter, Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules, Luck, Tony, Luis Chamberlain, Petr Pavlu On Fri, Feb 20, 2026 at 12:06:15AM -0800, Chris Li wrote: > On Thu, Feb 19, 2026 at 11:20 AM Andy Shevchenko > <andriy.shevchenko@intel.com> wrote: > > > > On Thu, Feb 19, 2026 at 09:06:23AM -0800, Chris Li wrote: > > > On Thu, Feb 19, 2026 at 9:00 AM Daniel Gomez <da.gomez@kernel.org> wrote: > > > > > > > > Can you please take a look? If Al patch is the correct approach, any > > > > chance you can send it and fix this? > > > > > > I am asking in another thread should I pull Al's git repo instead. > > > There are a few good commits there. > > > > Please, pull Al's work, My colleagues and I use his version of sparse for a few > > weeks without noticing any downsides. > > Thanks for the heads up. I just pulled Al's sparse repo. Can you also issue a new tag (say 0.6.5) so the distros can really be pushed to update the quite outdated sparse in their repos? > Sorry for the delay. Thanks! -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] builtin: mark __builtin_strlen() as integer constant expression 2026-02-20 8:30 ` Andy Shevchenko @ 2026-02-20 19:34 ` Chris Li 2026-02-24 10:26 ` Andy Shevchenko 0 siblings, 1 reply; 10+ messages in thread From: Chris Li @ 2026-02-20 19:34 UTC (permalink / raw) To: Andy Shevchenko Cc: Daniel Gomez, Al Viro, Sami Tolvanen, linux-sparse, Aaron Tomlin, Dan Carpenter, Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules, Luck, Tony, Luis Chamberlain, Petr Pavlu On Fri, Feb 20, 2026 at 12:31 AM Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > > On Fri, Feb 20, 2026 at 12:06:15AM -0800, Chris Li wrote: > > On Thu, Feb 19, 2026 at 11:20 AM Andy Shevchenko > > <andriy.shevchenko@intel.com> wrote: > > > > > > On Thu, Feb 19, 2026 at 09:06:23AM -0800, Chris Li wrote: > > > > On Thu, Feb 19, 2026 at 9:00 AM Daniel Gomez <da.gomez@kernel.org> wrote: > > > > > > > > > > Can you please take a look? If Al patch is the correct approach, any > > > > > chance you can send it and fix this? > > > > > > > > I am asking in another thread should I pull Al's git repo instead. > > > > There are a few good commits there. > > > > > > Please, pull Al's work, My colleagues and I use his version of sparse for a few > > > weeks without noticing any downsides. > > > > Thanks for the heads up. I just pulled Al's sparse repo. > > Can you also issue a new tag (say 0.6.5) so the distros can really be pushed to > update the quite outdated sparse in their repos? Sure. I can give it a spin this weekend and keep you posted. There is one risk on my signing key, it might be expired and I need to sort that out. Meanwhile, please give the current sparse repo some good tests. Chris ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] builtin: mark __builtin_strlen() as integer constant expression 2026-02-20 19:34 ` Chris Li @ 2026-02-24 10:26 ` Andy Shevchenko 0 siblings, 0 replies; 10+ messages in thread From: Andy Shevchenko @ 2026-02-24 10:26 UTC (permalink / raw) To: Chris Li Cc: Daniel Gomez, Al Viro, Sami Tolvanen, linux-sparse, Aaron Tomlin, Dan Carpenter, Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules, Luck, Tony, Luis Chamberlain, Petr Pavlu On Fri, Feb 20, 2026 at 11:34:29AM -0800, Chris Li wrote: > On Fri, Feb 20, 2026 at 12:31 AM Andy Shevchenko > <andriy.shevchenko@intel.com> wrote: > > On Fri, Feb 20, 2026 at 12:06:15AM -0800, Chris Li wrote: > > > On Thu, Feb 19, 2026 at 11:20 AM Andy Shevchenko > > > <andriy.shevchenko@intel.com> wrote: > > > > On Thu, Feb 19, 2026 at 09:06:23AM -0800, Chris Li wrote: > > > > > On Thu, Feb 19, 2026 at 9:00 AM Daniel Gomez <da.gomez@kernel.org> wrote: > > > > > > > > > > > > Can you please take a look? If Al patch is the correct approach, any > > > > > > chance you can send it and fix this? > > > > > > > > > > I am asking in another thread should I pull Al's git repo instead. > > > > > There are a few good commits there. > > > > > > > > Please, pull Al's work, My colleagues and I use his version of sparse for a few > > > > weeks without noticing any downsides. > > > > > > Thanks for the heads up. I just pulled Al's sparse repo. > > > > Can you also issue a new tag (say 0.6.5) so the distros can really be pushed to > > update the quite outdated sparse in their repos? > > Sure. I can give it a spin this weekend and keep you posted. There is > one risk on my signing key, it might be expired and I need to sort > that out. > > Meanwhile, please give the current sparse repo some good tests. It seems that your tip is the same as Al's, and if it's the case we are testing (actually using) this for a few weeks without problems. Thanks! -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] builtin: mark __builtin_strlen() as integer constant expression 2026-02-19 16:10 [PATCH] builtin: mark __builtin_strlen() as integer constant expression Daniel Gomez 2026-02-19 16:41 ` Sami Tolvanen @ 2026-02-19 16:53 ` Daniel Gomez 1 sibling, 0 replies; 10+ messages in thread From: Daniel Gomez @ 2026-02-19 16:53 UTC (permalink / raw) To: Chris Li, linux-sparse Cc: Aaron Tomlin, Andy Shevchenko, Dan Carpenter, Dmitry Torokhov, Eric Biggers, linux-kernel, linux-modules, Luck, Tony, Luis Chamberlain, Petr Pavlu, Sami Tolvanen On 2026-02-19 17:10, Daniel Gomez wrote: > From: Daniel Gomez <da.gomez@samsung.com> > > Commit ae83f3b72621 ("module: Add compile-time check for embedded > NUL characters") in the Linux kernel added static assert checks for > __builtin_strlen() inside MODULE_INFO() macros. But sparse does not mark > the result as CEF_SET_ICE during evaluation, making these assertions > fail with: > > error: static assertion failed: "MODULE_INFO(...) contains embedded > NUL byte" > > Fix by marking __builtin_strlen() as an integer constant expression at > eval time. This matches other builtins like __builtin_constant_p() or > __builtin_safe_p(). > > Signed-off-by: Daniel Gomez <da.gomez@samsung.com> Reported-by: kernel test robot <lkp@intel.com> Reported-by: "Luck, Tony" <tony.luck@intel.com> Reported-by: Eric Biggers <ebiggers@kernel.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-02-24 10:26 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-02-19 16:10 [PATCH] builtin: mark __builtin_strlen() as integer constant expression Daniel Gomez 2026-02-19 16:41 ` Sami Tolvanen 2026-02-19 17:00 ` Daniel Gomez 2026-02-19 17:06 ` Chris Li 2026-02-19 19:20 ` Andy Shevchenko 2026-02-20 8:06 ` Chris Li 2026-02-20 8:30 ` Andy Shevchenko 2026-02-20 19:34 ` Chris Li 2026-02-24 10:26 ` Andy Shevchenko 2026-02-19 16:53 ` Daniel Gomez
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox