Re: [PATCH] block/keyslot-manager: prevent crash when num_slots=1

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

 



On Wed, Nov 11, 2020 at 11:25:39AM -0800, Eric Biggers wrote:
> On Wed, Nov 11, 2020 at 09:45:38AM +0000, Satya Tangirala wrote:
> > On Wed, Nov 11, 2020 at 09:23:05AM +0000, Christoph Hellwig wrote:
> > > On Tue, Nov 10, 2020 at 06:14:27PM -0800, Eric Biggers wrote:
> > > > +	 * hash_ptr() assumes bits != 0, so ensure the hash table has at least 2
> > > > +	 * buckets.  This only makes a difference when there is only 1 keyslot.
> > > > +	 */
> > > > +	slot_hashtable_size = max(slot_hashtable_size, 2U);
> > > 
> > > shouldn't this be a min()?
> > I think it should be max(), since we want whichever is larger between 2
> > and the original slot_hashtable_size :)
> 
> max() is correct.  I could just open-code it, if that would make it clearer:
> 
> 	/*
> 	 * hash_ptr() assumes bits != 0, so ensure the hash table has at least 2
> 	 * buckets.  This only makes a difference when there is only 1 keyslot.
> 	 */
> 	if (slot_hashtable_size < 2)
> 		slot_hashtable_size = 2;

I sent out v2 with the above.

- Eric



[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