lkml.org 
[lkml]   [2017]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3.18 25/32] driver core: platform: Dont read past the end of "driver_override" buffer
    Date
    3.18-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Nicolai Stange <nstange@suse.de>

    commit bf563b01c2895a4bfd1a29cc5abc67fe706ecffd upstream.

    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'")
    Signed-off-by: Nicolai Stange <nstange@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/base/platform.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    --- a/drivers/base/platform.c
    +++ b/drivers/base/platform.c
    @@ -729,7 +729,8 @@ static ssize_t driver_override_store(str
    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);

    \
     
     \ /
      Last update: 2017-10-10 23:19    [W:4.041 / U:0.084 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site