Skip to content

Commit

Permalink
samples/bpf: Fix buffer overflow in tcp_basertt
Browse files Browse the repository at this point in the history
Using sizeof(nv) or strlen(nv)+1 is correct.

Fixes: c890063 ("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>
  • Loading branch information
ws-yangpc authored and Alexei Starovoitov committed May 5, 2023
1 parent 6953518 commit f4dea96
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion samples/bpf/tcp_basertt_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int bpf_basertt(struct bpf_sock_ops *skops)
case BPF_SOCK_OPS_BASE_RTT:
n = bpf_getsockopt(skops, SOL_TCP, TCP_CONGESTION,
cong, sizeof(cong));
if (!n && !__builtin_memcmp(cong, nv, sizeof(nv)+1)) {
if (!n && !__builtin_memcmp(cong, nv, sizeof(nv))) {
/* Set base_rtt to 80us */
rv = 80;
} else if (n) {
Expand Down

0 comments on commit f4dea96

Please sign in to comment.