* [PATCH v1 net-next 1/4] selftests: landlock: Replace MSG_OOB with O_ASYNC+F_SETSIG.
2026-11-16 2:18 [PATCH v1 net-next 0/4] af_unix: Drop MSG_OOB support Kuniyuki Iwashima
@ 2026-11-16 2:18 ` Kuniyuki Iwashima
2026-11-16 2:18 ` [PATCH v1 net-next 2/4] selftests: bpf: sockmap: Remove AF_UNIX MSG_OOB test case Kuniyuki Iwashima
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-11-16 2:18 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev,
Mickaël Salaün, Günther Noack,
linux-security-module
AF_UNIX will drop MSG_OOB support.
scoped_signal_test.c uses MSG_OOB in fown.sigurg_socket and
trace_fown.deny_scope_fown to trigger SIGURG and exercise
security_file_send_sigiotask().
The same hook can be exercised via send_sigio() with a plain send()
by setting O_ASYNC and F_SETSIG with SIGURG on recv_socket.
Let's replace MSG_OOB with O_ASYNC and F_SETSIG so that the tests
do not depend on CONFIG_AF_UNIX_OOB.
Note that with O_ASYNC set on recv_socket, closing client_socket
while recv_socket is still open also triggers SIGURG for POLL_HUP
in unix_release_sock(), which would emit an extra
landlock_deny_scope_signal trace event in
trace_fown.deny_scope_fown. Thus, the child waits for the parent
to close recv_socket via pipe_parent before closing client_socket.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
Cc: "Mickaël Salaün" <mic@digikod.net>
Cc: "Günther Noack" <gnoack@google.com>
Cc: linux-security-module@vger.kernel.org
---
tools/testing/selftests/landlock/config | 1 -
.../selftests/landlock/scoped_signal_test.c | 55 ++++++++-----------
2 files changed, 22 insertions(+), 34 deletions(-)
diff --git a/tools/testing/selftests/landlock/config b/tools/testing/selftests/landlock/config
index 5568d7a4b2d7..fb617c1a4ce3 100644
--- a/tools/testing/selftests/landlock/config
+++ b/tools/testing/selftests/landlock/config
@@ -1,4 +1,3 @@
-CONFIG_AF_UNIX_OOB=y
CONFIG_AUDIT=y
CONFIG_CGROUPS=y
CONFIG_CGROUP_SCHED=y
diff --git a/tools/testing/selftests/landlock/scoped_signal_test.c b/tools/testing/selftests/landlock/scoped_signal_test.c
index 259cdcc8aa5c..c4c365007370 100644
--- a/tools/testing/selftests/landlock/scoped_signal_test.c
+++ b/tools/testing/selftests/landlock/scoped_signal_test.c
@@ -405,24 +405,6 @@ 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 */
@@ -473,8 +455,8 @@ FIXTURE_TEARDOWN(fown)
}
/*
- * Sending an out of bound message will trigger the SIGURG signal
- * through file_send_sigiotask.
+ * Sending a message to a socket with O_ASYNC will trigger
+ * the SIGURG signal through file_send_sigiotask.
*/
TEST_F(fown, sigurg_socket)
{
@@ -485,9 +467,6 @@ 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);
@@ -521,14 +500,14 @@ TEST_F(fown, sigurg_socket)
*/
ASSERT_EQ(1, read(pipe_parent[0], &buffer_child, 1));
/* May signal itself. */
- ASSERT_EQ(1, send(client_socket, ".", 1, MSG_OOB));
- EXPECT_EQ(0, close(client_socket));
+ ASSERT_EQ(1, send(client_socket, ".", 1, 0));
ASSERT_EQ(1, write(pipe_child[1], ".", 1));
EXPECT_EQ(0, close(pipe_child[1]));
/* Waits for the message to be received. */
ASSERT_EQ(1, read(pipe_parent[0], &buffer_child, 1));
EXPECT_EQ(0, close(pipe_parent[0]));
+ EXPECT_EQ(0, close(client_socket));
if (variant->sandbox_setown == SANDBOX_BEFORE_SETOWN) {
ASSERT_EQ(0, signal_received);
@@ -560,20 +539,22 @@ TEST_F(fown, sigurg_socket)
create_scoped_domain(_metadata, LANDLOCK_SCOPE_SIGNAL);
/*
- * Sets the child to receive SIGURG for MSG_OOB. This uncommon use is
+ * Sets the child to receive SIGURG. This uncommon use is
* a valid attack scenario which also simplifies this test.
*/
ASSERT_EQ(0, fcntl(recv_socket, F_SETOWN, child));
+ ASSERT_EQ(0, fcntl(recv_socket, F_SETSIG, SIGURG));
+ ASSERT_EQ(0, fcntl(recv_socket, F_SETFL, O_ASYNC));
if (variant->sandbox_setown == SANDBOX_AFTER_SETOWN)
create_scoped_domain(_metadata, LANDLOCK_SCOPE_SIGNAL);
ASSERT_EQ(1, write(pipe_parent[1], ".", 1));
- /* Waits for the child to send MSG_OOB. */
+ /* Waits for the child to send data. */
ASSERT_EQ(1, read(pipe_child[0], &buffer_parent, 1));
EXPECT_EQ(0, close(pipe_child[0]));
- ASSERT_EQ(1, recv(recv_socket, &buffer_parent, 1, MSG_OOB));
+ ASSERT_EQ(1, recv(recv_socket, &buffer_parent, 1, 0));
EXPECT_EQ(0, close(recv_socket));
EXPECT_EQ(0, close(server_socket));
ASSERT_EQ(1, write(pipe_parent[1], ".", 1));
@@ -1085,11 +1066,15 @@ TEST_F(trace_fown, deny_scope_fown)
*/
ASSERT_EQ(1, read(pipe_parent[0], &buffer_child, 1));
/* Triggers the asynchronous SIGURG to this file owner. */
- ASSERT_EQ(1, send(client_socket, ".", 1, MSG_OOB));
- EXPECT_EQ(0, close(client_socket));
+ ASSERT_EQ(1, send(client_socket, ".", 1, 0));
ASSERT_EQ(1, write(pipe_child[1], ".", 1));
EXPECT_EQ(0, close(pipe_child[1]));
+ /* Waits for the message to be received. */
+ ASSERT_EQ(1, read(pipe_parent[0], &buffer_child, 1));
+ EXPECT_EQ(0, close(pipe_parent[0]));
+ EXPECT_EQ(0, close(client_socket));
+
_exit(0);
return;
}
@@ -1114,19 +1099,23 @@ TEST_F(trace_fown, deny_scope_fown)
create_scoped_domain(_metadata, LANDLOCK_SCOPE_SIGNAL);
/*
- * Sets the child to receive SIGURG for MSG_OOB. This uncommon use is a
+ * Sets the child to receive SIGURG. This uncommon use is a
* valid attack scenario which also simplifies this test.
*/
ASSERT_EQ(0, fcntl(recv_socket, F_SETOWN, child));
+ ASSERT_EQ(0, fcntl(recv_socket, F_SETSIG, SIGURG));
+ ASSERT_EQ(0, fcntl(recv_socket, F_SETFL, O_ASYNC));
ASSERT_EQ(1, write(pipe_parent[1], ".", 1));
- /* Waits for the child to send MSG_OOB. */
+ /* Waits for the child to send data. */
ASSERT_EQ(1, read(pipe_child[0], &buffer_parent, 1));
EXPECT_EQ(0, close(pipe_child[0]));
- ASSERT_EQ(1, recv(recv_socket, &buffer_parent, 1, MSG_OOB));
+ ASSERT_EQ(1, recv(recv_socket, &buffer_parent, 1, 0));
EXPECT_EQ(0, close(recv_socket));
EXPECT_EQ(0, close(server_socket));
+ ASSERT_EQ(1, write(pipe_parent[1], ".", 1));
+ EXPECT_EQ(0, close(pipe_parent[1]));
ASSERT_EQ(child, waitpid(child, &status, 0));
ASSERT_TRUE(WIFEXITED(status));
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v1 net-next 2/4] selftests: bpf: sockmap: Remove AF_UNIX MSG_OOB test case.
2026-11-16 2:18 [PATCH v1 net-next 0/4] af_unix: Drop MSG_OOB support Kuniyuki Iwashima
2026-11-16 2:18 ` [PATCH v1 net-next 1/4] selftests: landlock: Replace MSG_OOB with O_ASYNC+F_SETSIG Kuniyuki Iwashima
@ 2026-11-16 2:18 ` Kuniyuki Iwashima
2026-11-16 2:18 ` [PATCH v1 net-next 3/4] selftests: af_unix: Remove MSG_OOB tests Kuniyuki Iwashima
2026-11-16 2:18 ` [PATCH v1 net-next 4/4] af_unix: Remove MSG_OOB Kuniyuki Iwashima
3 siblings, 0 replies; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-11-16 2:18 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev,
John Fastabend, Jakub Sitnicki, Jiayuan Chen, bpf
We will drop MSG_OOB support from AF_UNIX.
Let's remove the test case from sockmap_redir.
Note that struct socket_spec.send_flags is no longer used so
removed too.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Jakub Sitnicki <jakub@cloudflare.com>
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
---
.../selftests/bpf/prog_tests/sockmap_redir.c | 45 +++++--------------
1 file changed, 11 insertions(+), 34 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c b/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c
index 9c461d93113d..e73d3a674a74 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c
@@ -103,7 +103,6 @@ struct redir_spec {
struct socket_spec {
int family;
int sotype;
- int send_flags;
int in[2];
int out[2];
};
@@ -197,12 +196,12 @@ static void handle_unsupported(int sd_send, int sd_peer, int sd_in, int sd_out,
try_recv("bpf.recv(sd_recv)", sd_recv, MSG_DONTWAIT, false);
}
-static void test_send_redir_recv(int sd_send, int send_flags, int sd_peer,
+static void test_send_redir_recv(int sd_send, int sd_peer,
int sd_in, int sd_out, int sd_recv,
struct maps *maps, int status)
{
unsigned int drop, pass;
- char *send_buf = "ab";
+ char *send_buf = "a";
char recv_buf = '\0';
ssize_t n, len = 1;
@@ -217,10 +216,7 @@ static void test_send_redir_recv(int sd_send, int send_flags, int sd_peer,
if (xbpf_map_update_elem(maps->out, &u32(0), &u64(sd_out), BPF_NOEXIST))
goto del_in;
- /* Last byte is OOB data when send_flags has MSG_OOB bit set */
- if (send_flags & MSG_OOB)
- len++;
- n = send(sd_send, send_buf, len, send_flags);
+ n = send(sd_send, send_buf, len, 0);
if (n >= 0 && n < len)
FAIL("incomplete send");
if (n < 0) {
@@ -255,20 +251,6 @@ static void test_send_redir_recv(int sd_send, int send_flags, int sd_peer,
if (recv_buf != send_buf[0])
FAIL("recv(): payload check, %02x != %02x", recv_buf, send_buf[0]);
- if (send_flags & MSG_OOB) {
- /* Fail reading OOB while in sockmap */
- try_recv("bpf.recv(sd_out, MSG_OOB)", sd_out,
- MSG_OOB | MSG_DONTWAIT, false);
-
- /* Remove sd_out from sockmap */
- xbpf_map_delete_elem(maps->out, &u32(0));
-
- /* Check that OOB was dropped on redirect */
- try_recv("recv(sd_out, MSG_OOB)", sd_out,
- MSG_OOB | MSG_DONTWAIT, false);
-
- goto del_in;
- }
out:
xbpf_map_delete_elem(maps->out, &u32(0));
del_in:
@@ -328,7 +310,7 @@ static void test_socket(enum bpf_map_type type, struct redir_spec *redir,
struct maps *maps, struct socket_spec *s_in,
struct socket_spec *s_out)
{
- int fd_in, fd_out, fd_send, fd_peer, fd_recv, flags, status;
+ int fd_in, fd_out, fd_send, fd_peer, fd_recv, status;
const char *in_str, *out_str;
char s[MAX_TEST_NAME];
@@ -337,26 +319,24 @@ static void test_socket(enum bpf_map_type type, struct redir_spec *redir,
fd_send = s_in->in[redir->idx_send];
fd_peer = s_in->in[redir->idx_send ^ 1];
fd_recv = s_out->out[redir->idx_recv];
- flags = s_in->send_flags;
in_str = socket_kind_to_str(fd_in);
out_str = socket_kind_to_str(fd_out);
status = get_support_status(redir->prog_type, in_str, out_str);
snprintf(s, sizeof(s),
- "%-4s %-17s %-5s %s %-5s%6s",
- /* hash sk_skb-to-ingress u_str → v_str (OOB) */
+ "%-4s %-17s %-5s %s %-5s",
+ /* hash sk_skb-to-ingress u_str → v_str */
type == BPF_MAP_TYPE_SOCKMAP ? "map" : "hash",
redir->name,
in_str,
status & SUPPORTED ? "→" : " ",
- out_str,
- (flags & MSG_OOB) ? "(OOB)" : "");
+ out_str);
if (!test__start_subtest(s))
return;
- test_send_redir_recv(fd_send, flags, fd_peer, fd_in, fd_out, fd_recv,
+ test_send_redir_recv(fd_send, fd_peer, fd_in, fd_out, fd_recv,
maps, status);
}
@@ -365,12 +345,10 @@ static void test_redir(enum bpf_map_type type, struct redir_spec *redir,
{
struct socket_spec *s, sockets[] = {
{ AF_INET, SOCK_STREAM },
- // { AF_INET, SOCK_STREAM, MSG_OOB }, /* Known to be broken */
{ AF_INET6, SOCK_STREAM },
{ AF_INET, SOCK_DGRAM },
{ AF_INET6, SOCK_DGRAM },
{ AF_UNIX, SOCK_STREAM },
- { AF_UNIX, SOCK_STREAM, MSG_OOB },
{ AF_UNIX, SOCK_DGRAM },
// { AF_UNIX, SOCK_SEQPACKET}, /* Unsupported BPF_MAP_UPDATE_ELEM */
{ AF_VSOCK, SOCK_STREAM },
@@ -392,10 +370,9 @@ static void test_redir(enum bpf_map_type type, struct redir_spec *redir,
struct socket_spec *out = &sockets[j];
struct socket_spec *in = &sockets[i];
- /* Skip intra-proto and between variants */
- if (out->send_flags ||
- (in->family == out->family &&
- in->sotype == out->sotype))
+ /* Skip intra-proto */
+ if (in->family == out->family &&
+ in->sotype == out->sotype)
continue;
test_socket(type, redir, maps, in, out);
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v1 net-next 3/4] selftests: af_unix: Remove MSG_OOB tests.
2026-11-16 2:18 [PATCH v1 net-next 0/4] af_unix: Drop MSG_OOB support Kuniyuki Iwashima
2026-11-16 2:18 ` [PATCH v1 net-next 1/4] selftests: landlock: Replace MSG_OOB with O_ASYNC+F_SETSIG Kuniyuki Iwashima
2026-11-16 2:18 ` [PATCH v1 net-next 2/4] selftests: bpf: sockmap: Remove AF_UNIX MSG_OOB test case Kuniyuki Iwashima
@ 2026-11-16 2:18 ` Kuniyuki Iwashima
2026-11-16 2:18 ` [PATCH v1 net-next 4/4] af_unix: Remove MSG_OOB Kuniyuki Iwashima
3 siblings, 0 replies; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-11-16 2:18 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
We will drop MSG_OOB support.
Let's remove msg_oob.c, MSG_OOB variants and flags field
in scm_rights.c.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
.../testing/selftests/net/af_unix/.gitignore | 1 -
tools/testing/selftests/net/af_unix/Makefile | 1 -
tools/testing/selftests/net/af_unix/config | 1 -
tools/testing/selftests/net/af_unix/msg_oob.c | 958 ------------------
.../selftests/net/af_unix/scm_rights.c | 45 +-
5 files changed, 1 insertion(+), 1005 deletions(-)
delete mode 100644 tools/testing/selftests/net/af_unix/msg_oob.c
diff --git a/tools/testing/selftests/net/af_unix/.gitignore b/tools/testing/selftests/net/af_unix/.gitignore
index 954f0958dd03..b926e7f9625f 100644
--- a/tools/testing/selftests/net/af_unix/.gitignore
+++ b/tools/testing/selftests/net/af_unix/.gitignore
@@ -1,5 +1,4 @@
diag_uid
-msg_oob
scm_inq
scm_pidfd
scm_rights
diff --git a/tools/testing/selftests/net/af_unix/Makefile b/tools/testing/selftests/net/af_unix/Makefile
index 45b841758f1b..fb2e09f0f44b 100644
--- a/tools/testing/selftests/net/af_unix/Makefile
+++ b/tools/testing/selftests/net/af_unix/Makefile
@@ -7,7 +7,6 @@ CFLAGS += $(KHDR_INCLUDES) -Wall $(call cc-option,-Wflex-array-member-not-at-end
TEST_GEN_PROGS := \
diag_uid \
- msg_oob \
scm_inq \
scm_pidfd \
scm_rights \
diff --git a/tools/testing/selftests/net/af_unix/config b/tools/testing/selftests/net/af_unix/config
index 46450fea8407..549c33203c41 100644
--- a/tools/testing/selftests/net/af_unix/config
+++ b/tools/testing/selftests/net/af_unix/config
@@ -1,4 +1,3 @@
-CONFIG_AF_UNIX_OOB=y
CONFIG_BPF=y
CONFIG_BPF_EVENTS=y
CONFIG_BPF_JIT=y
diff --git a/tools/testing/selftests/net/af_unix/msg_oob.c b/tools/testing/selftests/net/af_unix/msg_oob.c
deleted file mode 100644
index f051d79f7a8e..000000000000
--- a/tools/testing/selftests/net/af_unix/msg_oob.c
+++ /dev/null
@@ -1,958 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright Amazon.com Inc. or its affiliates. */
-
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <netinet/in.h>
-#include <sys/epoll.h>
-#include <sys/ioctl.h>
-#include <sys/signalfd.h>
-#include <sys/socket.h>
-
-#include "kselftest_harness.h"
-
-#define BUF_SZ 32
-
-FIXTURE(msg_oob)
-{
- int fd[4]; /* 0: AF_UNIX sender
- * 1: AF_UNIX receiver
- * 2: TCP sender
- * 3: TCP receiver
- */
- int signal_fd;
- int epoll_fd[2]; /* 0: AF_UNIX receiver
- * 1: TCP receiver
- */
- bool tcp_compliant;
-};
-
-FIXTURE_VARIANT(msg_oob)
-{
- bool peek;
-};
-
-FIXTURE_VARIANT_ADD(msg_oob, no_peek)
-{
- .peek = false,
-};
-
-FIXTURE_VARIANT_ADD(msg_oob, peek)
-{
- .peek = true
-};
-
-static void create_unix_socketpair(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self)
-{
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, self->fd);
- ASSERT_EQ(ret, 0);
-}
-
-static void create_tcp_socketpair(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self)
-{
- struct sockaddr_in addr;
- socklen_t addrlen;
- int listen_fd;
- int ret;
-
- listen_fd = socket(AF_INET, SOCK_STREAM, 0);
- ASSERT_GE(listen_fd, 0);
-
- ret = listen(listen_fd, -1);
- ASSERT_EQ(ret, 0);
-
- addrlen = sizeof(addr);
- ret = getsockname(listen_fd, (struct sockaddr *)&addr, &addrlen);
- ASSERT_EQ(ret, 0);
-
- self->fd[2] = socket(AF_INET, SOCK_STREAM, 0);
- ASSERT_GE(self->fd[2], 0);
-
- ret = connect(self->fd[2], (struct sockaddr *)&addr, addrlen);
- ASSERT_EQ(ret, 0);
-
- self->fd[3] = accept(listen_fd, (struct sockaddr *)&addr, &addrlen);
- ASSERT_GE(self->fd[3], 0);
-
- ret = fcntl(self->fd[3], F_SETFL, O_NONBLOCK);
- ASSERT_EQ(ret, 0);
-}
-
-static void setup_sigurg(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self)
-{
- struct signalfd_siginfo siginfo;
- int pid = getpid();
- sigset_t mask;
- int i, ret;
-
- for (i = 0; i < 2; i++) {
- ret = ioctl(self->fd[i * 2 + 1], FIOSETOWN, &pid);
- ASSERT_EQ(ret, 0);
- }
-
- ret = sigemptyset(&mask);
- ASSERT_EQ(ret, 0);
-
- ret = sigaddset(&mask, SIGURG);
- ASSERT_EQ(ret, 0);
-
- ret = sigprocmask(SIG_BLOCK, &mask, NULL);
- ASSERT_EQ(ret, 0);
-
- self->signal_fd = signalfd(-1, &mask, SFD_NONBLOCK);
- ASSERT_GE(self->signal_fd, 0);
-
- ret = read(self->signal_fd, &siginfo, sizeof(siginfo));
- ASSERT_EQ(ret, -1);
-}
-
-static void setup_epollpri(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self)
-{
- struct epoll_event event = {
- .events = EPOLLPRI,
- };
- int i;
-
- for (i = 0; i < 2; i++) {
- int ret;
-
- self->epoll_fd[i] = epoll_create1(0);
- ASSERT_GE(self->epoll_fd[i], 0);
-
- ret = epoll_ctl(self->epoll_fd[i], EPOLL_CTL_ADD, self->fd[i * 2 + 1], &event);
- ASSERT_EQ(ret, 0);
- }
-}
-
-static void close_sockets(FIXTURE_DATA(msg_oob) *self)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- close(self->fd[i]);
-}
-
-FIXTURE_SETUP(msg_oob)
-{
- create_unix_socketpair(_metadata, self);
- create_tcp_socketpair(_metadata, self);
-
- setup_sigurg(_metadata, self);
- setup_epollpri(_metadata, self);
-
- self->tcp_compliant = true;
-}
-
-FIXTURE_TEARDOWN(msg_oob)
-{
- close_sockets(self);
-}
-
-static void __epollpair(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self,
- bool oob_remaining)
-{
- struct epoll_event event[2] = {};
- int i, ret[2];
-
- for (i = 0; i < 2; i++)
- ret[i] = epoll_wait(self->epoll_fd[i], &event[i], 1, 0);
-
- ASSERT_EQ(ret[0], oob_remaining);
-
- if (self->tcp_compliant)
- ASSERT_EQ(ret[0], ret[1]);
-
- if (oob_remaining) {
- ASSERT_EQ(event[0].events, EPOLLPRI);
-
- if (self->tcp_compliant)
- ASSERT_EQ(event[0].events, event[1].events);
- }
-}
-
-static void __sendpair(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self,
- const void *buf, size_t len, int flags)
-{
- int i, ret[2];
-
- for (i = 0; i < 2; i++) {
- struct signalfd_siginfo siginfo = {};
- int bytes;
-
- ret[i] = send(self->fd[i * 2], buf, len, flags);
-
- bytes = read(self->signal_fd, &siginfo, sizeof(siginfo));
-
- if (flags & MSG_OOB) {
- ASSERT_EQ(bytes, sizeof(siginfo));
- ASSERT_EQ(siginfo.ssi_signo, SIGURG);
-
- bytes = read(self->signal_fd, &siginfo, sizeof(siginfo));
- }
-
- ASSERT_EQ(bytes, -1);
- }
-
- ASSERT_EQ(ret[0], len);
- ASSERT_EQ(ret[0], ret[1]);
-}
-
-static void __recvpair(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self,
- const char *expected_buf, int expected_len,
- int buf_len, int flags, bool is_sender)
-{
- int i, ret[2], recv_errno[2], expected_errno = 0;
- char recv_buf[2][BUF_SZ] = {};
- bool printed = false;
-
- ASSERT_GE(BUF_SZ, buf_len);
-
- errno = 0;
-
- for (i = 0; i < 2; i++) {
- int index = is_sender ? i * 2 : i * 2 + 1;
-
- ret[i] = recv(self->fd[index], recv_buf[i], buf_len, flags);
- recv_errno[i] = errno;
- }
-
- if (expected_len < 0) {
- expected_errno = -expected_len;
- expected_len = -1;
- }
-
- if (ret[0] != expected_len || recv_errno[0] != expected_errno) {
- TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
- TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
-
- ASSERT_EQ(ret[0], expected_len);
- ASSERT_EQ(recv_errno[0], expected_errno);
- }
-
- if (ret[0] != ret[1] || recv_errno[0] != recv_errno[1]) {
- TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
- TH_LOG("TCP :%s", ret[1] < 0 ? strerror(recv_errno[1]) : recv_buf[1]);
-
- printed = true;
-
- if (self->tcp_compliant) {
- ASSERT_EQ(ret[0], ret[1]);
- ASSERT_EQ(recv_errno[0], recv_errno[1]);
- }
- }
-
- if (expected_len >= 0) {
- int cmp;
-
- cmp = strncmp(expected_buf, recv_buf[0], expected_len);
- if (cmp) {
- TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
- TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
-
- ASSERT_EQ(cmp, 0);
- }
-
- cmp = strncmp(recv_buf[0], recv_buf[1], expected_len);
- if (cmp) {
- if (!printed) {
- TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
- TH_LOG("TCP :%s", ret[1] < 0 ? strerror(recv_errno[1]) : recv_buf[1]);
- }
-
- if (self->tcp_compliant)
- ASSERT_EQ(cmp, 0);
- }
- }
-}
-
-static void __setinlinepair(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self)
-{
- int i, oob_inline = 1;
-
- for (i = 0; i < 2; i++) {
- int ret;
-
- ret = setsockopt(self->fd[i * 2 + 1], SOL_SOCKET, SO_OOBINLINE,
- &oob_inline, sizeof(oob_inline));
- ASSERT_EQ(ret, 0);
- }
-}
-
-static void __setblockingpair(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self)
-{
- int i;
-
- for (i = 0; i < 2; i++) {
- int ret, old_flags, flags;
-
- old_flags = fcntl(self->fd[i * 2 + 1], F_GETFL, 0);
- ASSERT_NE(-1, old_flags);
-
- ret = fcntl(self->fd[i * 2 + 1], F_SETFL, old_flags & ~O_NONBLOCK);
- ASSERT_EQ(0, ret);
-
- flags = fcntl(self->fd[i * 2 + 1], F_GETFL, 0);
- ASSERT_EQ(old_flags & ~O_NONBLOCK, flags);
- }
-}
-
-static void __siocatmarkpair(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self,
- bool oob_head)
-{
- int answ[2] = {};
- int i;
-
- for (i = 0; i < 2; i++) {
- int ret;
-
- ret = ioctl(self->fd[i * 2 + 1], SIOCATMARK, &answ[i]);
- ASSERT_EQ(ret, 0);
- }
-
- ASSERT_EQ(answ[0], oob_head);
-
- if (self->tcp_compliant)
- ASSERT_EQ(answ[0], answ[1]);
-}
-
-static void __resetpair(struct __test_metadata *_metadata,
- FIXTURE_DATA(msg_oob) *self,
- const FIXTURE_VARIANT(msg_oob) *variant,
- bool reset)
-{
- int i;
-
- for (i = 0; i < 2; i++)
- close(self->fd[i * 2 + 1]);
-
- __recvpair(_metadata, self, "", reset ? -ECONNRESET : 0, 1,
- variant->peek ? MSG_PEEK : 0, true);
-}
-
-#define sendpair(buf, len, flags) \
- __sendpair(_metadata, self, buf, len, flags)
-
-#define recvpair(expected_buf, expected_len, buf_len, flags) \
- do { \
- if (variant->peek) \
- __recvpair(_metadata, self, \
- expected_buf, expected_len, \
- buf_len, (flags) | MSG_PEEK, false); \
- __recvpair(_metadata, self, \
- expected_buf, expected_len, \
- buf_len, flags, false); \
- } while (0)
-
-#define epollpair(oob_remaining) \
- __epollpair(_metadata, self, oob_remaining)
-
-#define siocatmarkpair(oob_head) \
- __siocatmarkpair(_metadata, self, oob_head)
-
-#define setinlinepair() \
- __setinlinepair(_metadata, self)
-
-#define setblockingpair() \
- __setblockingpair(_metadata, self)
-
-#define resetpair(reset) \
- __resetpair(_metadata, self, variant, reset)
-
-#define tcp_incompliant \
- for (self->tcp_compliant = false; \
- self->tcp_compliant == false; \
- self->tcp_compliant = true)
-
-TEST_F(msg_oob, non_oob)
-{
- sendpair("x", 1, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- recvpair("", -EINVAL, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(true);
-}
-
-TEST_F(msg_oob, non_oob_no_reset)
-{
- sendpair("x", 1, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- recvpair("x", 1, 1, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, oob)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("x", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(true);
-
- tcp_incompliant {
- resetpair(false); /* TCP sets -ECONNRESET for ex-OOB. */
- }
-}
-
-TEST_F(msg_oob, oob_reset)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- resetpair(true);
-}
-
-TEST_F(msg_oob, oob_drop)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("", -EAGAIN, 1, 0); /* Drop OOB. */
- epollpair(false);
- siocatmarkpair(false);
-
- recvpair("", -EINVAL, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, oob_ahead)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("o", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- recvpair("hell", 4, 4, 0);
- epollpair(false);
- siocatmarkpair(true);
-
- tcp_incompliant {
- resetpair(false); /* TCP sets -ECONNRESET for ex-OOB. */
- }
-}
-
-TEST_F(msg_oob, oob_break)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("hell", 4, 5, 0); /* Break at OOB even with enough buffer. */
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("o", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(true);
-
- recvpair("", -EAGAIN, 1, 0);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, oob_ahead_break)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- sendpair("world", 5, 0);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("o", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- recvpair("hell", 4, 9, 0); /* Break at OOB even after it's recv()ed. */
- epollpair(false);
- siocatmarkpair(true);
-
- recvpair("world", 5, 5, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, oob_break_drop)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- sendpair("world", 5, 0);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("hell", 4, 10, 0); /* Break at OOB even with enough buffer. */
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("world", 5, 10, 0); /* Drop OOB and recv() the next skb. */
- epollpair(false);
- siocatmarkpair(false);
-
- recvpair("", -EINVAL, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, ex_oob_break)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- sendpair("wor", 3, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- sendpair("ld", 2, 0);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("hellowo", 7, 10, 0); /* Break at OOB but not at ex-OOB. */
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("r", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(true);
-
- recvpair("ld", 2, 2, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, ex_oob_drop)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- sendpair("y", 1, MSG_OOB); /* TCP drops "x" at this moment. */
- epollpair(true);
-
- tcp_incompliant {
- siocatmarkpair(false);
-
- recvpair("x", 1, 1, 0); /* TCP drops "y" by passing through it. */
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("y", 1, 1, MSG_OOB); /* TCP returns -EINVAL. */
- epollpair(false);
- siocatmarkpair(true);
- }
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, ex_oob_drop_2)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- sendpair("y", 1, MSG_OOB); /* TCP drops "x" at this moment. */
- epollpair(true);
-
- tcp_incompliant {
- siocatmarkpair(false);
- }
-
- recvpair("y", 1, 1, MSG_OOB);
- epollpair(false);
-
- tcp_incompliant {
- siocatmarkpair(false);
-
- recvpair("x", 1, 1, 0); /* TCP returns -EAGAIN. */
- epollpair(false);
- siocatmarkpair(true);
- }
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, ex_oob_oob)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("x", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(true);
-
- sendpair("y", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("", -EAGAIN, 1, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- recvpair("", -EINVAL, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, ex_oob_ex_oob)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("x", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(true);
-
- sendpair("y", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("y", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(true);
-
- tcp_incompliant {
- resetpair(false); /* TCP sets -ECONNRESET for ex-OOB. */
- }
-}
-
-TEST_F(msg_oob, ex_oob_ex_oob_oob)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("x", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(true);
-
- sendpair("y", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("y", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(true);
-
- sendpair("z", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-}
-
-TEST_F(msg_oob, ex_oob_ahead_break)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- sendpair("wor", 3, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("r", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- sendpair("ld", 2, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- tcp_incompliant {
- recvpair("hellowol", 8, 10, 0); /* TCP recv()s "helloworl", why "r" ?? */
- }
-
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("d", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(true);
-
- tcp_incompliant {
- resetpair(false); /* TCP sets -ECONNRESET for ex-OOB. */
- }
-}
-
-TEST_F(msg_oob, ex_oob_siocatmark)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("o", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- sendpair("world", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("hell", 4, 4, 0); /* Intentionally stop at ex-OOB. */
- epollpair(true);
- siocatmarkpair(false);
-
- resetpair(true);
-}
-
-TEST_F(msg_oob, inline_oob)
-{
- setinlinepair();
-
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("", -EINVAL, 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("x", 1, 1, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, inline_oob_break)
-{
- setinlinepair();
-
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("", -EINVAL, 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("hell", 4, 5, 0); /* Break at OOB but not at ex-OOB. */
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("o", 1, 1, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, inline_oob_ahead_break)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- sendpair("world", 5, 0);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("o", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- setinlinepair();
-
- recvpair("hell", 4, 9, 0); /* Break at OOB even with enough buffer. */
- epollpair(false);
- siocatmarkpair(true);
-
- tcp_incompliant {
- recvpair("world", 5, 6, 0); /* TCP recv()s "oworld", ... "o" ??? */
- }
-
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, inline_ex_oob_break)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- sendpair("wor", 3, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- sendpair("ld", 2, 0);
- epollpair(true);
- siocatmarkpair(false);
-
- setinlinepair();
-
- recvpair("hellowo", 7, 10, 0); /* Break at OOB but not at ex-OOB. */
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("rld", 3, 3, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, inline_ex_oob_no_drop)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- setinlinepair();
-
- sendpair("y", 1, MSG_OOB); /* TCP does NOT drops "x" at this moment. */
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("x", 1, 1, 0);
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("y", 1, 1, 0);
- epollpair(false);
- siocatmarkpair(false);
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, inline_ex_oob_drop)
-{
- sendpair("x", 1, MSG_OOB);
- epollpair(true);
- siocatmarkpair(true);
-
- sendpair("y", 1, MSG_OOB); /* TCP drops "x" at this moment. */
- epollpair(true);
-
- setinlinepair();
-
- tcp_incompliant {
- siocatmarkpair(false);
-
- recvpair("x", 1, 1, 0); /* TCP recv()s "y". */
- epollpair(true);
- siocatmarkpair(true);
-
- recvpair("y", 1, 1, 0); /* TCP returns -EAGAIN. */
- epollpair(false);
- siocatmarkpair(false);
- }
-
- resetpair(false);
-}
-
-TEST_F(msg_oob, inline_ex_oob_siocatmark)
-{
- sendpair("hello", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("o", 1, 1, MSG_OOB);
- epollpair(false);
- siocatmarkpair(false);
-
- setinlinepair();
-
- sendpair("world", 5, MSG_OOB);
- epollpair(true);
- siocatmarkpair(false);
-
- recvpair("hell", 4, 4, 0); /* Intentionally stop at ex-OOB. */
- epollpair(true);
- siocatmarkpair(false);
-
- resetpair(true);
-}
-
-TEST_F(msg_oob, zero_buf_oob)
-{
- sendpair("a", 1, MSG_OOB);
- recvpair("", 0, 0, 0);
-}
-
-TEST_F(msg_oob, zero_buf_oob_blocking)
-{
- sendpair("a", 1, MSG_OOB);
- setblockingpair();
- recvpair("", 0, 0, 0);
-}
-
-TEST_F(msg_oob, zero_buf_non_oob_oob)
-{
- sendpair("ab", 2, MSG_OOB);
- recvpair("", 0, 0, 0);
-}
-
-TEST_F(msg_oob, zero_buf_non_oob_oob_blocking)
-{
- sendpair("ab", 2, MSG_OOB);
- setblockingpair();
- recvpair("", 0, 0, 0);
-}
-
-TEST_F(msg_oob, zero_buf_ex_oob_oob)
-{
- sendpair("a", 1, MSG_OOB);
- recvpair("a", 1, 1, MSG_OOB);
-
- sendpair("b", 1, MSG_OOB);
- recvpair("", 0, 0, 0);
-}
-
-TEST_F(msg_oob, zero_buf_ex_oob_oob_blocking)
-{
- sendpair("a", 1, MSG_OOB);
- recvpair("a", 1, 1, MSG_OOB);
-
- sendpair("b", 1, MSG_OOB);
- setblockingpair();
- recvpair("", 0, 0, 0);
-}
-
-TEST_HARNESS_MAIN
diff --git a/tools/testing/selftests/net/af_unix/scm_rights.c b/tools/testing/selftests/net/af_unix/scm_rights.c
index c165f250220a..40459fb21b73 100644
--- a/tools/testing/selftests/net/af_unix/scm_rights.c
+++ b/tools/testing/selftests/net/af_unix/scm_rights.c
@@ -21,7 +21,6 @@ FIXTURE_VARIANT(scm_rights)
{
char name[32];
int type;
- int flags;
bool test_listener;
bool disabled;
};
@@ -30,7 +29,6 @@ FIXTURE_VARIANT_ADD(scm_rights, dgram)
{
.name = "UNIX ",
.type = SOCK_DGRAM,
- .flags = 0,
.test_listener = false,
.disabled = false,
};
@@ -39,7 +37,6 @@ FIXTURE_VARIANT_ADD(scm_rights, dgram_disabled)
{
.name = "UNIX ",
.type = SOCK_DGRAM,
- .flags = 0,
.test_listener = false,
.disabled = true,
};
@@ -48,7 +45,6 @@ FIXTURE_VARIANT_ADD(scm_rights, stream)
{
.name = "UNIX-STREAM ",
.type = SOCK_STREAM,
- .flags = 0,
.test_listener = false,
.disabled = false,
};
@@ -57,25 +53,6 @@ FIXTURE_VARIANT_ADD(scm_rights, stream_disabled)
{
.name = "UNIX-STREAM ",
.type = SOCK_STREAM,
- .flags = 0,
- .test_listener = false,
- .disabled = true,
-};
-
-FIXTURE_VARIANT_ADD(scm_rights, stream_oob)
-{
- .name = "UNIX-STREAM ",
- .type = SOCK_STREAM,
- .flags = MSG_OOB,
- .test_listener = false,
- .disabled = false,
-};
-
-FIXTURE_VARIANT_ADD(scm_rights, stream_oob_disabled)
-{
- .name = "UNIX-STREAM ",
- .type = SOCK_STREAM,
- .flags = MSG_OOB,
.test_listener = false,
.disabled = true,
};
@@ -84,7 +61,6 @@ FIXTURE_VARIANT_ADD(scm_rights, stream_listener)
{
.name = "UNIX-STREAM ",
.type = SOCK_STREAM,
- .flags = 0,
.test_listener = true,
.disabled = false,
};
@@ -93,25 +69,6 @@ FIXTURE_VARIANT_ADD(scm_rights, stream_listener_disabled)
{
.name = "UNIX-STREAM ",
.type = SOCK_STREAM,
- .flags = 0,
- .test_listener = true,
- .disabled = true,
-};
-
-FIXTURE_VARIANT_ADD(scm_rights, stream_listener_oob)
-{
- .name = "UNIX-STREAM ",
- .type = SOCK_STREAM,
- .flags = MSG_OOB,
- .test_listener = true,
- .disabled = false,
-};
-
-FIXTURE_VARIANT_ADD(scm_rights, stream_listener_oob_disabled)
-{
- .name = "UNIX-STREAM ",
- .type = SOCK_STREAM,
- .flags = MSG_OOB,
.test_listener = true,
.disabled = true,
};
@@ -297,7 +254,7 @@ void __send_fd(struct __test_metadata *_metadata,
cmsg->cmsg_len = CMSG_LEN(sizeof(fds));
memcpy(CMSG_DATA(cmsg), fds, sizeof(fds));
- ret = sendmsg(self->fd[receiver * 2 + 1], &msg, variant->flags);
+ ret = sendmsg(self->fd[receiver * 2 + 1], &msg, 0);
if (variant->disabled) {
ASSERT_EQ(-1, ret);
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v1 net-next 4/4] af_unix: Remove MSG_OOB.
2026-11-16 2:18 [PATCH v1 net-next 0/4] af_unix: Drop MSG_OOB support Kuniyuki Iwashima
` (2 preceding siblings ...)
2026-11-16 2:18 ` [PATCH v1 net-next 3/4] selftests: af_unix: Remove MSG_OOB tests Kuniyuki Iwashima
@ 2026-11-16 2:18 ` Kuniyuki Iwashima
3 siblings, 0 replies; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-11-16 2:18 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
Security folks love MSG_OOB and it has had many bugs with
CVEs assigned.
The volume of bugs from MSG_OOB led to CONFIG_AF_UNIX_OOB,
but the default was 'y' even though there is no clear use case,
exposing innocent users to security risks.
Most of such bugs are trivial if CONFIG_AF_UNIX_OOB is not
enabled, but typically MSG_OOB allowed serious consequences,
such as LPE.
Considering RFC 6093 deprecated MSG_OOB for TCP in 2011, we
should not have accepted it for AF_UNIX from day 1.
It is time to drop support.
Along with that, ioctl(SIOCATMARK), EPOLLPRI, etc become
unavailable as if CONFIG_AF_UNIX_OOB=n.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
include/net/af_unix.h | 3 -
include/net/dropreason-core.h | 6 -
net/unix/Kconfig | 7 -
net/unix/af_unix.c | 252 +---------------------------------
4 files changed, 1 insertion(+), 267 deletions(-)
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index bb1b3dee02e8..43fb892eee06 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -50,9 +50,6 @@ struct unix_sock {
int inq_len;
bool recvmsg_inq;
bool scm_rights_notrunc;
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- struct sk_buff *oob_skb;
-#endif
};
#define unix_sk(ptr) container_of_const(ptr, struct unix_sock, sk)
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index fa2fe8990557..c010fdebf249 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -10,7 +10,6 @@
FN(SOCKET_FILTER) \
FN(SOCKET_RCVBUFF) \
FN(UNIX_DISCONNECT) \
- FN(UNIX_SKIP_OOB) \
FN(PKT_TOO_SMALL) \
FN(TCP_CSUM) \
FN(UDP_CSUM) \
@@ -164,11 +163,6 @@ enum skb_drop_reason {
* during send() that the peer has been close()d.
*/
SKB_DROP_REASON_UNIX_DISCONNECT,
- /**
- * @SKB_DROP_REASON_UNIX_SKIP_OOB: Out-Of-Band data is skipped by
- * recv() without MSG_OOB so dropped.
- */
- SKB_DROP_REASON_UNIX_SKIP_OOB,
/** @SKB_DROP_REASON_PKT_TOO_SMALL: packet size is too small */
SKB_DROP_REASON_PKT_TOO_SMALL,
/** @SKB_DROP_REASON_TCP_CSUM: TCP checksum error */
diff --git a/net/unix/Kconfig b/net/unix/Kconfig
index 6f1783c1659b..d378726d5eb9 100644
--- a/net/unix/Kconfig
+++ b/net/unix/Kconfig
@@ -16,13 +16,6 @@ config UNIX
Say Y unless you know what you are doing.
-config AF_UNIX_OOB
- bool "UNIX: out-of-bound messages"
- depends on UNIX
- default y
- help
- Support for MSG_OOB in UNIX domain sockets. If unsure, say Y.
-
config UNIX_DIAG
tristate "UNIX: socket monitoring interface"
depends on UNIX
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 96c13682938e..cc5c7fa40b4d 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -688,20 +688,12 @@ static void unix_release_sock(struct sock *sk, int embrion)
unix_state_unlock(sk);
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- u->oob_skb = NULL;
-#endif
-
wake_up_interruptible_all(&u->peer_wait);
if (skpair != NULL) {
if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) {
struct sk_buff *skb = skb_peek(&sk->sk_receive_queue);
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- if (skb && !unix_skb_len(skb))
- skb = skb_peek_next(skb, &sk->sk_receive_queue);
-#endif
unix_state_lock(skpair);
/* No more writes */
WRITE_ONCE(skpair->sk_shutdown, SHUTDOWN_MASK);
@@ -2325,67 +2317,6 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
*/
#define UNIX_SKB_FRAGS_SZ (PAGE_SIZE << get_order(32768))
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
-static int queue_oob(struct sock *sk, struct msghdr *msg, struct sock *other,
- struct scm_cookie *scm, bool fds_sent)
-{
- struct unix_sock *ousk = unix_sk(other);
- struct sk_buff *skb;
- int err;
-
- skb = sock_alloc_send_skb(sk, 1, msg->msg_flags & MSG_DONTWAIT, &err);
-
- if (!skb)
- return err;
-
- err = unix_scm_to_skb(scm, skb, !fds_sent);
- if (err < 0)
- goto out;
-
- err = unix_maybe_add_creds(skb, sk, other);
- if (err)
- goto out;
-
- skb_put(skb, 1);
- err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, 1);
-
- if (err)
- goto out;
-
- unix_state_lock(other);
-
- if (sock_flag(other, SOCK_DEAD) ||
- (other->sk_shutdown & RCV_SHUTDOWN)) {
- err = -EPIPE;
- goto out_unlock;
- }
-
- if (UNIXCB(skb).fp && !other->sk_scm_rights) {
- err = -EPERM;
- goto out_unlock;
- }
-
- scm_stat_add(other, skb);
-
- spin_lock(&other->sk_receive_queue.lock);
- WRITE_ONCE(ousk->oob_skb, skb);
- WRITE_ONCE(ousk->inq_len, ousk->inq_len + 1);
- __skb_queue_tail(&other->sk_receive_queue, skb);
- spin_unlock(&other->sk_receive_queue.lock);
-
- sk_send_sigurg(other);
- unix_state_unlock(other);
- READ_ONCE(other->sk_data_ready)(other);
-
- return 0;
-out_unlock:
- unix_state_unlock(other);
-out:
- consume_skb(skb);
- return err;
-}
-#endif
-
static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
size_t len)
{
@@ -2403,12 +2334,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
if (msg->msg_flags & MSG_OOB) {
err = -EOPNOTSUPP;
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- if (len)
- len--;
- else
-#endif
- goto out_err;
+ goto out_err;
}
if (msg->msg_namelen) {
@@ -2505,15 +2431,6 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
sent += size;
}
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- if (msg->msg_flags & MSG_OOB) {
- err = queue_oob(sk, msg, other, &scm, fds_sent);
- if (err)
- goto out_err;
- sent++;
- }
-#endif
-
scm_destroy(&scm);
return sent;
@@ -2765,115 +2682,6 @@ struct unix_stream_read_state {
unsigned int splice_flags;
};
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
-static int unix_stream_recv_urg(struct unix_stream_read_state *state)
-{
- struct sk_buff *oob_skb, *read_skb = NULL;
- struct socket *sock = state->socket;
- struct sock *sk = sock->sk;
- struct unix_sock *u = unix_sk(sk);
- int chunk = 1;
-
- mutex_lock(&u->iolock);
- unix_state_lock(sk);
- spin_lock(&sk->sk_receive_queue.lock);
-
- if (sock_flag(sk, SOCK_URGINLINE) || !u->oob_skb) {
- spin_unlock(&sk->sk_receive_queue.lock);
- unix_state_unlock(sk);
- mutex_unlock(&u->iolock);
- return -EINVAL;
- }
-
- oob_skb = u->oob_skb;
-
- if (!(state->flags & MSG_PEEK)) {
- WRITE_ONCE(u->oob_skb, NULL);
- WRITE_ONCE(u->inq_len, u->inq_len - 1);
-
- if (oob_skb->prev != (struct sk_buff *)&sk->sk_receive_queue &&
- !unix_skb_len(oob_skb->prev)) {
- read_skb = oob_skb->prev;
- __skb_unlink(read_skb, &sk->sk_receive_queue);
- }
- }
-
- spin_unlock(&sk->sk_receive_queue.lock);
- unix_state_unlock(sk);
-
- chunk = state->recv_actor(oob_skb, 0, chunk, state);
-
- if (!(state->flags & MSG_PEEK))
- UNIXCB(oob_skb).consumed += 1;
-
- mutex_unlock(&u->iolock);
-
- consume_skb(read_skb);
-
- if (chunk < 0)
- return -EFAULT;
-
- state->msg->msg_flags |= MSG_OOB;
- return 1;
-}
-
-static struct sk_buff *manage_oob(struct sk_buff *skb, struct sk_buff **last,
- struct sock *sk, int flags, int copied)
-{
- struct sk_buff *read_skb = NULL, *unread_skb = NULL;
- struct unix_sock *u = unix_sk(sk);
-
- if (likely(unix_skb_len(skb) && skb != READ_ONCE(u->oob_skb)))
- return skb;
-
- spin_lock(&sk->sk_receive_queue.lock);
-
- if (!unix_skb_len(skb)) {
- if (copied && (!u->oob_skb || skb == u->oob_skb)) {
- skb = NULL;
- } else if (flags & MSG_PEEK) {
- *last = skb;
- skb = skb_peek_next(skb, &sk->sk_receive_queue);
- } else {
- read_skb = skb;
- skb = skb_peek_next(skb, &sk->sk_receive_queue);
- __skb_unlink(read_skb, &sk->sk_receive_queue);
- *last = skb;
- }
-
- if (!skb)
- goto unlock;
- }
-
- if (skb != u->oob_skb)
- goto unlock;
-
- if (copied) {
- skb = NULL;
- } else if (!(flags & MSG_PEEK)) {
- WRITE_ONCE(u->oob_skb, NULL);
-
- if (!sock_flag(sk, SOCK_URGINLINE)) {
- __skb_unlink(skb, &sk->sk_receive_queue);
- unread_skb = skb;
- skb = skb_peek(&sk->sk_receive_queue);
- *last = skb;
- }
- } else if (!sock_flag(sk, SOCK_URGINLINE)) {
- *last = skb;
- skb = skb_peek_next(skb, &sk->sk_receive_queue);
- }
-
-unlock:
- spin_unlock(&sk->sk_receive_queue.lock);
-
- consume_skb(read_skb);
- kfree_skb_reason(unread_skb, SKB_DROP_REASON_UNIX_SKIP_OOB);
-
- return skb;
-}
-#endif
-
static int unix_stream_read_skb(struct sock *sk, skb_read_actor_t recv_actor)
{
struct sk_buff_head *queue = &sk->sk_receive_queue;
@@ -2900,17 +2708,6 @@ static int unix_stream_read_skb(struct sock *sk, skb_read_actor_t recv_actor)
WRITE_ONCE(u->inq_len, u->inq_len - unix_skb_len(skb));
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- if (skb == u->oob_skb) {
- WRITE_ONCE(u->oob_skb, NULL);
- spin_unlock(&queue->lock);
- mutex_unlock(&u->iolock);
-
- kfree_skb_reason(skb, SKB_DROP_REASON_UNIX_SKIP_OOB);
- return -EAGAIN;
- }
-#endif
-
spin_unlock(&queue->lock);
unix_orphan_scm(sk, skb);
@@ -2945,9 +2742,6 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state,
if (unlikely(flags & MSG_OOB)) {
err = -EOPNOTSUPP;
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- err = unix_stream_recv_urg(state);
-#endif
goto out;
}
@@ -2978,15 +2772,6 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state,
last = skb = skb_peek(&sk->sk_receive_queue);
again:
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- if (skb) {
- skb = manage_oob(skb, &last, sk, flags, copied);
- if (!skb && (copied || !state->size)) {
- unix_state_unlock(sk);
- break;
- }
- }
-#endif
if (skb == NULL) {
if (copied >= target)
goto unlock;
@@ -3322,37 +3107,6 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case SIOCUNIXFILE:
err = unix_open_file(sk);
break;
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- case SIOCATMARK:
- {
- struct unix_sock *u = unix_sk(sk);
- struct sk_buff *skb;
- int answ = 0;
-
- if (sk->sk_type != SOCK_STREAM)
- return -EOPNOTSUPP;
-
- mutex_lock(&u->iolock);
-
- skb = skb_peek(&sk->sk_receive_queue);
- if (skb) {
- struct sk_buff *oob_skb = READ_ONCE(u->oob_skb);
- struct sk_buff *next_skb;
-
- next_skb = skb_peek_next(skb, &sk->sk_receive_queue);
-
- if (skb == oob_skb ||
- (!unix_skb_len(skb) &&
- (!oob_skb || next_skb == oob_skb)))
- answ = 1;
- }
-
- mutex_unlock(&u->iolock);
-
- err = put_user(answ, (int __user *)arg);
- }
- break;
-#endif
default:
err = -ENOIOCTLCMD;
break;
@@ -3392,10 +3146,6 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa
mask |= EPOLLIN | EPOLLRDNORM;
if (sk_is_readable(sk))
mask |= EPOLLIN | EPOLLRDNORM;
-#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- if (READ_ONCE(unix_sk(sk)->oob_skb))
- mask |= EPOLLPRI;
-#endif
/* Connection-based need to check for termination and startup */
if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) &&
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread