Re: [PATCH] lightnvm: fix up nonsensical configure overrun checking

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

 



On 02/17/2016 03:06 PM, Alan wrote:
> Instead of checking a constant 0 actually check the space available. Even
> better remember to allow for the header and also check the right amount of
> space is needed.
> 
> Signed-off-by: Alan Cox <alan@xxxxxxxxxxxxxxx>
> ---
>  drivers/lightnvm/core.c |   11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index 33224cb..782ac5d 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -870,20 +870,19 @@ static int nvm_configure_by_str_event(const char *val,
>  
>  static int nvm_configure_get(char *buf, const struct kernel_param *kp)
>  {
> -	int sz = 0;
> -	char *buf_start = buf;
> +	int sz;
>  	struct nvm_dev *dev;
>  
> -	buf += sprintf(buf, "available devices:\n");
> +	sz = sprintf(buf, "available devices:\n");
>  	down_write(&nvm_lock);
>  	list_for_each_entry(dev, &nvm_devices, devices) {
> -		if (sz > 4095 - DISK_NAME_LEN)
> +		if (sz > 4095 - DISK_NAME_LEN - 2)
>  			break;
> -		buf += sprintf(buf, " %32s\n", dev->name);
> +		sz += sprintf(buf + sz, " %32s\n", dev->name);
>  	}
>  	up_write(&nvm_lock);
>  
> -	return buf - buf_start - 1;
> +	return sz;
>  }
>  
>  static const struct kernel_param_ops nvm_configure_by_str_event_param_ops = {
> 

Thanks Alan, applied.

-Matias
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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