Skip to content

Commit 926f38e

Browse files
Jakub Kicinskidavem330
authored andcommitted
tcp: fix out-of-bounds access in ULP sysctl
KASAN reports out-of-bound access in proc_dostring() coming from proc_tcp_available_ulp() because in case TCP ULP list is empty the buffer allocated for the response will not have anything printed into it. Set the first byte to zero to avoid strlen() going out-of-bounds. Fixes: 734942c ("tcp: ULP infrastructure") Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2399463 commit 926f38e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/ipv4/tcp_ulp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void tcp_get_available_ulp(char *buf, size_t maxlen)
8888
struct tcp_ulp_ops *ulp_ops;
8989
size_t offs = 0;
9090

91+
*buf = '\0';
9192
rcu_read_lock();
9293
list_for_each_entry_rcu(ulp_ops, &tcp_ulp_list, list) {
9394
offs += snprintf(buf + offs, maxlen - offs,

0 commit comments

Comments
 (0)