summaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2017-06-22 18:57:55 -0700
committerDavid S. Miller <davem@davemloft.net>2017-06-23 14:10:05 -0400
commit926f38e9744b2ee6d92085c28ebb50744e9e1182 (patch)
tree8bece0c7338621cebdf5978d5ebce396a2309ac2 /net/ipv4
parent239946314e57711d7da546b67964d0b387a3ee42 (diff)
downloadlinux-926f38e9744b2ee6d92085c28ebb50744e9e1182.tar.bz2
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: 734942cc4ea6 ("tcp: ULP infrastructure") Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/tcp_ulp.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/net/ipv4/tcp_ulp.c b/net/ipv4/tcp_ulp.c
index e855ea70819b..2417f55374c5 100644
--- a/net/ipv4/tcp_ulp.c
+++ b/net/ipv4/tcp_ulp.c
@@ -88,6 +88,7 @@ void tcp_get_available_ulp(char *buf, size_t maxlen)
struct tcp_ulp_ops *ulp_ops;
size_t offs = 0;
+ *buf = '\0';
rcu_read_lock();
list_for_each_entry_rcu(ulp_ops, &tcp_ulp_list, list) {
offs += snprintf(buf + offs, maxlen - offs,