[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d151a09a-6bbf-93d6-a7fe-b0cc6769a851@huawei.com>
Date: Fri, 15 Feb 2019 18:33:30 +0800
From: Gao Xiang <gaoxiang25@...wei.com>
To: Dan Carpenter <dan.carpenter@...cle.com>
CC: Chao Yu <yuchao0@...wei.com>, <devel@...verdev.osuosl.org>,
"Greg Kroah-Hartman" <gregkh@...uxfoundation.org>,
Chao Yu <chao@...nel.org>, <linux-erofs@...ts.ozlabs.org>,
LKML <linux-kernel@...r.kernel.org>, <stable@...r.kernel.org>,
<weidu.du@...wei.com>, Al Viro <viro@...IV.linux.org.uk>,
Miao Xie <miaoxie@...wei.com>, Fang Wei <fangwei1@...wei.com>
Subject: Re: [PATCH v2] staging: erofs: keep corrupted fs from crashing kernel
in erofs_namei()
Hi Dan,
On 2019/2/15 17:35, Dan Carpenter wrote:
> On Fri, Feb 15, 2019 at 05:32:33PM +0800, Chao Yu wrote:
>> On 2019/2/15 15:57, Dan Carpenter wrote:
>>> On Fri, Feb 15, 2019 at 03:02:25PM +0800, Chao Yu wrote:
>>>> On 2019/2/1 20:16, Gao Xiang wrote:
>>>>> + /*
>>>>> + * on-disk error, let's only BUG_ON in the debugging mode.
>>>>> + * otherwise, it will return 1 to just skip the invalid name
>>>>> + * and go on (in consideration of the lookup performance).
>>>>> + */
>>>>> + DBG_BUGON(qd->name > qd->end);
>>>>
>>>> qd->name == qd->end is not allowed as well?
>>>>
>>>> So will it be better to return directly here?
>>>>
>>>> if (unlikely(qd->name >= qd->end)) {
>>>> DBG_BUGON(1);
>>>> return 1;
>>>> }
>>>
>>> Please don't add likely/unlikely() annotations unless you have
>>> benchmarked it and it makes a difference.
>>
>> Well, it only occur for corrupted image, since the image is readonly, so it
>> is really rare.
>
> The likely/unlikely() annotations make the code harder to read. It's
> only worth it if it's is a speedup on a fast path.
Yes, I think abuse of using likely/unlikely() should be avoided (I agree that
some odd likely/unlikely() exists in the current code, that should be cleaned up).
However, likely/unlikely()s are also clearly highlight critical/corner paths).
I personally think it should be used in case-by-case basis rather than a unified
conclusion ("that makes the code harder to read").
Thanks,
Gao Xiang
>
> regards,
> dan carpenter
>
> _______________________________________________
> devel mailing list
> devel@...uxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
>
Powered by blists - more mailing lists