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]
Message-ID: <40d3505b-e27f-b294-582d-b0926a27419e@huawei.com>
Date:   Thu, 20 Jul 2023 16:44:01 +0800
From:   Miaohe Lin <linmiaohe@...wei.com>
To:     Naoya Horiguchi <naoya.horiguchi@...ux.dev>
CC:     <akpm@...ux-foundation.org>, <naoya.horiguchi@....com>,
        <shy828301@...il.com>, <linux-mm@...ck.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/4] mm: memory-failure: fix potential unexpected return
 value from unpoison_memory()

On 2023/7/20 7:48, Naoya Horiguchi wrote:
> On Sat, Jul 15, 2023 at 11:17:27AM +0800, Miaohe Lin wrote:
>> If unpoison_memory() fails to clear page hwpoisoned flag, return value
>> ret is expected to be -EBUSY. But when get_hwpoison_page() returns 1
>> and fails to clear page hwpoisoned flag due to races, return value will
>> be unexpected 1 leading to users being confused.
> 
> Thank you for fixing this.
> 
>>
>> Fixes: bf181c582588 ("mm/hwpoison: fix unpoison_memory()")
>> Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
>> ---
>>  mm/memory-failure.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index 9ab97016877e..ac074f82f5b3 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -2546,11 +2546,11 @@ int unpoison_memory(unsigned long pfn)
>>  			unpoison_pr_info("Unpoison: failed to grab page %#lx\n",
>>  					 pfn, &unpoison_rs);
>>  	} else {
>> +		ret = -EBUSY;
> 
> It seems be a code smell to me that the variable "ret" is used not only to
> save the return value of unpoison_memory(), but also to save the return
> value from get_hwpoison_page(). So I think that it might be better to use
> another auto-variable solely to save the return value of get_hwpoison_page.
> Then ret has the initial value -EBUSY at this point and no need to
> reinitialize it.
> 

This should be a nice improvement. Will do it in v2.

Thanks Naoya.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ