]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/landlock: Skip scoped_signal subtest with MSG_OOB if not available
authorThomas Huth <thuth@redhat.com>
Fri, 10 Jul 2026 08:16:42 +0000 (10:16 +0200)
committerMickaël Salaün <mic@digikod.net>
Fri, 10 Jul 2026 10:59:11 +0000 (12:59 +0200)
MSG_OOB might be disabled in the kernel for unix sockets (by not
selecting CONFIG_AF_UNIX_OOB), and in this case the related tests
of the scoped_signal_test are currently failing.  Add a runtime
probe using socketpair() to detect MSG_OOB support and skip the
test gracefully if it is unavailable.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Link: https://patch.msgid.link/20260710081642.405916-1-thuth@redhat.com
Cc: stable@vger.kernel.org
Fixes: f34e9ce5f479 ("selftests/landlock: Test signal created by out-of-bound message")
Signed-off-by: Mickaël Salaün <mic@digikod.net>
tools/testing/selftests/landlock/scoped_signal_test.c

index 3f0cd42a2afe04700ec26530150d61b575896118..2d37d0c06c069f25d44510bb1c12323821d7db4d 100644 (file)
@@ -400,6 +400,24 @@ static int setup_signal_handler(int signal)
        return sigaction(SIGURG, &sa, NULL);
 }
 
+/*
+ * MSG_OOB might be disabled in the kernel via the CONFIG_AF_UNIX_OOB
+ * switch, so this function can be used for probing for its availability.
+ */
+static bool has_af_unix_oob(void)
+{
+       bool available = false;
+       int sp[2];
+
+       if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) == 0) {
+               available = (send(sp[0], ".", 1, MSG_OOB) == 1);
+               close(sp[0]);
+               close(sp[1]);
+       }
+
+       return available;
+}
+
 /* clang-format off */
 FIXTURE(fown) {};
 /* clang-format on */
@@ -462,6 +480,9 @@ TEST_F(fown, sigurg_socket)
        int pipe_parent[2], pipe_child[2];
        pid_t child;
 
+       if (!has_af_unix_oob())
+               SKIP(return, "CONFIG_AF_UNIX_OOB / MSG_OOB not available");
+
        memset(&server_address, 0, sizeof(server_address));
        set_unix_address(&server_address, 0);