Re: [PATCH 1/2] lightnvm: potential underflow in pblk_read_rq()

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

 



> On 21 Apr 2017, at 22.53, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> 
> This is a static checker fix, and perhaps not a real bug.  The static
> checker thinks that nr_secs could be negative.  It would result in
> zeroing more memory than intended.  Anyway, even if it's not a bug,
> changing this variable to unsigned makes the code easier to audit.
> 
> Fixes: a4bd217b4326 ("lightnvm: physical block device (pblk) target")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> 
> diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c
> index bce7ed5fc73f..c9daa33e8d9c 100644
> --- a/drivers/lightnvm/pblk-read.c
> +++ b/drivers/lightnvm/pblk-read.c
> @@ -288,7 +288,7 @@ static void pblk_read_rq(struct pblk *pblk, struct nvm_rq *rqd,
> int pblk_submit_read(struct pblk *pblk, struct bio *bio)
> {
> 	struct nvm_tgt_dev *dev = pblk->dev;
> -	int nr_secs = pblk_get_secs(bio);
> +	unsigned int nr_secs = pblk_get_secs(bio);
> 	struct nvm_rq *rqd;
> 	unsigned long read_bitmap; /* Max 64 ppas per request */
> 	unsigned int bio_init_idx;

Thanks Dan. While you are at it, can you also modify the type on the
other 2 calls to pblk_get_secs in pblk-cache and pblk-core?

Otherwise, it is a good catch.

Reviewed-by: Javier González <javier@xxxxxxxxxxxx>

Javier

Attachment: signature.asc
Description: Message signed with OpenPGP


[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