[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211021123714.1125384-6-marcandre.lureau@redhat.com>
Date: Thu, 21 Oct 2021 16:37:09 +0400
From: Marc-André Lureau <marcandre.lureau@...hat.com>
To: netdev@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, sgarzare@...hat.com,
davem@...emloft.net, kuba@...nel.org,
Marc-André Lureau <marcandre.lureau@...hat.com>
Subject: [PATCH 05/10] virtio/vsock: add copy_peercred() to virtio_transport
Signed-off-by: Marc-André Lureau <marcandre.lureau@...hat.com>
---
include/linux/virtio_vsock.h | 2 ++
net/vmw_vsock/virtio_transport_common.c | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h
index 35d7eedb5e8e..2445bece9216 100644
--- a/include/linux/virtio_vsock.h
+++ b/include/linux/virtio_vsock.h
@@ -69,6 +69,8 @@ struct virtio_transport {
/* Takes ownership of the packet */
int (*send_pkt)(struct virtio_vsock_pkt *pkt);
+ /* Set peercreds on socket created after listen recv */
+ void (*copy_peercred)(struct sock *sk, struct virtio_vsock_pkt *pkt);
};
ssize_t
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 59ee1be5a6dd..611d25e80723 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -1194,6 +1194,15 @@ virtio_transport_recv_listen(struct sock *sk, struct virtio_vsock_pkt *pkt,
return -ENOMEM;
}
+ if (t->copy_peercred) {
+ t->copy_peercred(child, pkt);
+ } else {
+ put_pid(child->sk_peer_pid);
+ child->sk_peer_pid = NULL;
+ put_cred(child->sk_peer_cred);
+ child->sk_peer_cred = NULL;
+ }
+
sk_acceptq_added(sk);
lock_sock_nested(child, SINGLE_DEPTH_NESTING);
--
2.33.0.721.g106298f7f9
Powered by blists - more mailing lists