Skip to contentSkip to conversation

module: Add compile-time check for embedded NUL characters

PATCH Applied Kees Cook 13 participants 38 messages Oct 10, 2025 – Jan 16 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

v2 cover module: Add compile-time check for embedded NUL characters

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Hi!

A long time ago we had an issue with embedded NUL bytes in MODULE_INFO strings[1]. While this stands out pretty strongly when you look at the code, and we can't do anything about a binary module that just plain lies, we never actually implemented the trivial compile-time check needed to detect it.

Add this check (and fix 2 instances of needless trailing semicolons that this change exposed).

Note that these patches were produced as part of another LLM exercise. This time I wanted to try "what happens if I ask an LLM to go read a specific LWN article and write a patch based on a discussion?" It pretty effortlessly chose and implemented a suggested solution, tested the change, and fixed new build warnings in the process.

Since this was a relatively short session, here's an overview of the prompts involved as I guided it through a clean change and tried to see how it would reason about static_assert vs _Static_assert. (It wanted to use what was most common, not what was the current style -- we may want to update the comment above the static_assert macro to suggest using _Static_assert directly these days...)

I want to fix a weakness in the module info strings. Read about it
here: https://lwn.net/Articles/82305/

Since it's only "info" that we need to check, can you reduce the checks to just that instead of all the other stuff?

I think the change to the comment is redundent, and that should be in a commit log instead. Let's just keep the change to the static assert.

Is "static_assert" the idiomatic way to use a static assert in this code base? I've seen _Static_assert used sometimes.

What's the difference between the two?

Does Linux use C11 by default now?

Then let's not use the wrapper any more.

Do an "allmodconfig all -s" build to verify this works for all modules in the kernel.

Thanks!

-Kees

[1] https://lwn.net/Articles/82305/

Kees Cook (3):
media: dvb-usb-v2: lmedm04: Fix firmware macro definitions
media: radio: si470x: Fix DRIVER_AUTHOR macro definition
module: Add compile-time check for embedded NUL characters

 include/linux/moduleparam.h                   |  3 +++
 drivers/media/radio/si470x/radio-si470x-i2c.c |  2 +-
 drivers/media/usb/dvb-usb-v2/lmedm04.c        | 12 ++++++------
 3 files changed, 10 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/3 media: dvb-usb-v2: lmedm04: Fix firmware macro definitions

The firmware filename macros incorrectly included semicolons in their string literal definitions. Right now, this wasn't causing any real problem, but coming changes to the MODULE_INFO() macro make this more sensitive. Specifically, when used with MODULE_FIRMWARE(), this created syntax errors during macro expansion:

    MODULE_FIRMWARE(LME2510_C_S7395);

expands to:

    MODULE_INFO(firmware, "dvb-usb-lme2510c-s7395.fw";)
                                                     ^
                                          syntax error

Remove the trailing semicolons from all six firmware filename macro definitions. Semicolons should only appear at the point of use, not in the macro definition.

---
Cc: Malcolm Priestley <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: <[email protected]>

---
 drivers/media/usb/dvb-usb-v2/lmedm04.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/usb/dvb-usb-v2/lmedm04.c +6 -6
index 0c510035805b..05c18b6de5c6 100644
@@ -70,12 +70,12 @@
 #include "ts2020.h"
 
 
-#define LME2510_C_S7395	"dvb-usb-lme2510c-s7395.fw";
-#define LME2510_C_LG	"dvb-usb-lme2510c-lg.fw";
-#define LME2510_C_S0194	"dvb-usb-lme2510c-s0194.fw";
-#define LME2510_C_RS2000 "dvb-usb-lme2510c-rs2000.fw";
-#define LME2510_LG	"dvb-usb-lme2510-lg.fw";
-#define LME2510_S0194	"dvb-usb-lme2510-s0194.fw";
+#define LME2510_C_S7395	"dvb-usb-lme2510c-s7395.fw"
+#define LME2510_C_LG	"dvb-usb-lme2510c-lg.fw"
+#define LME2510_C_S0194	"dvb-usb-lme2510c-s0194.fw"
+#define LME2510_C_RS2000 "dvb-usb-lme2510c-rs2000.fw"
+#define LME2510_LG	"dvb-usb-lme2510-lg.fw"
+#define LME2510_S0194	"dvb-usb-lme2510-s0194.fw"
 
 /* debug */
 static int dvb_usb_lme2510_debug;
Signature · 1 line
2.34.1
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] media: dvb-usb-v2: lmedm04: Fix firmware macro definitions

Em Thu, 9 Oct 2025 20:06:07 -0700
Kees Cook <[email protected]> escreveu:

Quoted 14 lines

The firmware filename macros incorrectly included semicolons in their string literal definitions. Right now, this wasn't causing any real problem, but coming changes to the MODULE_INFO() macro make this more sensitive. Specifically, when used with MODULE_FIRMWARE(), this created syntax errors during macro expansion:

    MODULE_FIRMWARE(LME2510_C_S7395);

expands to:

    MODULE_INFO(firmware, "dvb-usb-lme2510c-s7395.fw";)
                                                     ^
                                          syntax error
Quoted 6 lines

Remove the trailing semicolons from all six firmware filename macro definitions. Semicolons should only appear at the point of use, not in the macro definition.

LGTM.

Quoted 31 lines

---
Cc: Malcolm Priestley <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: <[email protected]>

---
 drivers/media/usb/dvb-usb-v2/lmedm04.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/usb/dvb-usb-v2/lmedm04.c +6 -6
index 0c510035805b..05c18b6de5c6 100644
@@ -70,12 +70,12 @@
 #include "ts2020.h"
 
 
-#define LME2510_C_S7395	"dvb-usb-lme2510c-s7395.fw";
-#define LME2510_C_LG	"dvb-usb-lme2510c-lg.fw";
-#define LME2510_C_S0194	"dvb-usb-lme2510c-s0194.fw";
-#define LME2510_C_RS2000 "dvb-usb-lme2510c-rs2000.fw";
-#define LME2510_LG	"dvb-usb-lme2510-lg.fw";
-#define LME2510_S0194	"dvb-usb-lme2510-s0194.fw";
+#define LME2510_C_S7395	"dvb-usb-lme2510c-s7395.fw"
+#define LME2510_C_LG	"dvb-usb-lme2510c-lg.fw"
+#define LME2510_C_S0194	"dvb-usb-lme2510c-s0194.fw"
+#define LME2510_C_RS2000 "dvb-usb-lme2510c-rs2000.fw"
+#define LME2510_LG	"dvb-usb-lme2510-lg.fw"
+#define LME2510_S0194	"dvb-usb-lme2510-s0194.fw"
 
 /* debug */
 static int dvb_usb_lme2510_debug;
author
#3 lore raw

PATCH v2 2/3 media: radio: si470x: Fix DRIVER_AUTHOR macro definition

In reply to Kees Cook

The DRIVER_AUTHOR macro incorrectly included a semicolon in its string literal definition. Right now, this wasn't causing any real problem, but coming changes to the MODULE_INFO() macro make this more sensitive. Specifically, when used with MODULE_AUTHOR(), this created syntax errors during macro expansion:

    MODULE_AUTHOR(DRIVER_AUTHOR);

expands to:

MODULE_INFO(author, "Joonyoung Shim <[email protected]>";)
^
syntax error

Remove the trailing semicolon from the DRIVER_AUTHOR definition. Semicolons should only appear at the point of use, not in the macro definition.

---
Cc: Hans Verkuil <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Uwe Kleine-König <[email protected]>
Cc: <[email protected]>

---
 drivers/media/radio/si470x/radio-si470x-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-i2c.c +1 -1
index cdd2ac198f2c..3932a449a1b1 100644
@@ -10,7 +10,7 @@
 
 
 /* driver definitions */
-#define DRIVER_AUTHOR "Joonyoung Shim <[email protected]>";
+#define DRIVER_AUTHOR "Joonyoung Shim <[email protected]>"
 #define DRIVER_CARD "Silicon Labs Si470x FM Radio"
 #define DRIVER_DESC "I2C radio driver for Si470x FM Radio Receivers"
 #define DRIVER_VERSION "1.0.2"
Signature · 1 line
2.34.1
Reviewed-by on v2 2/3
#4 lore raw

Re: [PATCH v2 2/3] media: radio: si470x: Fix DRIVER_AUTHOR macro definition

Em Thu, 9 Oct 2025 20:06:08 -0700
Kees Cook <[email protected]> escreveu:

Quoted 14 lines

The DRIVER_AUTHOR macro incorrectly included a semicolon in its string literal definition. Right now, this wasn't causing any real problem, but coming changes to the MODULE_INFO() macro make this more sensitive. Specifically, when used with MODULE_AUTHOR(), this created syntax errors during macro expansion:

    MODULE_AUTHOR(DRIVER_AUTHOR);

expands to:

MODULE_INFO(author, "Joonyoung Shim <[email protected]>";)
^
syntax error

Quoted 6 lines

Remove the trailing semicolon from the DRIVER_AUTHOR definition. Semicolons should only appear at the point of use, not in the macro definition.

LGTM.

Quoted 22 lines

---
Cc: Hans Verkuil <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Uwe Kleine-König <[email protected]>
Cc: <[email protected]>

---
 drivers/media/radio/si470x/radio-si470x-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-i2c.c +1 -1
index cdd2ac198f2c..3932a449a1b1 100644
@@ -10,7 +10,7 @@
 
 
 /* driver definitions */
-#define DRIVER_AUTHOR "Joonyoung Shim <[email protected]>";
+#define DRIVER_AUTHOR "Joonyoung Shim <[email protected]>"
 #define DRIVER_CARD "Silicon Labs Si470x FM Radio"
 #define DRIVER_DESC "I2C radio driver for Si470x FM Radio Receivers"
 #define DRIVER_VERSION "1.0.2"
author
#5 lore raw

PATCH v2 3/3 module: Add compile-time check for embedded NUL characters

In reply to Kees Cook

Long ago, the kernel module license checks were bypassed by embedding a NUL character in the MODULE_LICENSE() string[1]. By using a string like "GPL\0proprietary text", the kernel would only read "GPL" due to C string termination at the NUL byte, allowing proprietary modules to avoid kernel tainting and access GPL-only symbols.

The MODULE_INFO() macro stores these strings in the .modinfo ELF section, and get_next_modinfo() uses strcmp()-family functions which stop at the first NUL. This split the embedded string into two separate .modinfo entries, with only the first part being processed by license_is_gpl_compatible().

Add a compile-time check using static_assert that compares the full string length (sizeof - 1) against __builtin_strlen(), which stops at the first NUL. If they differ, compilation fails with a clear error message.

While this check can still be circumvented by modifying the ELF binary post-compilation, it prevents accidental embedded NULs and forces intentional abuse to require deliberate binary manipulation rather than simple source-level tricks.

Build tested with test modules containing both valid and invalid license strings. The check correctly rejects:

MODULE_LICENSE("GPL\0proprietary")

while accepting normal declarations:

MODULE_LICENSE("GPL")

---
Cc: Luis Chamberlain <[email protected]>
Cc: Petr Pavlu <[email protected]>
Cc: Daniel Gomez <[email protected]>
Cc: Sami Tolvanen <[email protected]>
Cc: <[email protected]>

---
 include/linux/moduleparam.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/moduleparam.h +3 -0
index 6907aedc4f74..915f32f7d888 100644
@@ -26,6 +26,9 @@
 
 /* Generic info of form tag = "info" */
 #define MODULE_INFO(tag, info)					  \
+	static_assert(						  \
+		sizeof(info) - 1 == __builtin_strlen(info),	  \
+		"MODULE_INFO(" #tag ", ...) contains embedded NUL byte"); \
 	static const char __UNIQUE_ID(modinfo)[]			  \
 		__used __section(".modinfo") __aligned(1)		  \
 		= __MODULE_INFO_PREFIX __stringify(tag) "=" info
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 3/3
#6 lore raw
Quoted 27 lines · Kees Cook

Long ago, the kernel module license checks were bypassed by embedding a NUL character in the MODULE_LICENSE() string[1]. By using a string like "GPL\0proprietary text", the kernel would only read "GPL" due to C string termination at the NUL byte, allowing proprietary modules to avoid kernel tainting and access GPL-only symbols.

The MODULE_INFO() macro stores these strings in the .modinfo ELF section, and get_next_modinfo() uses strcmp()-family functions which stop at the first NUL. This split the embedded string into two separate .modinfo entries, with only the first part being processed by license_is_gpl_compatible().

Add a compile-time check using static_assert that compares the full string length (sizeof - 1) against __builtin_strlen(), which stops at the first NUL. If they differ, compilation fails with a clear error message.

While this check can still be circumvented by modifying the ELF binary post-compilation, it prevents accidental embedded NULs and forces intentional abuse to require deliberate binary manipulation rather than simple source-level tricks.

Build tested with test modules containing both valid and invalid license strings. The check correctly rejects:

MODULE_LICENSE("GPL\0proprietary")

Quoted 7 lines

while accepting normal declarations:

MODULE_LICENSE("GPL")

Signature · 2 lines
Thanks,
Petr
reviewer Reviewed-by on v2 3/3
#7 lore raw
In reply to Kees Cook
Quoted 62 lines · Kees Cook

Long ago, the kernel module license checks were bypassed by embedding a NUL character in the MODULE_LICENSE() string[1]. By using a string like "GPL\0proprietary text", the kernel would only read "GPL" due to C string termination at the NUL byte, allowing proprietary modules to avoid kernel tainting and access GPL-only symbols.

The MODULE_INFO() macro stores these strings in the .modinfo ELF section, and get_next_modinfo() uses strcmp()-family functions which stop at the first NUL. This split the embedded string into two separate .modinfo entries, with only the first part being processed by license_is_gpl_compatible().

Add a compile-time check using static_assert that compares the full string length (sizeof - 1) against __builtin_strlen(), which stops at the first NUL. If they differ, compilation fails with a clear error message.

While this check can still be circumvented by modifying the ELF binary post-compilation, it prevents accidental embedded NULs and forces intentional abuse to require deliberate binary manipulation rather than simple source-level tricks.

Build tested with test modules containing both valid and invalid license strings. The check correctly rejects:

MODULE_LICENSE("GPL\0proprietary")

while accepting normal declarations:

MODULE_LICENSE("GPL")

---
Cc: Luis Chamberlain <[email protected]>
Cc: Petr Pavlu <[email protected]>
Cc: Daniel Gomez <[email protected]>
Cc: Sami Tolvanen <[email protected]>
Cc: <[email protected]>

---
 include/linux/moduleparam.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/moduleparam.h +3 -0
index 6907aedc4f74..915f32f7d888 100644
@@ -26,6 +26,9 @@
 
 /* Generic info of form tag = "info" */
 #define MODULE_INFO(tag, info)					  \
+	static_assert(						  \
+		sizeof(info) - 1 == __builtin_strlen(info),	  \
+		"MODULE_INFO(" #tag ", ...) contains embedded NUL byte"); \
 	static const char __UNIQUE_ID(modinfo)[]			  \
 		__used __section(".modinfo") __aligned(1)		  \
 		= __MODULE_INFO_PREFIX __stringify(tag) "=" info
Signature · 1 line
2.34.1

Nice!

Signature · 1 line
Aaron Tomlin
#8 lore raw
In reply to Kees Cook
Quoted 22 lines · Kees Cook

Long ago, the kernel module license checks were bypassed by embedding a NUL character in the MODULE_LICENSE() string[1]. By using a string like "GPL\0proprietary text", the kernel would only read "GPL" due to C string termination at the NUL byte, allowing proprietary modules to avoid kernel tainting and access GPL-only symbols.

The MODULE_INFO() macro stores these strings in the .modinfo ELF section, and get_next_modinfo() uses strcmp()-family functions which stop at the first NUL. This split the embedded string into two separate .modinfo entries, with only the first part being processed by license_is_gpl_compatible().

Add a compile-time check using static_assert that compares the full string length (sizeof - 1) against __builtin_strlen(), which stops at the first NUL. If they differ, compilation fails with a clear error message.

While this check can still be circumvented by modifying the ELF binary post-compilation, it prevents accidental embedded NULs and forces intentional abuse to require deliberate binary manipulation rather than simple source-level tricks.

Quoted 8 lines

Build tested with test modules containing both valid and invalid license strings. The check correctly rejects:

MODULE_LICENSE("GPL\0proprietary")

while accepting normal declarations:

MODULE_LICENSE("GPL")

Who will take this series? I can take the first two media patches and someone else can take this last patch, or I can take all, or someone else can take all patches. The media patches already have my 'Reviewed-by'.

Any preferences?

Regards,

Hans

Quoted 28 lines

---
Cc: Luis Chamberlain <[email protected]>
Cc: Petr Pavlu <[email protected]>
Cc: Daniel Gomez <[email protected]>
Cc: Sami Tolvanen <[email protected]>
Cc: <[email protected]>

---
 include/linux/moduleparam.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/moduleparam.h +3 -0
index 6907aedc4f74..915f32f7d888 100644
@@ -26,6 +26,9 @@
 
 /* Generic info of form tag = "info" */
 #define MODULE_INFO(tag, info)					  \
+	static_assert(						  \
+		sizeof(info) - 1 == __builtin_strlen(info),	  \
+		"MODULE_INFO(" #tag ", ...) contains embedded NUL byte"); \
 	static const char __UNIQUE_ID(modinfo)[]			  \
 		__used __section(".modinfo") __aligned(1)		  \
 		= __MODULE_INFO_PREFIX __stringify(tag) "=" info
maintainer Reviewed-by
#9 lore raw
Quoted 30 lines · Hans Verkuil
Quoted 29 lines · Kees Cook

Long ago, the kernel module license checks were bypassed by embedding a NUL character in the MODULE_LICENSE() string[1]. By using a string like "GPL\0proprietary text", the kernel would only read "GPL" due to C string termination at the NUL byte, allowing proprietary modules to avoid kernel tainting and access GPL-only symbols.

The MODULE_INFO() macro stores these strings in the .modinfo ELF section, and get_next_modinfo() uses strcmp()-family functions which stop at the first NUL. This split the embedded string into two separate .modinfo entries, with only the first part being processed by license_is_gpl_compatible().

Add a compile-time check using static_assert that compares the full string length (sizeof - 1) against __builtin_strlen(), which stops at the first NUL. If they differ, compilation fails with a clear error message.

While this check can still be circumvented by modifying the ELF binary post-compilation, it prevents accidental embedded NULs and forces intentional abuse to require deliberate binary manipulation rather than simple source-level tricks.

Build tested with test modules containing both valid and invalid license strings. The check correctly rejects:

MODULE_LICENSE("GPL\0proprietary")

while accepting normal declarations:

Quoted 7 lines
Quoted 1 line

MODULE_LICENSE("GPL")

Who will take this series? I can take the first two media patches and someone else can take this last patch, or I can take all, or someone else can take all patches. The media patches already have my 'Reviewed-by'.

Any preferences?

I will take patch 3 in modules' tree.

Quoted 9 lines

Regards,

Hans

Quoted 4 lines
#10 lore raw
Quoted 33 lines · Daniel Gomez
Quoted 32 lines · Hans Verkuil
Quoted 30 lines · Kees Cook

Long ago, the kernel module license checks were bypassed by embedding a NUL character in the MODULE_LICENSE() string[1]. By using a string like "GPL\0proprietary text", the kernel would only read "GPL" due to C string termination at the NUL byte, allowing proprietary modules to avoid kernel tainting and access GPL-only symbols.

The MODULE_INFO() macro stores these strings in the .modinfo ELF section, and get_next_modinfo() uses strcmp()-family functions which stop at the first NUL. This split the embedded string into two separate .modinfo entries, with only the first part being processed by license_is_gpl_compatible().

Add a compile-time check using static_assert that compares the full string length (sizeof - 1) against __builtin_strlen(), which stops at the first NUL. If they differ, compilation fails with a clear error message.

While this check can still be circumvented by modifying the ELF binary post-compilation, it prevents accidental embedded NULs and forces intentional abuse to require deliberate binary manipulation rather than simple source-level tricks.

Build tested with test modules containing both valid and invalid license strings. The check correctly rejects:

MODULE_LICENSE("GPL\0proprietary")

while accepting normal declarations:

MODULE_LICENSE("GPL")

Quoted 7 lines
Quoted 5 lines

Who will take this series? I can take the first two media patches and someone else can take this last patch, or I can take all, or someone else can take all patches. The media patches already have my 'Reviewed-by'.

Any preferences?

I will take patch 3 in modules' tree.

OK, then I'll take patches 1 and 2 in the media tree.

Regards,

Hans

Quoted 13 lines
Quoted 11 lines

Regards,

Hans

Quoted 4 lines
#11 lore raw
In reply to Kees Cook

Hi Kees, Dan,

Sorry to react on an oldish patch, but I have a question about it, see below.

Quoted 49 lines · Kees Cook

Long ago, the kernel module license checks were bypassed by embedding a NUL character in the MODULE_LICENSE() string[1]. By using a string like "GPL\0proprietary text", the kernel would only read "GPL" due to C string termination at the NUL byte, allowing proprietary modules to avoid kernel tainting and access GPL-only symbols.

The MODULE_INFO() macro stores these strings in the .modinfo ELF section, and get_next_modinfo() uses strcmp()-family functions which stop at the first NUL. This split the embedded string into two separate .modinfo entries, with only the first part being processed by license_is_gpl_compatible().

Add a compile-time check using static_assert that compares the full string length (sizeof - 1) against __builtin_strlen(), which stops at the first NUL. If they differ, compilation fails with a clear error message.

While this check can still be circumvented by modifying the ELF binary post-compilation, it prevents accidental embedded NULs and forces intentional abuse to require deliberate binary manipulation rather than simple source-level tricks.

Build tested with test modules containing both valid and invalid license strings. The check correctly rejects:

MODULE_LICENSE("GPL\0proprietary")

while accepting normal declarations:

MODULE_LICENSE("GPL")

---
Cc: Luis Chamberlain <[email protected]>
Cc: Petr Pavlu <[email protected]>
Cc: Daniel Gomez <[email protected]>
Cc: Sami Tolvanen <[email protected]>
Cc: <[email protected]>

---
 include/linux/moduleparam.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/moduleparam.h +0 -0
index 6907aedc4f74..915f32f7d888 100644

include/linux/moduleparam.h line 31

Quoted 6 lines
include/linux/moduleparam.h +3 -0
@@ -26,6 +26,9 @@
 
 /* Generic info of form tag = "info" */
 #define MODULE_INFO(tag, info)					  \
+	static_assert(						  \
+		sizeof(info) - 1 == __builtin_strlen(info),	  \
+		"MODULE_INFO(" #tag ", ...) contains embedded NUL byte"); \

When checking MPTCP code on top of Linus tree, I get this new warning with all MPTCP KUnit tests (net/mptcp/*_test.c), e.g.

$ touch net/mptcp/crypto_test.c && make C=1 net/mptcp/crypto_test.o
  CC [M]  net/mptcp/crypto_test.o
  CHECK   net/mptcp/crypto_test.c
net/mptcp/crypto_test.c:72:1: error: bad integer constant expression
net/mptcp/crypto_test.c:72:1: error: static assertion failed: "MODULE_INFO(license, ...) contains embedded NUL byte"
net/mptcp/crypto_test.c:73:1: error: bad integer constant expression
net/mptcp/crypto_test.c:73:1: error: static assertion failed: "MODULE_INFO(description, ...) contains embedded NUL byte"

I'm using Sparse last development version with Dan's commit:

$ sparse --version
v0.6.4-73-gfbdde312

=> fbdde312 ("builtin: implement __builtin_strlen() for constants")

And the two lines causing the warnings don't have "\0":

    72  MODULE_LICENSE("GPL");
    73  MODULE_DESCRIPTION("KUnit tests for MPTCP Crypto");

Am I missing something?

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#12 lore raw
Quoted 8 lines · Matthieu Baerts
$ touch net/mptcp/crypto_test.c && make C=1 net/mptcp/crypto_test.o
  CC [M]  net/mptcp/crypto_test.o
  CHECK   net/mptcp/crypto_test.c
net/mptcp/crypto_test.c:72:1: error: bad integer constant expression
net/mptcp/crypto_test.c:72:1: error: static assertion failed: "MODULE_INFO(license, ...) contains embedded NUL byte"
net/mptcp/crypto_test.c:73:1: error: bad integer constant expression
net/mptcp/crypto_test.c:73:1: error: static assertion failed: "MODULE_INFO(description, ...) contains embedded NUL byte"

FYI, we were discussing the fix here:

https://lore.kernel.org/all/[email protected]/

Sami provided a fix to the thread that you can test. It'd be good to know if it works for you too. But we still have some questions as we are not familiar with the sparse code.

Sami, would you mind sending a patch to the sparse list and then we can ask questions there?

#13 lore raw
In reply to Matthieu Baerts
Quoted 4 lines · Matthieu Baerts

net/mptcp/crypto_test.c:72:1: error: bad integer constant expression
net/mptcp/crypto_test.c:72:1: error: static assertion failed: "MODULE_INFO(license, ...) contains embedded NUL byte" net/mptcp/crypto_test.c:73:1: error: bad integer constant expression
net/mptcp/crypto_test.c:73:1: error: static assertion failed: "MODULE_INFO(description, ...) contains embedded NUL byte"

There was a fix for that posted. Let me ping them to see if anyone is planning to send an actual patch.

https://lore.kernel.org/all/[email protected]/

regards
dan carpenter

#14 lore raw

Hi Dan, Daniel

Quoted 10 lines · Dan Carpenter
Quoted 4 lines · Matthieu Baerts

net/mptcp/crypto_test.c:72:1: error: bad integer constant expression
net/mptcp/crypto_test.c:72:1: error: static assertion failed: "MODULE_INFO(license, ...) contains embedded NUL byte" net/mptcp/crypto_test.c:73:1: error: bad integer constant expression
net/mptcp/crypto_test.c:73:1: error: static assertion failed: "MODULE_INFO(description, ...) contains embedded NUL byte"

There was a fix for that posted. Let me ping them to see if anyone is planning to send an actual patch.

https://lore.kernel.org/all/[email protected]/

Thank you both for your reply! I didn't think about looking at the v1.

I confirm that Sami's patch silences the errors on my side. Thanks!

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#15 lore raw
Quoted 12 lines · Matthieu Baerts

Hi Dan, Daniel

Quoted 8 lines · Dan Carpenter
Quoted 4 lines · Matthieu Baerts

net/mptcp/crypto_test.c:72:1: error: bad integer constant expression
net/mptcp/crypto_test.c:72:1: error: static assertion failed: "MODULE_INFO(license, ...) contains embedded NUL byte" net/mptcp/crypto_test.c:73:1: error: bad integer constant expression
net/mptcp/crypto_test.c:73:1: error: static assertion failed: "MODULE_INFO(description, ...) contains embedded NUL byte"

There was a fix for that posted. Let me ping them to see if anyone is planning to send an actual patch.

Should I wait for the actual patch for sparse?

Quoted 6 lines
Quoted 2 lines

https://lore.kernel.org/all/[email protected]/

Thank you both for your reply! I didn't think about looking at the v1.

I confirm that Sami's patch silences the errors on my side. Thanks!

Thanks for the report.

Chris

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#17 lore raw
Quoted 8 lines · Patchwork Integration

Dear Kees Cook:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test static:test-smatch

drivers/media/usb/usbtv/usbtv-core.c:157:1: error: bad constant expression

Where can I find what this test actually does?

Quoted 2 lines

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.htm .

This webserver appears to be misconfigured to send compressed output without the right headers? I can't actually view this URL.

-Kees

Signature · 1 line
Kees Cook
#18 lore raw

Hi Kees

Thanks for the report.

Quoted 11 lines · Kees Cook
Quoted 7 lines · Patchwork Integration

Dear Kees Cook:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test static:test-smatch

Quoted 8 lines
Quoted 1 line

drivers/media/usb/usbtv/usbtv-core.c:157:1: error: bad constant expression

Where can I find what this test actually does?

Quoted 2 lines

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.htm .

This webserver appears to be misconfigured to send compressed output without the right headers? I can't actually view this URL.

I will follow-up with fdo maintainers to figure out what happened. there. On the meantime you can use these url that seems to work:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.txt
https://gitlab.freedesktop.org/linux-media/users/patchwork/-/jobs/85913398

Basically sparse/smatch do not seem to understand the constant.

Thanks!

Quoted 5 lines

-Kees

--
Kees Cook

Signature · 1 line
Ricardo Ribalda
author
#19 lore raw
Quoted 24 lines · Ricardo Ribalda

Hi Kees

Thanks for the report.

Quoted 18 lines · Kees Cook
Quoted 8 lines · Patchwork Integration

Dear Kees Cook:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test static:test-smatch

drivers/media/usb/usbtv/usbtv-core.c:157:1: error: bad constant expression

Where can I find what this test actually does?

Quoted 2 lines

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.htm .

Quoted 8 lines
Quoted 1 line

This webserver appears to be misconfigured to send compressed output without the right headers? I can't actually view this URL.

I will follow-up with fdo maintainers to figure out what happened. there. On the meantime you can use these url that seems to work:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.txt
https://gitlab.freedesktop.org/linux-media/users/patchwork/-/jobs/85913398

Basically sparse/smatch do not seem to understand the constant.

Yeah, I managed to find the actual scripts that are run for the static-sparse/smatch tests. It looks like those tools aren't correctly handling string literals for __builtin_strlen(), which is a constant for constant arguments.

So, that's a C parsing bug in those tools (GCC and Clang are fine).

-Kees

Signature · 1 line
Kees Cook
#20 lore raw

Hi Dan

Quoted 33 lines · Kees Cook
Quoted 31 lines · Ricardo Ribalda

Hi Kees

Thanks for the report.

Quoted 11 lines · Kees Cook
Quoted 7 lines · Patchwork Integration

Dear Kees Cook:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test static:test-smatch

Quoted 8 lines
Quoted 1 line

drivers/media/usb/usbtv/usbtv-core.c:157:1: error: bad constant expression

Where can I find what this test actually does?

Quoted 2 lines

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.htm .

This webserver appears to be misconfigured to send compressed output without the right headers? I can't actually view this URL.

I will follow-up with fdo maintainers to figure out what happened. there. On the meantime you can use these url that seems to work:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.txt
https://gitlab.freedesktop.org/linux-media/users/patchwork/-/jobs/85913398

Quoted 8 lines
Quoted 1 line

Basically sparse/smatch do not seem to understand the constant.

Yeah, I managed to find the actual scripts that are run for the static-sparse/smatch tests. It looks like those tools aren't correctly handling string literals for __builtin_strlen(), which is a constant for constant arguments.

So, that's a C parsing bug in those tools (GCC and Clang are fine).

Could you take a look at this patch:
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

Seems that sparse/smatch are not very happy about __builtin_strlen()

Could you fix support for __builtin_strlen() in your tool?

Once Kees lands his patch it will break all the CIs using sparse/smatch, including media-ci.

Eg:

drivers/media/pci/zoran/zr36060.c:33:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression

Thanks :)

Quoted 5 lines

-Kees

--
Kees Cook

Signature · 1 line
Ricardo Ribalda
author
#21 lore raw
Quoted 52 lines · Ricardo Ribalda

Hi Dan

Quoted 33 lines · Kees Cook
Quoted 31 lines · Ricardo Ribalda

Hi Kees

Thanks for the report.

Quoted 11 lines · Kees Cook
Quoted 7 lines · Patchwork Integration

Dear Kees Cook:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test static:test-smatch

Quoted 8 lines
Quoted 1 line

drivers/media/usb/usbtv/usbtv-core.c:157:1: error: bad constant expression

Where can I find what this test actually does?

Quoted 2 lines

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.htm .

This webserver appears to be misconfigured to send compressed output without the right headers? I can't actually view this URL.

I will follow-up with fdo maintainers to figure out what happened. there. On the meantime you can use these url that seems to work:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.txt
https://gitlab.freedesktop.org/linux-media/users/patchwork/-/jobs/85913398

Quoted 8 lines
Quoted 1 line

Basically sparse/smatch do not seem to understand the constant.

Yeah, I managed to find the actual scripts that are run for the static-sparse/smatch tests. It looks like those tools aren't correctly handling string literals for __builtin_strlen(), which is a constant for constant arguments.

So, that's a C parsing bug in those tools (GCC and Clang are fine).

Could you take a look at this patch:
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

Seems that sparse/smatch are not very happy about __builtin_strlen()

Could you fix support for __builtin_strlen() in your tool?

Quoted 8 lines

Once Kees lands his patch it will break all the CIs using sparse/smatch, including media-ci.

Eg:

drivers/media/pci/zoran/zr36060.c:33:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression

We've waited a decade to get the embedded-NUL check into the modinfo macros, so I'm happy to wait until we can get the CI tooling updated.

Please keep me posted on when the sparse and smatch have been updated and I'll re-send the modinfo patch.

Thanks!

-Kees

Signature · 1 line
Kees Cook
#22 lore raw

Hi Kees

Quoted 57 lines · Kees Cook
Quoted 55 lines · Ricardo Ribalda

Hi Dan

Quoted 33 lines · Kees Cook
Quoted 31 lines · Ricardo Ribalda

Hi Kees

Thanks for the report.

Quoted 11 lines · Kees Cook
Quoted 7 lines · Patchwork Integration

Dear Kees Cook:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test static:test-smatch

Quoted 8 lines
Quoted 1 line

drivers/media/usb/usbtv/usbtv-core.c:157:1: error: bad constant expression

Where can I find what this test actually does?

Quoted 2 lines

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.htm .

This webserver appears to be misconfigured to send compressed output without the right headers? I can't actually view this URL.

I will follow-up with fdo maintainers to figure out what happened. there. On the meantime you can use these url that seems to work:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.txt
https://gitlab.freedesktop.org/linux-media/users/patchwork/-/jobs/85913398

Quoted 8 lines
Quoted 1 line

Basically sparse/smatch do not seem to understand the constant.

Yeah, I managed to find the actual scripts that are run for the static-sparse/smatch tests. It looks like those tools aren't correctly handling string literals for __builtin_strlen(), which is a constant for constant arguments.

So, that's a C parsing bug in those tools (GCC and Clang are fine).

Could you take a look at this patch:
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

Seems that sparse/smatch are not very happy about __builtin_strlen()

Could you fix support for __builtin_strlen() in your tool?

Once Kees lands his patch it will break all the CIs using sparse/smatch, including media-ci.

Quoted 8 lines
Quoted 5 lines

Eg:

drivers/media/pci/zoran/zr36060.c:33:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression

We've waited a decade to get the embedded-NUL check into the modinfo macros, so I'm happy to wait until we can get the CI tooling updated.

For media-ci. It will probably be after 6.19rc1

Basically, when
https://lore.kernel.org/linux-sparse/CACePvbVG2KrGQq4cNKV=wbO5h=jp3M0RO1SdfX8kV4OukjPG8A@mail.gmail.com/T/#t
lands in media-committers.

How did you plan to land this series? via which tree?

if Chris have not landed his fix yet, maybe you can include that patch in your series as 1/X.... That will make every ci happy

Regards!

Quoted 10 lines

Please keep me posted on when the sparse and smatch have been updated and I'll re-send the modinfo patch.

Thanks!

-Kees

--
Kees Cook

Signature · 1 line
Ricardo Ribalda
author
#23 lore raw
Quoted 66 lines · Ricardo Ribalda

Hi Kees

Quoted 63 lines · Kees Cook
Quoted 60 lines · Ricardo Ribalda

Hi Dan

Quoted 33 lines · Kees Cook
Quoted 31 lines · Ricardo Ribalda

Hi Kees

Thanks for the report.

Quoted 11 lines · Kees Cook
Quoted 7 lines · Patchwork Integration

Dear Kees Cook:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test static:test-smatch

Quoted 8 lines
Quoted 1 line

drivers/media/usb/usbtv/usbtv-core.c:157:1: error: bad constant expression

Where can I find what this test actually does?

Quoted 2 lines

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.htm .

This webserver appears to be misconfigured to send compressed output without the right headers? I can't actually view this URL.

I will follow-up with fdo maintainers to figure out what happened. there. On the meantime you can use these url that seems to work:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.txt
https://gitlab.freedesktop.org/linux-media/users/patchwork/-/jobs/85913398

Quoted 8 lines
Quoted 1 line

Basically sparse/smatch do not seem to understand the constant.

Yeah, I managed to find the actual scripts that are run for the static-sparse/smatch tests. It looks like those tools aren't correctly handling string literals for __builtin_strlen(), which is a constant for constant arguments.

So, that's a C parsing bug in those tools (GCC and Clang are fine).

Could you take a look at this patch:
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

Seems that sparse/smatch are not very happy about __builtin_strlen()

Could you fix support for __builtin_strlen() in your tool?

Once Kees lands his patch it will break all the CIs using sparse/smatch, including media-ci.

Eg:

drivers/media/pci/zoran/zr36060.c:33:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression

Quoted 8 lines
Quoted 2 lines

We've waited a decade to get the embedded-NUL check into the modinfo macros, so I'm happy to wait until we can get the CI tooling updated.

For media-ci. It will probably be after 6.19rc1

Basically, when
https://lore.kernel.org/linux-sparse/CACePvbVG2KrGQq4cNKV=wbO5h=jp3M0RO1SdfX8kV4OukjPG8A@mail.gmail.com/T/#t
lands in media-committers.

That's external to Linux, though; it's a patch for sparse and smatch. How often does the CI rebuild sparse and smatch?

Quoted 1 line

How did you plan to land this series? via which tree?

I assume it would go either via the modules tree or the hardening tree. (Again, no rush.)

Quoted 2 lines

if Chris have not landed his fix yet, maybe you can include that patch in your series as 1/X.... That will make every ci happy

Since it's a patch for a separate project, I don't think that will work. (Maybe I'm misunderstanding something?)

-Kees

Signature · 1 line
Kees Cook
#24 lore raw

Hi Kees

Quoted 71 lines · Kees Cook
Quoted 69 lines · Ricardo Ribalda

Hi Kees

Quoted 65 lines · Kees Cook
Quoted 52 lines · Ricardo Ribalda

Hi Dan

Quoted 33 lines · Kees Cook
Quoted 31 lines · Ricardo Ribalda

Hi Kees

Thanks for the report.

Quoted 11 lines · Kees Cook
Quoted 7 lines · Patchwork Integration

Dear Kees Cook:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test static:test-smatch

Quoted 8 lines
Quoted 1 line

drivers/media/usb/usbtv/usbtv-core.c:157:1: error: bad constant expression

Where can I find what this test actually does?

Quoted 2 lines

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.htm .

This webserver appears to be misconfigured to send compressed output without the right headers? I can't actually view this URL.

I will follow-up with fdo maintainers to figure out what happened. there. On the meantime you can use these url that seems to work:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.txt
https://gitlab.freedesktop.org/linux-media/users/patchwork/-/jobs/85913398

Quoted 8 lines
Quoted 1 line

Basically sparse/smatch do not seem to understand the constant.

Yeah, I managed to find the actual scripts that are run for the static-sparse/smatch tests. It looks like those tools aren't correctly handling string literals for __builtin_strlen(), which is a constant for constant arguments.

So, that's a C parsing bug in those tools (GCC and Clang are fine).

Could you take a look at this patch:
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

Seems that sparse/smatch are not very happy about __builtin_strlen()

Could you fix support for __builtin_strlen() in your tool?

Quoted 8 lines

Once Kees lands his patch it will break all the CIs using sparse/smatch, including media-ci.

Eg:

drivers/media/pci/zoran/zr36060.c:33:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression

We've waited a decade to get the embedded-NUL check into the modinfo macros, so I'm happy to wait until we can get the CI tooling updated.

Quoted 8 lines
Quoted 5 lines

For media-ci. It will probably be after 6.19rc1

Basically, when
https://lore.kernel.org/linux-sparse/CACePvbVG2KrGQq4cNKV=wbO5h=jp3M0RO1SdfX8kV4OukjPG8A@mail.gmail.com/T/#t
lands in media-committers.

That's external to Linux, though; it's a patch for sparse and smatch. How often does the CI rebuild sparse and smatch?

My bad, I thought it was a patch for the kernel tree :)

We build it every monday or when there is a change in media-ci. I can also trigger it manually.

Quoted 11 lines
Quoted 2 lines

How did you plan to land this series? via which tree?

I assume it would go either via the modules tree or the hardening tree. (Again, no rush.)

Quoted 2 lines

if Chris have not landed his fix yet, maybe you can include that patch in your series as 1/X.... That will make every ci happy

Since it's a patch for a separate project, I don't think that will work. (Maybe I'm misunderstanding something?)

No, it is me who misunderstood it, sorry.

Quoted 5 lines

-Kees

--
Kees Cook

Signature · 1 line
Ricardo Ribalda
maintainer
#25 lore raw
In reply to Kees Cook
Quoted 76 lines · Kees Cook
Quoted 66 lines · Ricardo Ribalda

Hi Kees

Quoted 63 lines · Kees Cook
Quoted 60 lines · Ricardo Ribalda

Hi Dan

Quoted 33 lines · Kees Cook
Quoted 31 lines · Ricardo Ribalda

Hi Kees

Thanks for the report.

Quoted 11 lines · Kees Cook
Quoted 7 lines · Patchwork Integration

Dear Kees Cook:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test static:test-smatch

Quoted 8 lines
Quoted 1 line

drivers/media/usb/usbtv/usbtv-core.c:157:1: error: bad constant expression

Where can I find what this test actually does?

Quoted 2 lines

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.htm .

This webserver appears to be misconfigured to send compressed output without the right headers? I can't actually view this URL.

I will follow-up with fdo maintainers to figure out what happened. there. On the meantime you can use these url that seems to work:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/85913402/artifacts/report.txt
https://gitlab.freedesktop.org/linux-media/users/patchwork/-/jobs/85913398

Quoted 8 lines
Quoted 1 line

Basically sparse/smatch do not seem to understand the constant.

Yeah, I managed to find the actual scripts that are run for the static-sparse/smatch tests. It looks like those tools aren't correctly handling string literals for __builtin_strlen(), which is a constant for constant arguments.

So, that's a C parsing bug in those tools (GCC and Clang are fine).

Could you take a look at this patch:
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

Seems that sparse/smatch are not very happy about __builtin_strlen()

Could you fix support for __builtin_strlen() in your tool?

Once Kees lands his patch it will break all the CIs using sparse/smatch, including media-ci.

Eg:

drivers/media/pci/zoran/zr36060.c:33:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression drivers/media/usb/pvrusb2/pvrusb2-dvb.c:19:1: error: bad constant expression

Quoted 8 lines
Quoted 2 lines

We've waited a decade to get the embedded-NUL check into the modinfo macros, so I'm happy to wait until we can get the CI tooling updated.

For media-ci. It will probably be after 6.19rc1

Basically, when
https://lore.kernel.org/linux-sparse/CACePvbVG2KrGQq4cNKV=wbO5h=jp3M0RO1SdfX8kV4OukjPG8A@mail.gmail.com/T/#t
lands in media-committers.

Quoted 7 lines

That's external to Linux, though; it's a patch for sparse and smatch. How often does the CI rebuild sparse and smatch?

Quoted 1 line

How did you plan to land this series? via which tree?

I assume it would go either via the modules tree or the hardening tree. (Again, no rush.)

FYI, the patch is applied to modules-next, so I was planning to send it for v6.19-rc1.

author
#27 lore raw
Quoted 7 lines · Daniel Gomez
Quoted 5 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 3 lines

Hi!

[...]

Applied patch 3, thanks!

[3/3] module: Add compile-time check for embedded NUL characters

      commit: 913359754ea821c4d6f6a77e0449b29984099663

I'm nervous about this going in alone -- it breaks allmodconfig builds without the media fixes. My intention was to have the media fixes land first...

Should I send the media fixes to linus right away?

-Kees

Signature · 1 line
Kees Cook
maintainer
#28 lore raw
Quoted 17 lines · Kees Cook
Quoted 7 lines · Daniel Gomez
Quoted 5 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 3 lines

Hi!

[...]

Applied patch 3, thanks!

[3/3] module: Add compile-time check for embedded NUL characters

      commit: 913359754ea821c4d6f6a77e0449b29984099663
Quoted 8 lines

I'm nervous about this going in alone -- it breaks allmodconfig builds without the media fixes. My intention was to have the media fixes land first...

Should I send the media fixes to linus right away?

-Kees

I can take both patches. But I think it'd make sense to drop patch 3 first and then, apply all 3.

Please, Kees, Hans and Mauro, let me know if this is okay with you.

#29 lore raw
Quoted 26 lines · Daniel Gomez
Quoted 23 lines · Kees Cook
Quoted 7 lines · Daniel Gomez
Quoted 5 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 3 lines

Hi!

[...]

Applied patch 3, thanks!

[3/3] module: Add compile-time check for embedded NUL characters

      commit: 913359754ea821c4d6f6a77e0449b29984099663

I'm nervous about this going in alone -- it breaks allmodconfig builds without the media fixes. My intention was to have the media fixes land first...

Should I send the media fixes to linus right away?

Quoted 7 lines
Quoted 2 lines

-Kees

I can take both patches. But I think it'd make sense to drop patch 3 first and then, apply all 3.

Please, Kees, Hans and Mauro, let me know if this is okay with you.

I'm fine. If you take it, then I'll drop the media patches from our tree (I merged the media patches yesterday).

Let me know if you take them.

Regards,

Hans

maintainer
#30 lore raw
Quoted 33 lines · Hans Verkuil
Quoted 32 lines · Daniel Gomez
Quoted 17 lines · Kees Cook
Quoted 7 lines · Daniel Gomez
Quoted 5 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 3 lines

Hi!

[...]

Applied patch 3, thanks!

[3/3] module: Add compile-time check for embedded NUL characters

      commit: 913359754ea821c4d6f6a77e0449b29984099663
Quoted 8 lines

I'm nervous about this going in alone -- it breaks allmodconfig builds without the media fixes. My intention was to have the media fixes land first...

Should I send the media fixes to linus right away?

-Kees

I can take both patches. But I think it'd make sense to drop patch 3 first and then, apply all 3.

Quoted 6 lines
Quoted 1 line

Please, Kees, Hans and Mauro, let me know if this is okay with you.

I'm fine. If you take it, then I'll drop the media patches from our tree (I merged the media patches yesterday).

Let me know if you take them.

Thanks, Hans. I merged patch 3 yesterday as well, but since patch order matters in this case, it makes sense to take all of them through the modules tree.

Sorry for the trouble, and thanks Kees, for pointing this out.

Quoted 4 lines

Regards,

Hans

maintainer
#31 lore raw
Quoted 41 lines · Daniel Gomez
Quoted 38 lines · Hans Verkuil
Quoted 26 lines · Daniel Gomez
Quoted 23 lines · Kees Cook
Quoted 7 lines · Daniel Gomez
Quoted 5 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 3 lines

Hi!

[...]

Applied patch 3, thanks!

[3/3] module: Add compile-time check for embedded NUL characters

      commit: 913359754ea821c4d6f6a77e0449b29984099663

I'm nervous about this going in alone -- it breaks allmodconfig builds without the media fixes. My intention was to have the media fixes land first...

Should I send the media fixes to linus right away?

Quoted 7 lines
Quoted 2 lines

-Kees

I can take both patches. But I think it'd make sense to drop patch 3 first and then, apply all 3.

Please, Kees, Hans and Mauro, let me know if this is okay with you.

I'm fine. If you take it, then I'll drop the media patches from our tree (I merged the media patches yesterday).

Quoted 6 lines
Quoted 1 line

Let me know if you take them.

Thanks, Hans. I merged patch 3 yesterday as well, but since patch order matters in this case, it makes sense to take all of them through the modules tree.

Sorry for the trouble, and thanks Kees, for pointing this out.

Kees,

FYI, I have dropped patch 3 from modules. My intention is to merge all 3 patches tomorrow.

I believe Hans has also dropped the patches from the media tree as I do not see them here: https://git.linuxtv.org/media.git/log/

Quoted 5 lines
Quoted 5 lines

Regards,

Hans

#32 lore raw
Quoted 51 lines · Daniel Gomez
Quoted 41 lines · Daniel Gomez
Quoted 38 lines · Hans Verkuil
Quoted 26 lines · Daniel Gomez
Quoted 23 lines · Kees Cook
Quoted 7 lines · Daniel Gomez
Quoted 5 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 3 lines

Hi!

[...]

Applied patch 3, thanks!

[3/3] module: Add compile-time check for embedded NUL characters

      commit: 913359754ea821c4d6f6a77e0449b29984099663

I'm nervous about this going in alone -- it breaks allmodconfig builds without the media fixes. My intention was to have the media fixes land first...

Should I send the media fixes to linus right away?

Quoted 7 lines
Quoted 2 lines

-Kees

I can take both patches. But I think it'd make sense to drop patch 3 first and then, apply all 3.

Please, Kees, Hans and Mauro, let me know if this is okay with you.

I'm fine. If you take it, then I'll drop the media patches from our tree (I merged the media patches yesterday).

Quoted 6 lines
Quoted 1 line

Let me know if you take them.

Thanks, Hans. I merged patch 3 yesterday as well, but since patch order matters in this case, it makes sense to take all of them through the modules tree.

Sorry for the trouble, and thanks Kees, for pointing this out.

Quoted 7 lines

Kees,

FYI, I have dropped patch 3 from modules. My intention is to merge all 3 patches tomorrow.

I believe Hans has also dropped the patches from the media tree as I do not see them here: https://git.linuxtv.org/media.git/log/

Correct, I dropped them. They are all yours :-)

Regards,

Hans

maintainer Reviewed-by Tested-by on the v2 series
#33 lore raw
In reply to Kees Cook
Quoted 62 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Hi!

A long time ago we had an issue with embedded NUL bytes in MODULE_INFO strings[1]. While this stands out pretty strongly when you look at the code, and we can't do anything about a binary module that just plain lies, we never actually implemented the trivial compile-time check needed to detect it.

Add this check (and fix 2 instances of needless trailing semicolons that this change exposed).

Note that these patches were produced as part of another LLM exercise. This time I wanted to try "what happens if I ask an LLM to go read a specific LWN article and write a patch based on a discussion?" It pretty effortlessly chose and implemented a suggested solution, tested the change, and fixed new build warnings in the process.

Since this was a relatively short session, here's an overview of the prompts involved as I guided it through a clean change and tried to see how it would reason about static_assert vs _Static_assert. (It wanted to use what was most common, not what was the current style -- we may want to update the comment above the static_assert macro to suggest using _Static_assert directly these days...)

I want to fix a weakness in the module info strings. Read about it
here: https://lwn.net/Articles/82305/

Since it's only "info" that we need to check, can you reduce the checks to just that instead of all the other stuff?

I think the change to the comment is redundent, and that should be in a commit log instead. Let's just keep the change to the static assert.

Is "static_assert" the idiomatic way to use a static assert in this code base? I've seen _Static_assert used sometimes.

What's the difference between the two?

Does Linux use C11 by default now?

Then let's not use the wrapper any more.

Do an "allmodconfig all -s" build to verify this works for all modules in the kernel.

Thanks!

-Kees

[1] https://lwn.net/Articles/82305/

Kees Cook (3):
media: dvb-usb-v2: lmedm04: Fix firmware macro definitions
media: radio: si470x: Fix DRIVER_AUTHOR macro definition
module: Add compile-time check for embedded NUL characters

Quoted 5 lines
 include/linux/moduleparam.h                   |  3 +++
 drivers/media/radio/si470x/radio-si470x-i2c.c |  2 +-
 drivers/media/usb/dvb-usb-v2/lmedm04.c        | 12 ++++++------
 3 files changed, 10 insertions(+), 7 deletions(-)

I have also tested a build of v6.18-rc3 + patches using allmodconfig:

maintainer
#34 lore raw
Quoted 69 lines · Daniel Gomez
Quoted 62 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Hi!

A long time ago we had an issue with embedded NUL bytes in MODULE_INFO strings[1]. While this stands out pretty strongly when you look at the code, and we can't do anything about a binary module that just plain lies, we never actually implemented the trivial compile-time check needed to detect it.

Add this check (and fix 2 instances of needless trailing semicolons that this change exposed).

Note that these patches were produced as part of another LLM exercise. This time I wanted to try "what happens if I ask an LLM to go read a specific LWN article and write a patch based on a discussion?" It pretty effortlessly chose and implemented a suggested solution, tested the change, and fixed new build warnings in the process.

Since this was a relatively short session, here's an overview of the prompts involved as I guided it through a clean change and tried to see how it would reason about static_assert vs _Static_assert. (It wanted to use what was most common, not what was the current style -- we may want to update the comment above the static_assert macro to suggest using _Static_assert directly these days...)

I want to fix a weakness in the module info strings. Read about it
here: https://lwn.net/Articles/82305/

Since it's only "info" that we need to check, can you reduce the checks to just that instead of all the other stuff?

I think the change to the comment is redundent, and that should be in a commit log instead. Let's just keep the change to the static assert.

Is "static_assert" the idiomatic way to use a static assert in this code base? I've seen _Static_assert used sometimes.

What's the difference between the two?

Does Linux use C11 by default now?

Then let's not use the wrapper any more.

Do an "allmodconfig all -s" build to verify this works for all modules in the kernel.

Thanks!

-Kees

[1] https://lwn.net/Articles/82305/

Kees Cook (3):
media: dvb-usb-v2: lmedm04: Fix firmware macro definitions
media: radio: si470x: Fix DRIVER_AUTHOR macro definition
module: Add compile-time check for embedded NUL characters

Quoted 5 lines
 include/linux/moduleparam.h                   |  3 +++
 drivers/media/radio/si470x/radio-si470x-i2c.c |  2 +-
 drivers/media/usb/dvb-usb-v2/lmedm04.c        | 12 ++++++------
 3 files changed, 10 insertions(+), 7 deletions(-)
Quoted 6 lines

I have also tested a build of v6.18-rc3 + patches using allmodconfig:

I forgot to mention it required the following patch for the build to succeed:

dmaengine: mmp_pdma: fix DMA mask handling

https://lore.kernel.org/all/[email protected]/

#35 lore raw
In reply to Daniel Gomez
Quoted 69 lines · Daniel Gomez
Quoted 62 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Hi!

A long time ago we had an issue with embedded NUL bytes in MODULE_INFO strings[1]. While this stands out pretty strongly when you look at the code, and we can't do anything about a binary module that just plain lies, we never actually implemented the trivial compile-time check needed to detect it.

Add this check (and fix 2 instances of needless trailing semicolons that this change exposed).

Note that these patches were produced as part of another LLM exercise. This time I wanted to try "what happens if I ask an LLM to go read a specific LWN article and write a patch based on a discussion?" It pretty effortlessly chose and implemented a suggested solution, tested the change, and fixed new build warnings in the process.

Since this was a relatively short session, here's an overview of the prompts involved as I guided it through a clean change and tried to see how it would reason about static_assert vs _Static_assert. (It wanted to use what was most common, not what was the current style -- we may want to update the comment above the static_assert macro to suggest using _Static_assert directly these days...)

I want to fix a weakness in the module info strings. Read about it
here: https://lwn.net/Articles/82305/

Since it's only "info" that we need to check, can you reduce the checks to just that instead of all the other stuff?

I think the change to the comment is redundent, and that should be in a commit log instead. Let's just keep the change to the static assert.

Is "static_assert" the idiomatic way to use a static assert in this code base? I've seen _Static_assert used sometimes.

What's the difference between the two?

Does Linux use C11 by default now?

Then let's not use the wrapper any more.

Do an "allmodconfig all -s" build to verify this works for all modules in the kernel.

Thanks!

-Kees

[1] https://lwn.net/Articles/82305/

Kees Cook (3):
media: dvb-usb-v2: lmedm04: Fix firmware macro definitions
media: radio: si470x: Fix DRIVER_AUTHOR macro definition
module: Add compile-time check for embedded NUL characters

Quoted 5 lines
 include/linux/moduleparam.h                   |  3 +++
 drivers/media/radio/si470x/radio-si470x-i2c.c |  2 +-
 drivers/media/usb/dvb-usb-v2/lmedm04.c        | 12 ++++++------
 3 files changed, 10 insertions(+), 7 deletions(-)
Quoted 5 lines

I have also tested a build of v6.18-rc3 + patches using allmodconfig:

Folks, are you aware that this change blown up the sparse? Now there is a "bad constant expression" to each MODULE_*() macro line.

Nice that Uwe is in the Cc list, so IIRC he is Debian maintainer for sparse and perhaps has an influence to it to some extent.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#36 lore raw
Quoted 70 lines · Andy Shevchenko
Quoted 69 lines · Daniel Gomez
Quoted 67 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Hi!

A long time ago we had an issue with embedded NUL bytes in MODULE_INFO strings[1]. While this stands out pretty strongly when you look at the code, and we can't do anything about a binary module that just plain lies, we never actually implemented the trivial compile-time check needed to detect it.

Add this check (and fix 2 instances of needless trailing semicolons that this change exposed).

Note that these patches were produced as part of another LLM exercise. This time I wanted to try "what happens if I ask an LLM to go read a specific LWN article and write a patch based on a discussion?" It pretty effortlessly chose and implemented a suggested solution, tested the change, and fixed new build warnings in the process.

Since this was a relatively short session, here's an overview of the prompts involved as I guided it through a clean change and tried to see how it would reason about static_assert vs _Static_assert. (It wanted to use what was most common, not what was the current style -- we may want to update the comment above the static_assert macro to suggest using _Static_assert directly these days...)

I want to fix a weakness in the module info strings. Read about it
here: https://lwn.net/Articles/82305/

Since it's only "info" that we need to check, can you reduce the checks to just that instead of all the other stuff?

I think the change to the comment is redundent, and that should be in a commit log instead. Let's just keep the change to the static assert.

Is "static_assert" the idiomatic way to use a static assert in this code base? I've seen _Static_assert used sometimes.

What's the difference between the two?

Does Linux use C11 by default now?

Then let's not use the wrapper any more.

Do an "allmodconfig all -s" build to verify this works for all modules in the kernel.

Thanks!

-Kees

[1] https://lwn.net/Articles/82305/

Kees Cook (3):
media: dvb-usb-v2: lmedm04: Fix firmware macro definitions
media: radio: si470x: Fix DRIVER_AUTHOR macro definition
module: Add compile-time check for embedded NUL characters

 include/linux/moduleparam.h                   |  3 +++
 drivers/media/radio/si470x/radio-si470x-i2c.c |  2 +-
 drivers/media/usb/dvb-usb-v2/lmedm04.c        | 12 ++++++------
 3 files changed, 10 insertions(+), 7 deletions(-)
Quoted 8 lines
Quoted 5 lines

I have also tested a build of v6.18-rc3 + patches using allmodconfig:

Folks, are you aware that this change blown up the sparse? Now there is a "bad constant expression" to each MODULE_*() macro line.

Thanks for the heads up.

I can see this thread:

https://lore.kernel.org/all/[email protected]/#t

And this:

https://lore.kernel.org/linux-sparse/CACePvbVG2KrGQq4cNKV=wbO5h=jp3M0RO1SdfX8kV4OukjPG8A@mail.gmail.com/T/#t

Quoted 4 lines

Nice that Uwe is in the Cc list, so IIRC he is Debian maintainer for sparse and perhaps has an influence to it to some extent.

Would it be better approach to postpone patch 3 from Kent until sparse is fixed?

#37 lore raw
In reply to Andy Shevchenko

Helo Andy,

Quoted 5 lines · Andy Shevchenko

Folks, are you aware that this change blown up the sparse? Now there is a "bad constant expression" to each MODULE_*() macro line.

Nice that Uwe is in the Cc list, so IIRC he is Debian maintainer for sparse and perhaps has an influence to it to some extent.

To be honest, in the nearer past I'm very passive on the sparse maintainer side and even stopped using it as it fails on guard locking.

My impression is also that upstream isn't very active any more, but that might have been temporal and wrong as I stopped looking.

If there is an outcome and a patch to cherry-pick into the Debian packaging, give me a ping.

Uwe

Applied
#38 lore raw
In reply to Kees Cook
Quoted 8 lines · Kees Cook

v2:
- use static_assert instead of _Static_assert
- add Hans's Reviewed-by's
v1: https://lore.kernel.org/lkml/[email protected]/

Hi!

[...]

Applied, thanks!

[1/3] media: dvb-usb-v2: lmedm04: Fix firmware macro definitions
(no commit info)
[2/3] media: radio: si470x: Fix DRIVER_AUTHOR macro definition
(no commit info)
[3/3] module: Add compile-time check for embedded NUL characters
(no commit info)

Best regards,

Signature · 1 line
Daniel Gomez <[email protected]>