[PATCH v4 03/19] selftests/liveupdate: Add tests for preserve and retrieve user argument

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Nov 11 16:31:06 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/liveupdate: zero min_arg.arg in
  preserve_memfd_with_arg()
--

commit 1a8c90d14c1496a0314a67c567059709fa28b4ba
Author: Pasha Tatashin <pasha.tatashin at soleen.com>

selftests/liveupdate: Add tests for preserve and retrieve user argument

This commit adds libliveupdate helpers for passing a user argument to
LIVEUPDATE_SESSION_PRESERVE_FD and LIVEUPDATE_SESSION_RETRIEVE_FD, along
with a preserve_memfd_with_arg test case covering memfd argument handling.

> diff --git a/tools/testing/selftests/liveupdate/liveupdate.c b/tools/testing/selftests/liveupdate/liveupdate.c
> index 2dedd5fc2534f..4c4272167635b 100644
> --- a/tools/testing/selftests/liveupdate/liveupdate.c
> +++ b/tools/testing/selftests/liveupdate/liveupdate.c
[ ... ]
> @@ -530,4 +531,47 @@ TEST_F(liveupdate_device, preserve_many_files)
>  	ASSERT_EQ(close(session_fd), 0);
>  }
>  
> +/*
> + * Test Case: Preserve MemFD with User Argument
> + *
> + * Verifies that passing a non-zero user argument to memfd preservation fails
> + * with -EOPNOTSUPP, while passing a zero argument or using the minimum struct
> + * size without the arg field succeeds.
> + */
> +TEST_F(liveupdate_device, preserve_memfd_with_arg)
> +{
> +	struct liveupdate_session_preserve_fd min_arg = {};
> +	int session_fd, mem_fd1, mem_fd2;
> +
> +	self->fd1 = open(LIVEUPDATE_DEV, O_RDWR);
> +	if (self->fd1 < 0 && errno == ENOENT)
> +		SKIP(return, "%s does not exist", LIVEUPDATE_DEV);
> +	ASSERT_GE(self->fd1, 0);
> +
> +	session_fd = luo_create_session(self->fd1, "preserve-arg-test");
> +	ASSERT_GE(session_fd, 0);
> +
> +	mem_fd1 = memfd_create("arg-memfd-1", 0);
> +	ASSERT_GE(mem_fd1, 0);
> +
> +	/* Non-zero arg is not supported by memfd handler */
> +	EXPECT_EQ(luo_session_preserve_fd_arg(session_fd, mem_fd1, 0x1111, 1),
> +		  -EOPNOTSUPP);
> +
> +	/* Legacy struct size (up to token) should zero-fill arg and succeed */
> +	min_arg.size = offsetof(struct liveupdate_session_preserve_fd, arg);
> +	min_arg.fd = mem_fd1;
> +	min_arg.token = 0x1111;
> +	ASSERT_EQ(ioctl(session_fd, LIVEUPDATE_SESSION_PRESERVE_FD, &min_arg), 0);

[Severity: Low]
Should min_arg.arg be set to a non-zero value before this ioctl() call?
Because min_arg is zero-initialized on the stack, min_arg.arg is already 0
in userspace, so this check would still pass even if the kernel ignored
min_arg.size and read the trailing arg field from userspace.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261111002358.1842967-1-dmatlack@google.com?part=3



More information about the kexec mailing list