Re: [PATCH V2 02/20] sbitmap: introduce __sbitmap_for_each_set()

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

 



On Thu, 2017-08-24 at 11:57 +0800, Ming Lei wrote:
> On Tue, Aug 22, 2017 at 06:28:54PM +0000, Bart Van Assche wrote:
> > * Whether or not index >= sb->map_nr. I propose to start iterating from the
> >   start of @sb in this case.
> 
> It has been checked at the end of the loop.

That's not sufficient to avoid an out-of-bounds access if the start index is
large. If __sbitmap_for_each_set() would accept values for the start index
argument that result in index >= sb->map_nr then that will simplify code that
accesses an sbitmap in a round-robin fashion.

> > 	}
> > 
> > 	while (true) {
> > 		struct sbitmap_word *word = &sb->map[i];
> > 		unsigned int off;
> 
> Looks you removed the check on 'word->word'.

Yes, and I did that on purpose. If the start index refers to a word that is
zero then the "if (word->word) continue;" code will cause the end-of-loop
check to be skipped and hence will cause an infinite loop.

Bart.




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux