All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@google.com>
To: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	 Kuniyuki Iwashima <kuni1840@gmail.com>,
	netdev@vger.kernel.org
Subject: [PATCH v1 net-next 4/4] af_unix: Remove MSG_OOB.
Date: Mon, 16 Nov 2026 02:18:21 +0000	[thread overview]
Message-ID: <20261116021845.2533130-5-kuniyu@google.com> (raw)
In-Reply-To: <20261116021845.2533130-1-kuniyu@google.com>

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


  parent reply	other threads:[~2026-11-16  2:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-17  2:19   ` sashiko-bot
2026-11-17 17:19   ` netdev-bot+sashiko
2026-11-18  1:37     ` 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-17 17:19   ` netdev-bot+sashiko
2026-11-18  1:43     ` Kuniyuki Iwashima
2026-11-18  2:23   ` Jiayuan Chen
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 [this message]
2026-11-17 17:19   ` [PATCH v1 net-next 4/4] af_unix: Remove MSG_OOB netdev-bot+sashiko
2026-11-18  1:46     ` Kuniyuki Iwashima

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116021845.2533130-5-kuniyu@google.com \
    --to=kuniyu@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.