diff mbox series

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

Message ID ZBtE4XlqCXjFELHR@decadent.org.uk (mailing list archive)
State New, archived
Headers show
Series modpost: Fix processing of CRCs on 32-bit build machines | expand

Commit Message

Ben Hutchings March 22, 2023, 6:11 p.m. UTC
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.

Cc: stable@vger.kernel.org
Fixes: f292d875d0dc ("modpost: extract symbol versions from *.cmd files")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 scripts/mod/modpost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Masahiro Yamada March 23, 2023, 6:20 a.m. UTC | #1
On Thu, Mar 23, 2023 at 3:11 AM Ben Hutchings <ben@decadent.org.uk> wrote:
>
> 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.
>
> Cc: stable@vger.kernel.org
> Fixes: f292d875d0dc ("modpost: extract symbol versions from *.cmd files")
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---


Applied to linux-kbuild/fixes.
Thanks.


>  scripts/mod/modpost.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index efff8078e395..9466b6a2abae 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -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 */
>
diff mbox series

Patch

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index efff8078e395..9466b6a2abae 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -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 */