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: <a7f51d49-cb6a-4066-a58f-2505e29f25e8@p183>
Date:   Sat, 22 Apr 2023 12:45:14 +0300
From:   Alexey Dobriyan <adobriyan@...il.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ELF: use __builtin_mul_overflow() more

On Fri, Apr 21, 2023 at 12:39:11PM -0700, Andrew Morton wrote:
> On Fri, 21 Apr 2023 21:54:36 +0300 Alexey Dobriyan <adobriyan@...il.com> wrote:
> 
> > __builtin_mul_overflow() can do multiplication and overflow check
> > in one line.
> > 
> > --- a/fs/binfmt_elf.c
> > +++ b/fs/binfmt_elf.c
> > @@ -1651,9 +1651,8 @@ static int fill_files_note(struct memelfnote *note, struct coredump_params *cprm
> >  
> >  	/* *Estimated* file count and total data size needed */
> >  	count = cprm->vma_count;
> > -	if (count > UINT_MAX / 64)
> > +	if (__builtin_mul_overflow(count, 64, &size))
> >  		return -EINVAL;
> > -	size = count * 64;
> 
> Huh, what the heck is that ;)
> 
> 
> include/linux/overflow.h has check_mul_overflow() for us to use here.

Oh, no, wrappers.

> tools/lib/bpf/libbpf_internal.h uses
> 
> 	#if __has_builtin(__builtin_mul_overflow)
> 
> but check_mul_overflow() didn't bother testing for availability. 

gcc 5.1 has __builtin_mul_overflow()

> Probably tools/lib/bpf/libbpf_internal.h should just use
> check_mul_overflow().

I don't know, this is userspace stuff.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ