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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <abc66ec5-85a4-47e1-9759-2f60ab111971@vivo.com>
Date: Thu, 14 Aug 2025 12:05:17 +0800
From: Qianfeng Rong <rongqianfeng@...o.com>
To: Paul Menzel <pmenzel@...gen.mpg.de>
Cc: Tony Nguyen <anthony.l.nguyen@...el.com>,
 Przemek Kitszel <przemyslaw.kitszel@...el.com>,
 Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
 <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
 Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
 Jesper Dangaard Brouer <hawk@...nel.org>,
 John Fastabend <john.fastabend@...il.com>,
 Stanislav Fomichev <sdf@...ichev.me>, intel-wired-lan@...ts.osuosl.org,
 netdev@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
 bpf@...r.kernel.org
Subject: Re: [Intel-wired-lan] [PATCH 1/5] ethtool: use vmalloc_array() to
 simplify code


在 2025/8/13 0:34, Paul Menzel 写道:
> [You don't often get email from pmenzel@...gen.mpg.de. Learn why this 
> is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Dear Qianfeng,
>
>
> Thank you for your patch.
>
> Am 12.08.25 um 15:32 schrieb Qianfeng Rong:
>> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
>> simplify the code and maintain consistency with existing kmalloc_array()
>> usage.
>
> You could build it without and with your patch and look if the assembler
> code changes.
>

Very good point, the following experiment was done:
//before apply patch:
objdump -dSl --prefix-addresses fm10k_ethtool.o > original.dis

//after apply patch:
objdump -dSl --prefix-addresses fm10k_ethtool.o > patched.dis

diff -u original.dis patched.dis | diffstat
patched.dis | 1578 ... 1 file changed, 785 insertions(+), 793 deletions(-)

 From the above results, we can see that the assembly instructions are
reduced after applying the patch.


#define array_size(a, b)    size_mul(a, b)

static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
{
     size_t bytes;

     if (check_mul_overflow(factor1, factor2, &bytes))
         return SIZE_MAX;

     return bytes;
}

void *__vmalloc_array_noprof(size_t n, size_t size, gfp_t flags)
{
     size_t bytes;

     if (unlikely(check_mul_overflow(n, size, &bytes)))
         return NULL;
     return __vmalloc_noprof(bytes, flags);
}

And from the code, array_size() will return SIZE_MAX after detecting
overflow.  SIZE_MAX is passed to vmalloc for available memory
verification before exiting and returning NULL. vmalloc_array()
will directly return NULL after detecting overflow.

Best regards,
Qianfeng
> Reviewed-by: Paul Menzel <pmenzel@...gen.mpg.de>
>
>
> Kind regards,
>
> Paul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ