Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples/bpf: Fix buffer overflow in tcp_basertt

Using sizeof(nv) or strlen(nv)+1 is correct.

Fixes: c890063e4404 ("bpf: sample BPF_SOCKET_OPS_BASE_RTT program")
Signed-off-by: Pengcheng Yang <yangpc@wangsu.com>
Link: https://lore.kernel.org/r/1683276658-2860-1-git-send-email-yangpc@wangsu.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Pengcheng Yang and committed by
Alexei Starovoitov
f4dea968 69535186

+1 -1
+1 -1
samples/bpf/tcp_basertt_kern.c
··· 47 47 case BPF_SOCK_OPS_BASE_RTT: 48 48 n = bpf_getsockopt(skops, SOL_TCP, TCP_CONGESTION, 49 49 cong, sizeof(cong)); 50 - if (!n && !__builtin_memcmp(cong, nv, sizeof(nv)+1)) { 50 + if (!n && !__builtin_memcmp(cong, nv, sizeof(nv))) { 51 51 /* Set base_rtt to 80us */ 52 52 rv = 80; 53 53 } else if (n) {