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


Groups > linux.kernel > #1580973 > unrolled thread

[PATCH] staging: fbtft: Fix buffer overflow vulnerability

Started by"Tobin C. Harding" <me@tobin.cc>
First post2017-02-15 01:50 +0100
Last post2017-02-15 02:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] staging: fbtft: Fix buffer overflow vulnerability "Tobin C. Harding" <me@tobin.cc> - 2017-02-15 01:50 +0100
    Re: [PATCH] staging: fbtft: Fix buffer overflow vulnerability Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-15 02:10 +0100

#1580973 — [PATCH] staging: fbtft: Fix buffer overflow vulnerability

From"Tobin C. Harding" <me@tobin.cc>
Date2017-02-15 01:50 +0100
Subject[PATCH] staging: fbtft: Fix buffer overflow vulnerability
Message-ID<taVXb-Ae-1@gated-at.bofh.it>
Module copies a user supplied string (module parameter) into a buffer
using strncpy() and does not check that the buffer is null terminated.

Replace call to strncpy() with call to strlcpy() ensuring that the
buffer is null terminated.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/fbtft/fbtft_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c
index de46f8d..7b7223b 100644
--- a/drivers/staging/fbtft/fbtft_device.c
+++ b/drivers/staging/fbtft/fbtft_device.c
@@ -1483,7 +1483,7 @@ static int __init fbtft_device_init(void)
 			displays[i].pdev->name = name;
 			displays[i].spi = NULL;
 		} else {
-			strncpy(displays[i].spi->modalias, name, SPI_NAME_SIZE);
+			strlcpy(displays[i].spi->modalias, name, SPI_NAME_SIZE);
 			displays[i].pdev = NULL;
 		}
 	}
-- 
2.7.4

[toc] | [next] | [standalone]


#1580979

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-02-15 02:10 +0100
Message-ID<taWgx-XP-1@gated-at.bofh.it>
In reply to#1580973
On Wed, Feb 15, 2017 at 11:42:54AM +1100, Tobin C. Harding wrote:
> Module copies a user supplied string (module parameter) into a buffer
> using strncpy() and does not check that the buffer is null terminated.
> 
> Replace call to strncpy() with call to strlcpy() ensuring that the
> buffer is null terminated.
> 
> Signed-off-by: Tobin C. Harding <me@tobin.cc>
> ---
>  drivers/staging/fbtft/fbtft_device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c
> index de46f8d..7b7223b 100644
> --- a/drivers/staging/fbtft/fbtft_device.c
> +++ b/drivers/staging/fbtft/fbtft_device.c
> @@ -1483,7 +1483,7 @@ static int __init fbtft_device_init(void)
>  			displays[i].pdev->name = name;
>  			displays[i].spi = NULL;
>  		} else {
> -			strncpy(displays[i].spi->modalias, name, SPI_NAME_SIZE);
> +			strlcpy(displays[i].spi->modalias, name, SPI_NAME_SIZE);

Shouldn't we properly check the return value here to know if the buffer
did get truncated?  Or do we really care?

thanks,

greg k-h

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web