Re: [PATCH] Bluetooth: mgmt: Pessimize compile-time bounds-check

From
Marcel Holtmann <marcel@holtmann.org>
Date
2021-08-19 14:52:36
Also in
linux-hardening, lkml, netdev
Reply to
Kees Cook, 2021-08-18
Hi Kees,
After gaining __alloc_size hints, GCC thinks it can reach a memcpy()
with eir_len == 0 (since it can't see into the rewrite of status).
Instead, check eir_len == 0, avoiding this future warning:

In function 'eir_append_data',
   inlined from 'read_local_oob_ext_data_complete' at net/bluetooth/mgmt.c:7210:12:
./include/linux/fortify-string.h:54:29: warning: '__builtin_memcpy' offset 5 is out of the bounds [0, 3] [-Warray-bounds]
...
net/bluetooth/hci_request.h:133:2: note: in expansion of macro 'memcpy'
 133 |  memcpy(&eir[eir_len], data, data_len);
     |  ^~~~~~

Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <redacted>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: <redacted>
Cc: <redacted>
Signed-off-by: Kees Cook <redacted>
---
net/bluetooth/mgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.

Regards

Marcel
Thread (4 messages) 4 messages, 3 authors, last reply 2021-08-19
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help