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@xxxxxxxxxx>
---
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);