[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241206052607.1197-8-kuniyu@amazon.com>
Date: Fri, 6 Dec 2024 14:25:59 +0900
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
<pabeni@...hat.com>
CC: Kuniyuki Iwashima <kuniyu@...zon.com>, Kuniyuki Iwashima
<kuni1840@...il.com>, <netdev@...r.kernel.org>
Subject: [PATCH v1 net-next 07/15] af_unix: Call unix_autobind() only when msg_namelen is specified in unix_dgram_sendmsg().
If unix_peer_get() returns non-NULL in unix_dgram_sendmsg(), the socket
have been already bound in unix_dgram_connect() or unix_bind().
Let's not call unix_autobind() in such a case in unix_dgram_sendmsg().
Signed-off-by: Kuniyuki Iwashima <kuniyu@...zon.com>
---
net/unix/af_unix.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index e439829efc56..6fb1811da4cd 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1994,6 +1994,14 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
NULL);
if (err)
goto out;
+
+ if ((test_bit(SOCK_PASSCRED, &sock->flags) ||
+ test_bit(SOCK_PASSPIDFD, &sock->flags)) &&
+ !READ_ONCE(u->addr)) {
+ err = unix_autobind(sk);
+ if (err)
+ goto out;
+ }
} else {
sunaddr = NULL;
other = unix_peer_get(sk);
@@ -2003,14 +2011,6 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
}
}
- if ((test_bit(SOCK_PASSCRED, &sock->flags) ||
- test_bit(SOCK_PASSPIDFD, &sock->flags)) &&
- !READ_ONCE(u->addr)) {
- err = unix_autobind(sk);
- if (err)
- goto out;
- }
-
if (len > READ_ONCE(sk->sk_sndbuf) - 32) {
err = -EMSGSIZE;
goto out;
--
2.39.5 (Apple Git-154)
Powered by blists - more mailing lists