All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests/ipc: restore ENOSYS handling for MSG_COPY and clean up
@ 2026-11-29  0:56 Nikolai Dokutovich
  2026-11-29  1:55 ` + selftests-ipc-restore-enosys-handling-for-msg_copy-and-clean-up.patch added to mm-nonmm-unstable branch Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Nikolai Dokutovich @ 2026-11-29  0:56 UTC (permalink / raw)
  To: Shuah Khan, Andrew Morton
  Cc: Paul White, Manfred Spraul, Davidlohr Bueso, linux-kselftest,
	linux-kernel, Nikolai Dokutovich

msgrcv(MSG_COPY) is rejected with -ENOSYS by do_msgrcv() when the kernel
is built without CONFIG_CHECKPOINT_RESTORE: prepare_copy() is stubbed to
return ERR_PTR(-ENOSYS) in ipc/msg.c. The test used to skip on that
error, but commit fd3c1fd8baf4 ("selftests: ipc: change operation not
supported error number") changed the check to EOPNOTSUPP, which is not
what this kernel path returns, so the suite now reports

    not ok 1 Failed to copy IPC message: Function not implemented (38)

on every kernel without CONFIG_CHECKPOINT_RESTORE.

While here, stop skipping from dump_queue(): ksft_exit_skip() leaves the
queue allocated, and a rerun in the same IPC namespace then fails at
msgget(IPC_CREAT | IPC_EXCL) with -EEXIST. Return the error to main(),
remove the queue and only then skip.

Reproduced on a kernel without CONFIG_CHECKPOINT_RESTORE: before the
fix, a run failed with the message above and a second run failed with
"Can't create queue: -17"; after it, both runs report

    1..0 # SKIP MSG_COPY not supported

Fixes: fd3c1fd8baf4 ("selftests: ipc: change operation not supported error number")
Signed-off-by: Nikolai Dokutovich <ndokutovich@gmail.com>
---
 tools/testing/selftests/ipc/msgque.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c
index 4b4c1abfac0f..b6058be9a005 100644
--- a/tools/testing/selftests/ipc/msgque.c
+++ b/tools/testing/selftests/ipc/msgque.c
@@ -161,8 +161,8 @@ int dump_queue(struct msgque_data *msgque)
 		ret = msgrcv(msgque->msq_id, &msgque->messages[i].mtype,
 				MAX_MSG_SIZE, i, IPC_NOWAIT | MSG_COPY);
 		if (ret < 0) {
-			if (errno == EOPNOTSUPP)
-				ksft_exit_skip("MSG_COPY not supported\n");
+			if (errno == ENOSYS)
+				return -ENOSYS;
 
 			ksft_test_result_fail("Failed to copy IPC message: %m (%d)\n", errno);
 			return -errno;
@@ -222,6 +222,15 @@ int main(int argc, char **argv)
 	}
 
 	err = dump_queue(&msgque);
+	if (err == -ENOSYS) {
+		/*
+		 * MSG_COPY is not available. Remove the queue before leaving:
+		 * a leftover queue makes a rerun fail at msgget(IPC_EXCL).
+		 */
+		if (msgctl(msgque.msq_id, IPC_RMID, NULL))
+			ksft_exit_fail_msg("Failed to destroy queue: %d\n", -errno);
+		ksft_exit_skip("MSG_COPY not supported\n");
+	}
 	if (err) {
 		ksft_test_result_fail("Failed to dump queue: %d\n", err);
 		goto err_destroy;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-29  1:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  0:56 [PATCH] selftests/ipc: restore ENOSYS handling for MSG_COPY and clean up Nikolai Dokutovich
2026-11-29  1:55 ` + selftests-ipc-restore-enosys-handling-for-msg_copy-and-clean-up.patch added to mm-nonmm-unstable branch Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.