Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1739379

Re: [PATCH 3/3] driver core: platform: Don't read past the end of "driver_override" buffer

From Bjorn Helgaas <helgaas@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 3/3] driver core: platform: Don't read past the end of "driver_override" buffer
Date 2017-09-26 02:00 +0200
Message-ID <utLs6-51O-9@gated-at.bofh.it> (permalink)
References <uorDH-8jW-1@gated-at.bofh.it> <uorDJ-8jW-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Greg, I assume you'll deal with this one?  Just let me know if I
should do something with it.

On Mon, Sep 11, 2017 at 09:45:42AM +0200, Nicolai Stange wrote:
> When printing the driver_override parameter when it is 4095 and 4094 bytes
> long, the printing code would access invalid memory because we need count+1
> bytes for printing.
> 
> Reject driver_override values of these lengths in driver_override_store().
> 
> This is in close analogy to commit 4efe874aace5 ("PCI: Don't read past the
> end of sysfs "driver_override" buffer") from Sasha Levin.
> 
> Fixes: 3d713e0e382e ("driver core: platform: add device binding path 'driver_override'")
> Cc: stable@vger.kernel.org	# v3.17+
> Signed-off-by: Nicolai Stange <nstange@suse.de>
> ---
>  drivers/base/platform.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index d1bd99271066..9045c5f3734e 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -868,7 +868,8 @@ static ssize_t driver_override_store(struct device *dev,
>  	struct platform_device *pdev = to_platform_device(dev);
>  	char *driver_override, *old, *cp;
>  
> -	if (count > PATH_MAX)
> +	/* We need to keep extra room for a newline */
> +	if (count >= (PAGE_SIZE - 1))
>  		return -EINVAL;
>  
>  	driver_override = kstrndup(buf, count, GFP_KERNEL);
> -- 
> 2.13.5
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] make PCI's and platform's driver_override_store()/show() converge Nicolai Stange <nstange@suse.de> - 2017-09-11 09:50 +0200
  [PATCH 1/3] PCI: fix race condition with driver_override Nicolai Stange <nstange@suse.de> - 2017-09-11 09:50 +0200
    Re: [PATCH 1/3] PCI: fix race condition with driver_override Bjorn Helgaas <helgaas@kernel.org> - 2017-09-26 01:50 +0200
  [PATCH 3/3] driver core: platform: Don't read past the end of "driver_override" buffer Nicolai Stange <nstange@suse.de> - 2017-09-11 09:50 +0200
    Re: [PATCH 3/3] driver core: platform: Don't read past the end of  "driver_override" buffer Bjorn Helgaas <helgaas@kernel.org> - 2017-09-26 02:00 +0200
      Re: [PATCH 3/3] driver core: platform: Don't read past the end of  "driver_override" buffer Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-26 09:00 +0200
  [PATCH 2/3] PCI: don't use snprintf() in driver_override_show() Nicolai Stange <nstange@suse.de> - 2017-09-11 09:50 +0200
    Re: [PATCH 2/3] PCI: don't use snprintf() in driver_override_show() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-11 14:00 +0200
      Re: [PATCH 2/3] PCI: don't use snprintf() in driver_override_show() Bjorn Helgaas <helgaas@kernel.org> - 2017-09-26 01:50 +0200
        Re: [PATCH 2/3] PCI: don't use snprintf() in driver_override_show() Nicolai Stange <nstange@suse.de> - 2017-09-26 08:40 +0200

csiph-web