aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/samples
diff options
context:
space:
mode:
authorPengcheng Yang <yangpc@wangsu.com>2023-05-05 16:50:58 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-23 13:46:49 +0200
commite92f61e0701ea780e57e1be8dbd1fbec5f42c09e (patch)
tree7144130e70d6837e36cb4c7a5fc853ab96c1170c /samples
parentc77eb01a6e4147a50388757d8dc2638425e0c333 (diff)
downloadaa-e92f61e0701ea780e57e1be8dbd1fbec5f42c09e.tar.gz
samples/bpf: Fix buffer overflow in tcp_basertt
[ Upstream commit f4dea9689c5fea3d07170c2cb0703e216f1a0922 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'samples')
-rw-r--r--samples/bpf/tcp_basertt_kern.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/samples/bpf/tcp_basertt_kern.c b/samples/bpf/tcp_basertt_kern.c
index 8dfe09a92feca7..822b0742b81543 100644
--- a/samples/bpf/tcp_basertt_kern.c
+++ b/samples/bpf/tcp_basertt_kern.c
@@ -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) {