Skip to contentSkip to conversation

modpost: Fix processing of CRCs on 32-bit build machines

PATCH In review Ben Hutchings 2 participants 2 messages Mar 22, 2023 – Mar 23, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modpost: Fix processing of CRCs on 32-bit build machines

modpost now reads CRCs from .*.cmd files, parsing them using strtol(). This is inconsistent with its parsing of Module.symvers and with their definition as *unsigned* 32-bit values.

strtol() clamps values to [LONG_MIN, LONG_MAX], and when building on a 32-bit system this changes all CRCs >= 0x80000000 to be 0x7fffffff.

Change extract_crcs_for_object() to use strtoul() instead.

Fixes f292d875d0dc ("modpost: extract symbol versions from *.cmd files")
---
 scripts/mod/modpost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
index efff8078e395..9466b6a2abae 100644
@@ -1733,7 +1733,7 @@ static void extract_crcs_for_object(const char *object, struct module *mod)
 		if (!isdigit(*p))
 			continue;	/* skip this line */
 
-		crc = strtol(p, &p, 0);
+		crc = strtoul(p, &p, 0);
 		if (*p != '\n')
 			continue;	/* skip this line */
 
#1 lore raw
Quoted 8 lines · Ben Hutchings

modpost now reads CRCs from .*.cmd files, parsing them using strtol(). This is inconsistent with its parsing of Module.symvers and with their definition as *unsigned* 32-bit values.

strtol() clamps values to [LONG_MIN, LONG_MAX], and when building on a 32-bit system this changes all CRCs >= 0x80000000 to be 0x7fffffff.

Quoted 6 lines

Change extract_crcs_for_object() to use strtoul() instead.

Fixes f292d875d0dc ("modpost: extract symbol versions from *.cmd files")

---

Applied to linux-kbuild/fixes.
Thanks.

Quoted 16 lines
 scripts/mod/modpost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
index efff8078e395..9466b6a2abae 100644
@@ -1733,7 +1733,7 @@ static void extract_crcs_for_object(const char *object, struct module *mod)
                if (!isdigit(*p))
                        continue;       /* skip this line */
 
-               crc = strtol(p, &p, 0);
+               crc = strtoul(p, &p, 0);
                if (*p != '\n')
                        continue;       /* skip this line */
 
Signature · 2 lines
Best Regards
Masahiro Yamada