Re: [PATCH v2] staging: erofs: keep corrupted fs from crashing kernel in erofs_namei()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 18, 2019 at 10:41:36AM +0800, Chao Yu wrote:
> 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
> 
> Well, I think unlikely here can imply this is a rare case which may help to
> read...
> 
> > only worth it if it's is a speedup on a fast path.
> 
> I guess unlikely here can help pipeline to load/execute right branch codes
> instead of that rare branch one with BUGON(), is that right?
> 

Correct.  If you really think the likely/unlikely on this line will lead
to a performance improvement which will show up on a benchmark then you
should use it.  (But there is no way that it really show on benchmarks,
let's not pretend).

If it doesn't show up on benchmarking, then we're just discussing style.
Kernel style tends to be minimalist.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux