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]
Date:   Thu, 19 May 2022 10:30:40 +0800
From:   "linyujun (C)" <linyujun809@...wei.com>
To:     "Gustavo A. R. Silva" <gustavoars@...nel.org>
CC:     <peterz@...radead.org>, <mingo@...hat.com>, <acme@...nel.org>,
        <mark.rutland@....com>, <alexander.shishkin@...ux.intel.com>,
        <jolsa@...nel.org>, <namhyung@...nel.org>, <tglx@...utronix.de>,
        <bp@...en8.de>, <dave.hansen@...ux.intel.com>, <x86@...nel.org>,
        <hpa@...or.com>, <linux-perf-users@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <johnny.chenyi@...wei.com>,
        <chenjiahao16@...wei.com>, <chenlifu@...wei.com>,
        <lizhengyu3@...wei.com>, <liaochang1@...wei.com>,
        <wangzhu9@...wei.com>, <xuyihang@...wei.com>,
        <chris.zjh@...wei.com>, <zouyipeng@...wei.com>
Subject: Re: [PATCH -next] x86/events:Use struct_size() helper in kzalloc()

Thank you for your suggestion. I will modify the patch according
to your suggestion and make the v2 version.

Thanks
--
LinYujun

在 2022/5/18 21:49, Gustavo A. R. Silva 写道:
> On Wed, May 18, 2022 at 09:16:26PM +0800, Lin Yujun wrote:
>> Replace sizeof() with struct_size() to avoid potential integer
>> or heap overflow.
> This is not exactly what the patch does.
>
> Your patch is replacing the open-coded calculation of the total amount
> of memory to be allocated for rapl_pmus with struct_size().
>
>> Also, address the following sparse warnings:
>> arch/x86/events/rapl.c:685:16: warning: using sizeof on a
>> flexible structure
> This does not address this warning because struct_size()
> still make use of sizeof on the struct-with-flex-array,
> internally.
>
> So, the mention to the sparse warning should be removed from
> this changelog text.
>
>> Signed-off-by: Lin Yujun <linyujun809@...wei.com>
>> ---
>>   arch/x86/events/rapl.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c
>> index 77e3a47af5ad..c7e79f0ac04f 100644
>> --- a/arch/x86/events/rapl.c
>> +++ b/arch/x86/events/rapl.c
>> @@ -685,7 +685,7 @@ static int __init init_rapl_pmus(void)
>>   	int maxdie = topology_max_packages() * topology_max_die_per_package();
>>   	size_t size;
>>   
>> -	size = sizeof(*rapl_pmus) + maxdie * sizeof(struct rapl_pmu *);
>> +	size = struct_size(rapl_pmus, pmus, maxdie);
>>   	rapl_pmus = kzalloc(size, GFP_KERNEL);
> It seems that in this case, size could be entirely replaced by
> struct_size().
>
> Thanks
> --
> Gustavo
> .

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ