stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang <gaoxiang25@huawei.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Chao Yu <yuchao0@huawei.com>, <devel@driverdev.osuosl.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	Chao Yu <chao@kernel.org>, <linux-erofs@lists.ozlabs.org>,
	LKML <linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>,
	<weidu.du@huawei.com>, Al Viro <viro@ZenIV.linux.org.uk>,
	Miao Xie <miaoxie@huawei.com>, Fang Wei <fangwei1@huawei.com>
Subject: Re: [PATCH v2] staging: erofs: keep corrupted fs from crashing kernel in erofs_namei()
Date: Fri, 15 Feb 2019 18:33:30 +0800	[thread overview]
Message-ID: <d151a09a-6bbf-93d6-a7fe-b0cc6769a851@huawei.com> (raw)
In-Reply-To: <20190215093503.GH2326@kadam>

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@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 

  reply	other threads:[~2019-02-15 10:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 12:16 [PATCH v2] staging: erofs: keep corrupted fs from crashing kernel in erofs_namei() Gao Xiang
2019-02-12  5:05 ` Gao Xiang
2019-02-15  7:02 ` Chao Yu
2019-02-15  7:57   ` Dan Carpenter
2019-02-15  9:04     ` Gao Xiang
2019-02-15  9:32     ` Chao Yu
2019-02-15  9:35       ` Dan Carpenter
2019-02-15 10:33         ` Gao Xiang [this message]
2019-02-18  2:41         ` Chao Yu
2019-02-18  6:16           ` Dan Carpenter
2019-02-15  8:58   ` Gao Xiang
2019-02-18  1:39     ` Chao Yu
2019-02-18  2:17       ` Gao Xiang
2019-02-18  2:50         ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d151a09a-6bbf-93d6-a7fe-b0cc6769a851@huawei.com \
    --to=gaoxiang25@huawei.com \
    --cc=chao@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=fangwei1@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=stable@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=weidu.du@huawei.com \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).