[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211021123714.1125384-7-marcandre.lureau@redhat.com>
Date: Thu, 21 Oct 2021 16:37:10 +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 06/10] vsock: set socket peercred
When AF_VSOCK socket is created, the peercreds are set to the current
process values.
This is how AF_UNIX listen work too, but unconnected AF_UNIX sockets
return pid:0 & uid/gid:-1.
Signed-off-by: Marc-André Lureau <marcandre.lureau@...hat.com>
---
net/vmw_vsock/af_vsock.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 1925682a942a..9b211ff49b08 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -760,6 +760,7 @@ static struct sock *__vsock_create(struct net *net,
psk = parent ? vsock_sk(parent) : NULL;
if (parent) {
+ sock_copy_peercred(sk, parent);
vsk->trusted = psk->trusted;
#if IS_ENABLED(CONFIG_VMWARE_VMCI_VSOCKETS)
vsk->owner = get_cred(psk->owner);
@@ -770,6 +771,7 @@ static struct sock *__vsock_create(struct net *net,
vsk->buffer_max_size = psk->buffer_max_size;
security_sk_clone(parent, sk);
} else {
+ sock_init_peercred(sk);
vsk->trusted = ns_capable_noaudit(&init_user_ns, CAP_NET_ADMIN);
#if IS_ENABLED(CONFIG_VMWARE_VMCI_VSOCKETS)
vsk->owner = get_current_cred();
--
2.33.0.721.g106298f7f9
Powered by blists - more mailing lists