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


Groups > linux.kernel > #1719571

Re: [PATCH] [net-next] qlge: avoid memcpy buffer overflow

From David Miller <davem@davemloft.net>
Newsgroups linux.kernel
Subject Re: [PATCH] [net-next] qlge: avoid memcpy buffer overflow
Date 2017-08-24 23:10 +0200
Message-ID <ui7y2-3iu-21@gated-at.bofh.it> (permalink)
References <uhEw2-1x1-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Arnd Bergmann <arnd@arndb.de>
Date: Wed, 23 Aug 2017 15:59:49 +0200

> gcc-8.0.0 (snapshot) points out that we copy a variable-length string
> into a fixed length field using memcpy() with the destination length,
> and that ends up copying whatever follows the string:
> 
>     inlined from 'ql_core_dump' at drivers/net/ethernet/qlogic/qlge/qlge_dbg.c:1106:2:
> drivers/net/ethernet/qlogic/qlge/qlge_dbg.c:708:2: error: 'memcpy' reading 15 bytes from a region of size 14 [-Werror=stringop-overflow=]
>   memcpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1);
> 
> Changing it to use strncpy() will instead zero-pad the destination,
> which seems to be the right thing to do here.
> 
> The bug is probably harmless, but it seems like a good idea to address
> it in stable kernels as well, if only for the purpose of building with
> gcc-8 without warnings.
> 
> Cc: stable@vger.kernel.org

Please don't use explicit stable CC:'ing for networking changes.

> Fixes: a61f80261306 ("qlge: Add ethtool register dump function.")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to 'net' and queued up for -stable, thanks.

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


Thread

[PATCH] [net-next] qlge: avoid memcpy buffer overflow Arnd Bergmann <arnd@arndb.de> - 2017-08-23 16:10 +0200
  Re: [PATCH] [net-next] qlge: avoid memcpy buffer overflow David Miller <davem@davemloft.net> - 2017-08-24 23:10 +0200

csiph-web