Skip to content

Commit f4dea96

Browse files
ws-yangpcAlexei Starovoitov
authored and
Alexei Starovoitov
committed
samples/bpf: Fix buffer overflow in tcp_basertt
Using sizeof(nv) or strlen(nv)+1 is correct. Fixes: c890063 ("bpf: sample BPF_SOCKET_OPS_BASE_RTT program") Signed-off-by: Pengcheng Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 6953518 commit f4dea96

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

samples/bpf/tcp_basertt_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int bpf_basertt(struct bpf_sock_ops *skops)
4747
case BPF_SOCK_OPS_BASE_RTT:
4848
n = bpf_getsockopt(skops, SOL_TCP, TCP_CONGESTION,
4949
cong, sizeof(cong));
50-
if (!n && !__builtin_memcmp(cong, nv, sizeof(nv)+1)) {
50+
if (!n && !__builtin_memcmp(cong, nv, sizeof(nv))) {
5151
/* Set base_rtt to 80us */
5252
rv = 80;
5353
} else if (n) {

0 commit comments

Comments
 (0)