[PATCH v1 4/7] selftests: liveupdate: Add tests for preserve and retrieve user argument

sashiko-bot at kernel.org sashiko-bot at kernel.org
Thu Oct 15 02:45:14 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests: missing retrieve user arg test case
--

commit 420b1c3465899a231e547b85211758efc34277b8
Author: Pasha Tatashin <pasha.tatashin at soleen.com>
Date:   Thu Oct 15 09:38:13 2026 +0000

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

This commit adds luo_session_preserve_fd_arg() and 
luo_session_retrieve_fd_arg() helpers to libliveupdate to pass handler-specific 
arguments. It also introduces a preserve_memfd_with_arg test case to verify 
memfd preservation behavior with different user arguments.

> diff --git a/tools/testing/selftests/liveupdate/liveupdate.c b/tools/testing/selftests/liveupdate/liveupdate.c
> index 9de068f31c3ec..83e0978f3818d 100644
> --- a/tools/testing/selftests/liveupdate/liveupdate.c
> +++ b/tools/testing/selftests/liveupdate/liveupdate.c

[ ... ]

> @@ -570,4 +571,47 @@ TEST_F(liveupdate_device, session_freeze)
>  	ASSERT_EQ(close(mem_fd2), 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);
> +
> +	/* Explicit zero arg with full struct size should also succeed */
> +	mem_fd2 = memfd_create("arg-memfd-2", 0);
> +	ASSERT_GE(mem_fd2, 0);
> +	ASSERT_EQ(luo_session_preserve_fd_arg(session_fd, mem_fd2, 0x2222, 0), 0);
> +
> +	ASSERT_EQ(close(session_fd), 0);
> +	ASSERT_EQ(close(mem_fd1), 0);
> +	ASSERT_EQ(close(mem_fd2), 0);
> +}

[Severity: Medium]
The commit title and message explicitly claim to add tests for both preserve
and retrieve user argument, stating it verifies support in both
LIVEUPDATE_SESSION_PRESERVE_FD and LIVEUPDATE_SESSION_RETRIEVE_FD.

However, only the preserve_memfd_with_arg test case is implemented. No
corresponding test for the retrieve path is provided here.

Was the retrieve test case accidentally omitted from this patch?

> +
>  TEST_HARNESS_MAIN

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015093816.2438942-1-pasha.tatashin@soleen.com?part=4



More information about the kexec mailing list