lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK7LNASBgpThWFN0dbPL5TfhoZTky2SXrGbJyMo_iUXzC2Ha4A@mail.gmail.com>
Date: Sat, 11 Jan 2025 02:34:36 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: David Laight <david.laight.linux@...il.com>
Cc: linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 6/6] genksyms: use uint32_t instead of unsigned long for
 calculating CRC

On Fri, Jan 3, 2025 at 5:34 PM David Laight
<david.laight.linux@...il.com> wrote:
>
> On Fri,  3 Jan 2025 16:30:43 +0900
> Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> > Currently, 'unsigned long' is used for intermediate variables when
> > calculating CRCs.
> >
> > The size of 'long' differs depending on the architecture: it is 32 bits
> > on 32-bit architectures and 64 bits on 64-bit architectures.
> >
> > The CRC values generated by genksyms represent the compatibility of
> > exported symbols. Therefore, reproducibility is important. In other
> > words, we need to ensure that the output is the same when the kernel
> > source is identical, regardless of whether genksyms is running on a
> > 32-bit or 64-bit build machine.
> >
> > Fortunately, the output from genksyms is not affected by the build
> > machine's architecture because only the lower 32 bits of the
> > 'unsigned long' variables are used.
> >
> > To make it even clearer that the CRC calculation is independent of
> > the build machine's architecture, this commit explicitly uses the
> > fixed-width type, uint32_t.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
> > ---
> >
> >  scripts/genksyms/genksyms.c | 15 ++++++++-------
> >  1 file changed, 8 insertions(+), 7 deletions(-)
> >
> > diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
> > index e2cd3dcb469f..8b0d7ac73dbb 100644
> > --- a/scripts/genksyms/genksyms.c
> > +++ b/scripts/genksyms/genksyms.c
> >...
> > -     printf("#SYMVER %s 0x%08lx\n", name, crc);
> > +     printf("#SYMVER %s 0x%08lx\n", name, (unsigned long)crc);
>
> That should use PRIu32, but the whole patch could just use 'unsigned int'.
> No one is going to try to build this where 'int' is 16bit.
> All the hex constants assume that int is 32bits as well.


The point is, uint32_t is the clearest way to ensure
the variables are fixed width.

Casting to (unsigned long) vs PRIu32 is
just a matter of preference.




-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ