]> git.baikalelectronics.ru Git - kernel.git/commit
net: cxgb4: avoid memcpy beyond end of source buffer
authorArnd Bergmann <arnd@arndb.de>
Fri, 2 Feb 2018 15:18:37 +0000 (16:18 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Feb 2018 00:32:05 +0000 (19:32 -0500)
commitf08ce78fb71d6f52100d9c18d52973f8c370ba72
tree4b6c485e427f644f578733e54c61b3c97619fa61
parent9043b70e182888012c3bcd4545b9f3fb54909d56
net: cxgb4: avoid memcpy beyond end of source buffer

Building with link-time-optimizations revealed that the cxgb4 driver does
a fixed-size memcpy() from a variable-length constant string into the
network interface name:

In function 'memcpy',
    inlined from 'cfg_queues_uld.constprop' at drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c:335:2,
    inlined from 'cxgb4_register_uld.constprop' at drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c:719:9:
include/linux/string.h:350:3: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter
   __read_overflow2();
   ^

I can see two equally workable solutions: either we use a strncpy() instead
of the memcpy() to stop at the end of the input, or we make the source buffer
fixed length as well. This implements the latter.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h