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] [thread-next>] [day] [month] [year] [list]
Date: Mon, 6 May 2024 19:31:36 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Edward Liaw' <edliaw@...gle.com>, Justin Stitt <justinstitt@...gle.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Shuah Khan
	<shuah@...nel.org>, Nathan Chancellor <nathan@...nel.org>, Nick Desaulniers
	<ndesaulniers@...gle.com>, Bill Wendling <morbo@...gle.com>, "H. Peter Anvin"
	<hpa@...ux.intel.com>, Andy Lutomirski <luto@....edu>,
	"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
	"kernel-team@...roid.com" <kernel-team@...roid.com>, "llvm@...ts.linux.dev"
	<llvm@...ts.linux.dev>
Subject: RE: [PATCH v3] selftests/vDSO: Explicit unsigned char conversion for
 elf_hash

From: Edward Liaw
> Sent: 06 May 2024 18:34
> 
> On Mon, May 6, 2024 at 10:16 AM Justin Stitt <justinstitt@...gle.com> wrote:
> >
> > On Sun, May 5, 2024 at 6:21 AM David Laight <David.Laight@...lab.com> wrote:
> > >
> > > From: Justin Stitt
> > > > Sent: 01 May 2024 20:55
> > > ...
> > > > > static unsigned long elf_hash(const unsigned char *name)
> > > ...
> > > > Is it possible to just change the types of the parameters of vdso_sym()
> > > > or does that trigger even more warnings on the callsites of vdso_sym()?
> > >
> > > Isn't the problem the definition of elf_hash()?
> > > A '\0' terminated string really ought to be 'char *' not 'unsigned char *'.
> >
> > Right, although note this comment just about its definition:
> >
> > /* Straight from the ELF specification. */
> > static unsigned long elf_hash(const unsigned char *name)
> > {
> >
> > which indeed matches [1]
> >
> > [1]: https://man.freebsd.org/cgi/man.cgi?query=elf_hash&sektion=3&apropos=0&manpath=FreeBSD+7.1-
> RELEASE
> 
> How about I move the type cast into elf_hash, like libelf does
> https://sourceforge.net/p/elftoolchain/code/HEAD/tree/trunk/libelf/elf_hash.c#l47
> 
> diff --git a/tools/testing/selftests/vDSO/parse_vdso.c
> b/tools/testing/selftests/vDSO/parse_vdso.c
> index 413f75620a35..33db8abd7d59 100644
> --- a/tools/testing/selftests/vDSO/parse_vdso.c
> +++ b/tools/testing/selftests/vDSO/parse_vdso.c
> @@ -56,12 +56,15 @@ static struct vdso_info
>  } vdso_info;
> 
>  /* Straight from the ELF specification. */
> -static unsigned long elf_hash(const unsigned char *name)
> +static unsigned long elf_hash(const char *name)
>  {
>   unsigned long h = 0, g;
> - while (*name)
> + const unsigned char *s;
> +
> + s = (const unsigned char *) name;
> + while (*s)
>   {
> - h = (h << 4) + *name++;
> + h = (h << 4) + *s++;
>   if (g = h & 0xf0000000)
>   h ^= g >> 24;
>   h &= ~g;

That makes a lot more sense.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ