Skip to content

Commit

Permalink
bpf, test_run: Fix LIVE_FRAME frame update after a page has been recy…
Browse files Browse the repository at this point in the history
…cled

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: syzbot+d121e098da06af416d23@syzkaller.appspotmail.com
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: syzbot+d121e098da06af416d23@syzkaller.appspotmail.com
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://lore.kernel.org/bpf/20241030-test-run-mem-fix-v1-1-41e88e8cae43@redhat.com
  • Loading branch information
tohojo authored and borkmann committed Oct 31, 2024
1 parent 053b212 commit c40dd8c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/bpf/test_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ static void reset_ctx(struct xdp_page_head *head)
head->ctx.data_meta = head->orig_ctx.data_meta;
head->ctx.data_end = head->orig_ctx.data_end;
xdp_update_frame_from_buff(&head->ctx, head->frame);
head->frame->mem = head->orig_ctx.rxq->mem;
}

static int xdp_recv_frames(struct xdp_frame **frames, int nframes,
Expand Down

0 comments on commit c40dd8c

Please sign in to comment.