提交 926f38e9 编写于 作者: J Jakub Kicinski 提交者: David S. Miller

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: 734942cc ("tcp: ULP infrastructure")
Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 23994631
...@@ -88,6 +88,7 @@ void tcp_get_available_ulp(char *buf, size_t maxlen) ...@@ -88,6 +88,7 @@ void tcp_get_available_ulp(char *buf, size_t maxlen)
struct tcp_ulp_ops *ulp_ops; struct tcp_ulp_ops *ulp_ops;
size_t offs = 0; size_t offs = 0;
*buf = '\0';
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(ulp_ops, &tcp_ulp_list, list) { list_for_each_entry_rcu(ulp_ops, &tcp_ulp_list, list) {
offs += snprintf(buf + offs, maxlen - offs, offs += snprintf(buf + offs, maxlen - offs,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册