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: Sun, 16 Jun 2024 18:22:43 +0800
From: quic_zijuhu <quic_zijuhu@...cinc.com>
To: Greg KH <gregkh@...uxfoundation.org>
CC: <rafael@...nel.org>, <andriy.shevchenko@...ux.intel.com>, <brgl@...ev.pl>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1] devres: Fix devm_krealloc() allocating memory with
 wrong size

On 6/16/2024 6:17 PM, Greg KH wrote:
> On Sun, Jun 16, 2024 at 06:10:02PM +0800, quic_zijuhu wrote:
>> On 6/16/2024 6:02 PM, Greg KH wrote:
>>> On Sun, Jun 16, 2024 at 05:54:15PM +0800, Zijun Hu wrote:
>>>> Kernel API devm_krealloc() calls alloc_dr() with wrong argument
>>>> @total_new_size, and it will cause more memory to be allocated
>>>> than required, fixed by using @new_size as alloc_dr()'s argument.
>>>>
>>>> Fixes: f82485722e5d ("devres: provide devm_krealloc()")
>>>> Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>
>>>> ---
>>>>  drivers/base/devres.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
>>>> index 3df0025d12aa..1cf87ddf1f55 100644
>>>> --- a/drivers/base/devres.c
>>>> +++ b/drivers/base/devres.c
>>>> @@ -898,7 +898,7 @@ void *devm_krealloc(struct device *dev, void *ptr, size_t new_size, gfp_t gfp)
>>>>  	 * taking the lock as most probably the caller uses GFP_KERNEL.
>>>>  	 */
>>>>  	new_dr = alloc_dr(devm_kmalloc_release,
>>>> -			  total_new_size, gfp, dev_to_node(dev));
>>>> +			  new_size, gfp, dev_to_node(dev));
>>>
>>> Wait, are you sure?  Did you properly test this?  What is the actual
>>> savings and how do you handle the fact that you are now not allocating
>>> the space reserved for the devres structure itself?
>>>
>> sure even if i did not test it.
>> beware that alloc_dr() will call check_dr_size() to reserve space for
>> devres structure.
>>
>> it will reserve the devres structure two times if using wrong
>> @total_new_size. it is obvious wrong.
> 
> Ah, I missed that, that is tricky.  Please document this better when you
> resubmit a new version.
> 
okay. will send v2.
> And of course, please test it.
okay.
> 
> thanks,
> 
> greg k-h


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ