16.11.2024 04:10, Kuniyuki Iwashima пишет:
Now this allows sending pidfd without SO_PASSPIDFD, so you need to
add a validation for "if (!msg->msg_control)" in __scm_recv_common().
Will do, thanks.
Btw don't we need MSG_CTRUNC in
such case even if "msg_control"exists?
Or the established practice is to just drop cmsg silently?
I mean, something like the below:
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -176,12 +176,19 @@ static inline bool __scm_recv_common(struct socket
*sock, struct msghdr *msg,
if (!msg->msg_control) {
if (test_bit(SOCK_PASSCRED, &sock->flags) ||
test_bit(SOCK_PASSPIDFD, &sock->flags) ||
- scm->fp || scm_has_secdata(sock))
+ scm->fp || scm_has_secdata(sock) ||
+ scm->pidfd_flags)
msg->msg_flags |= MSG_CTRUNC;
scm_destroy(scm);
return false;
}
+ if (!test_bit(SOCK_PASSPIDFD, &sock->flags) && scm->pidfd_flags) {
+ msg->msg_flags |= MSG_CTRUNC;
+ scm_destroy(scm);
+ return false;
+ }
+
if (test_bit(SOCK_PASSCRED, &sock->flags)) {
struct user_namespace *current_ns = current_user_ns();
struct ucred ucreds = {