From ef9284113b946d8107a7c9e0e3730e12c2fde34d Mon Sep 17 00:00:00 2001 From: arctic-alpaca <67190338+arctic-alpaca@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:58:42 +0100 Subject: [PATCH] tests: Fix UB in AF_XDP test --- test/integration-test/src/tests/xdp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration-test/src/tests/xdp.rs b/test/integration-test/src/tests/xdp.rs index bd694287..8d6395f5 100644 --- a/test/integration-test/src/tests/xdp.rs +++ b/test/integration-test/src/tests/xdp.rs @@ -32,9 +32,9 @@ fn af_xdp() { struct PacketMap(MaybeUninit<[u8; 4096]>); // Safety: don't access alloc down the line. - let mut alloc = Box::new(PacketMap(MaybeUninit::uninit())); + let mut alloc = Box::new(PacketMap(MaybeUninit::zeroed())); let umem = { - // Safety: this is a shared buffer between the kernel and us, uninitialized memory is valid. + // Safety: Zeroed memory is valid for u8 arrays. let mem = unsafe { alloc.0.assume_init_mut() }.as_mut().into(); // Safety: we cannot access `mem` further down the line because it falls out of scope. unsafe { Umem::new(UmemConfig::default(), mem).unwrap() }