From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751417AbdBOBCi (ORCPT ); Tue, 14 Feb 2017 20:02:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33452 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902AbdBOBC3 (ORCPT ); Tue, 14 Feb 2017 20:02:29 -0500 Date: Tue, 14 Feb 2017 17:02:28 -0800 From: Greg Kroah-Hartman To: "Tobin C. Harding" Cc: Thomas Petazzoni , noralf@tronnes.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: fbtft: Fix buffer overflow vulnerability Message-ID: <20170215010228.GA26880@kroah.com> References: <1487119374-16345-1-git-send-email-me@tobin.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1487119374-16345-1-git-send-email-me@tobin.cc> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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