Re: [PATCH] block: add a BUILD_BUG_ON() for adding more bio flags than we have space

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

 



On 1/10/23 02:47, Jens Axboe wrote:
> We have BIO_FLAG_LAST in the enum for bio specific flags, but it's
> not used to check that we're not exceeding the size of them. Add
> such a check.
> 
> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
> 
> ---
> 
> diff --git a/block/bio.c b/block/bio.c
> index 5f96fcae3f75..633d1a2af785 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -1785,6 +1785,8 @@ static int __init init_bio(void)
>  {
>  	int i;
>  
> +	BUILD_BUG_ON(BIO_FLAG_LAST > 8 * sizeof_field(struct bio, bi_flags));
> +
>  	bio_integrity_init();
>  
>  	for (i = 0; i < ARRAY_SIZE(bvec_slabs); i++) {
> 

Looks OK to me.

Reviewed-by: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx>

-- 
Damien Le Moal
Western Digital Research




[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