lkml.org 
[lkml]   [2022]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH bpf-next] samples/bpf: xdp_router_ipv4_user: Fix write overflow
Date
From: Rong Tao <rongtao@cestc.cn>

prefix_key->data allocates three bytes using alloca(), but four bytes are
accessed in the program.

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
samples/bpf/xdp_router_ipv4_user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/samples/bpf/xdp_router_ipv4_user.c b/samples/bpf/xdp_router_ipv4_user.c
index 683913bbf279..9d41db09c480 100644
--- a/samples/bpf/xdp_router_ipv4_user.c
+++ b/samples/bpf/xdp_router_ipv4_user.c
@@ -162,7 +162,7 @@ static void read_route(struct nlmsghdr *nh, int nll)
__be32 gw;
} *prefix_value;

- prefix_key = alloca(sizeof(*prefix_key) + 3);
+ prefix_key = alloca(sizeof(*prefix_key) + 4);
prefix_value = alloca(sizeof(*prefix_value));

prefix_key->prefixlen = 32;
--
2.38.1
\
 
 \ /
  Last update: 2022-11-22 03:35    [W:0.039 / U:0.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site