Netdev List
 help / color / mirror / Atom feed
From: Jori Koolstra <jkoolstra@xs4all.nl>
To: brauner@kernel.org, cyphar@cyphar.com, kuniyu@google.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org
Cc: netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, jkoolstra@xs4all.nl
Subject: [PATCH net-next v6 2/4] net: scm: move scm_detach_fds() from common path to scm_recv_unix()
Date: Sun,  2 Aug 2026 17:12:10 +0200	[thread overview]
Message-ID: <20260802151212.3294591-3-jkoolstra@xs4all.nl> (raw)
In-Reply-To: <20260802151212.3294591-1-jkoolstra@xs4all.nl>

scm->fp can only be set when using UNIX sockets, therefore we should
move it out of the common path __scm_recv_common() into
scm_recv_unix().

Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
---
 net/core/scm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/scm.c b/net/core/scm.c
index eec13f50ecaf..a73b1eb30fd2 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -523,9 +523,6 @@ static bool __scm_recv_common(struct sock *sk, struct msghdr *msg,
 
 	scm_passec(sk, msg, scm);
 
-	if (scm->fp)
-		scm_detach_fds(msg, scm);
-
 	return true;
 }
 
@@ -545,6 +542,9 @@ void scm_recv_unix(struct socket *sock, struct msghdr *msg,
 	if (!__scm_recv_common(sock->sk, msg, scm, flags))
 		return;
 
+	if (scm->fp)
+		scm_detach_fds(msg, scm);
+
 	if (sock->sk->sk_scm_pidfd)
 		scm_pidfd_recv(msg, scm);
 
-- 
2.55.0


  parent reply	other threads:[~2026-08-02 15:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02 15:12 [PATCH net-next v6 0/4] net: af_unix: useful handling of LSM denials on SCM_RIGHTS Jori Koolstra
2026-08-02 15:12 ` [PATCH net-next v6 1/4] net: af_unix: enable custom setsockopt for all socket types Jori Koolstra
2026-08-04 16:49   ` Kuniyuki Iwashima
2026-08-02 15:12 ` Jori Koolstra [this message]
2026-08-02 15:12 ` [PATCH net-next v6 3/4] net: af_unix: useful handling of LSM denials on SCM_RIGHTS Jori Koolstra
2026-08-04 17:16   ` Kuniyuki Iwashima
2026-08-05 10:09     ` Jori Koolstra
2026-08-05 16:27       ` Kuniyuki Iwashima
2026-08-02 15:12 ` [PATCH net-next v6 4/4] selftest: Add tests for " Jori Koolstra
2026-08-04 17:26   ` Kuniyuki Iwashima
2026-08-05 10:18     ` Jori Koolstra
2026-08-05 16:30       ` 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=20260802151212.3294591-3-jkoolstra@xs4all.nl \
    --to=jkoolstra@xs4all.nl \
    --cc=brauner@kernel.org \
    --cc=cyphar@cyphar.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox