Skip to content

Commit c40dd8c

Browse files
tohojoborkmann
authored andcommitted
bpf, test_run: Fix LIVE_FRAME frame update after a page has been recycled
The test_run code detects whether a page has been modified and re-initialises the xdp_frame structure if it has, using xdp_update_frame_from_buff(). However, xdp_update_frame_from_buff() doesn't touch frame->mem, so that wasn't correctly re-initialised, which led to the pages from page_pool not being returned correctly. Syzbot noticed this as a memory leak. Fix this by also copying the frame->mem structure when re-initialising the frame, like we do on initialisation of a new page from page_pool. Fixes: e5995bc ("bpf, test_run: fix crashes due to XDP frame overwriting/corruption") Fixes: b530e9e ("bpf: Add "live packet" mode for XDP in BPF_PROG_RUN") Reported-by: [email protected] Signed-off-by: Toke Høiland-Jørgensen <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Tested-by: [email protected] Reviewed-by: Alexander Lobakin <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 053b212 commit c40dd8c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/bpf/test_run.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ static void reset_ctx(struct xdp_page_head *head)
246246
head->ctx.data_meta = head->orig_ctx.data_meta;
247247
head->ctx.data_end = head->orig_ctx.data_end;
248248
xdp_update_frame_from_buff(&head->ctx, head->frame);
249+
head->frame->mem = head->orig_ctx.rxq->mem;
249250
}
250251

251252
static int xdp_recv_frames(struct xdp_frame **frames, int nframes,

0 commit comments

Comments
 (0)