netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] scm: fix MSG_CTRUNC setting condition for SO_PASSSEC
@ 2023-02-26 20:17 Alexander Mikhalitsyn
  2023-02-27  9:47 ` Leon Romanovsky
  2023-02-27 10:01 ` Eric Dumazet
  0 siblings, 2 replies; 9+ messages in thread
From: Alexander Mikhalitsyn @ 2023-02-26 20:17 UTC (permalink / raw)
  To: davem
  Cc: linux-kernel, netdev, Alexander Mikhalitsyn, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni

Currently, we set MSG_CTRUNC flag is we have no
msg_control buffer provided and SO_PASSCRED is set
or if we have pending SCM_RIGHTS.

For some reason we have no corresponding check for
SO_PASSSEC.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
---
 include/net/scm.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/net/scm.h b/include/net/scm.h
index 1ce365f4c256..585adc1346bd 100644
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -105,16 +105,27 @@ static inline void scm_passec(struct socket *sock, struct msghdr *msg, struct sc
 		}
 	}
 }
+
+static inline bool scm_has_secdata(struct socket *sock)
+{
+	return test_bit(SOCK_PASSSEC, &sock->flags);
+}
 #else
 static inline void scm_passec(struct socket *sock, struct msghdr *msg, struct scm_cookie *scm)
 { }
+
+static inline bool scm_has_secdata(struct socket *sock)
+{
+	return false;
+}
 #endif /* CONFIG_SECURITY_NETWORK */
 
 static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,
 				struct scm_cookie *scm, int flags)
 {
 	if (!msg->msg_control) {
-		if (test_bit(SOCK_PASSCRED, &sock->flags) || scm->fp)
+		if (test_bit(SOCK_PASSCRED, &sock->flags) || scm->fp ||
+		    scm_has_secdata(sock))
 			msg->msg_flags |= MSG_CTRUNC;
 		scm_destroy(scm);
 		return;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-02-28 15:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-26 20:17 [PATCH net-next] scm: fix MSG_CTRUNC setting condition for SO_PASSSEC Alexander Mikhalitsyn
2023-02-27  9:47 ` Leon Romanovsky
2023-02-27  9:55   ` Aleksandr Mikhalitsyn
2023-02-27 18:32     ` Leon Romanovsky
2023-02-28 10:06       ` Aleksandr Mikhalitsyn
2023-02-28 14:45         ` Leon Romanovsky
2023-02-28 15:10           ` Aleksandr Mikhalitsyn
2023-02-27 10:01 ` Eric Dumazet
2023-02-27 10:21   ` Aleksandr Mikhalitsyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).