Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp582425pxb; Thu, 21 Oct 2021 05:40:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNXYr+BM2zg3Y+b/loA1+GtfaoIdENWNCqQPmlT3GkTsbiVxskN8OWBb6b/a39PnQFOIQM X-Received: by 2002:a05:6402:3d6:: with SMTP id t22mr7643568edw.240.1634820038530; Thu, 21 Oct 2021 05:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634820038; cv=none; d=google.com; s=arc-20160816; b=CMVOn7I2sp7Zzb1YPSyN11c42o8nIZbPN4PAT1JnsUh4BgnY1cj/Mz4F/s5MNY6FF/ GVHXQb1tFCxwrtAfJTPFMakmIiDvvfgo5bFBkLccGjKJTTvDYhxa/vaQc1LG1w59t30a CuwyNoZdMqA+jcAbzKP7JHJN4t4AuQ3lhwRpPwXTDaDqv7cIsqj+0AWXoBo4KoxbZo/0 IOy5m1GctnRCf+vqDAFx0B8bPJwKKuRyk9vNWl/20HyQzzrRpJolojXCqMcbCizpE3/V DltXOZ30JbFzMcXK1Ai4FwvG/KkgDNSOP33GzFMCvHZbCrsSA+5s9vJ2IXhXXnwHR5k7 uA+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SnZ3ounfBlwh4UazSm19Od83jKUAVNgDJA6/wGPAT4Q=; b=zsIoBOWeqAHoN6NwvfWdpMKSh8+8+M9IMgyj1w+nnYMBTp+kLEUH+v67xuvU4Em3HE 3GCKQP3N2QUG7WVCCXboqOx/oDV2OwbZXCq1yb1ZOqF/eLQDzMSvhPMGF9zyuEl/Fq53 +/9ERnpaw4IMPSlzJNyRe3A1WBztz63n/pvKSGs6nAyM2w46yDNUoxR8J2EwCn9/oKJB 3DpK6bXPD4MFwmAY4brKkpnmJ0s2vOHSvaXzu5APwYc3MEWpC7pFTtisyY4+GqEyk1T5 XrGDC+RC2WGndZDkFyEICBkAeGqKhHZa3n5/5TrglmlKuvHSJWp4USoW8rfrikQWedDr n9SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TAIIEi2O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si10924162edd.214.2021.10.21.05.40.13; Thu, 21 Oct 2021 05:40:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TAIIEi2O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231196AbhJUMkY (ORCPT + 99 others); Thu, 21 Oct 2021 08:40:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40280 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231365AbhJUMkR (ORCPT ); Thu, 21 Oct 2021 08:40:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634819881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SnZ3ounfBlwh4UazSm19Od83jKUAVNgDJA6/wGPAT4Q=; b=TAIIEi2Ok/HOrQYTLGcNICqWpne4kLkpX68xX/HXS63+rVbmj4svh57A2xk4mqJPeF2/Eu RqKt6/dUEKkxE86YP/mdGjFEM8P8zjmm0GK4yAESlOjnbUfrP/irbkQixuG8g3DCQovdfI nRbR11qfgjhs4edbVksNfkTdWWtuTp0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-278-RbnOS3NeMDKbEpNp1kKAFA-1; Thu, 21 Oct 2021 08:37:58 -0400 X-MC-Unique: RbnOS3NeMDKbEpNp1kKAFA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58FAD8066FD; Thu, 21 Oct 2021 12:37:57 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id A76685D740; Thu, 21 Oct 2021 12:37:49 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, sgarzare@redhat.com, davem@davemloft.net, kuba@kernel.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 06/10] vsock: set socket peercred Date: Thu, 21 Oct 2021 16:37:10 +0400 Message-Id: <20211021123714.1125384-7-marcandre.lureau@redhat.com> In-Reply-To: <20211021123714.1125384-1-marcandre.lureau@redhat.com> References: <20211021123714.1125384-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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