Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1402766pxb; Tue, 26 Oct 2021 08:24:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4y15bwWHNjX6CbYY+CINmtrdKhil8hkv/TGJRbEmA3vXqhMVOJfnX7a6e+uX0DCjqrXur X-Received: by 2002:a17:90a:a88e:: with SMTP id h14mr32233061pjq.41.1635261871532; Tue, 26 Oct 2021 08:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635261871; cv=none; d=google.com; s=arc-20160816; b=sm0qEMbHAclFM70xA0cPWprZ5++L7vHd0T1HmDpl4NZA3h/iv+t/0md1f7P4UR9Pv2 n1Yxb9Aw+cqQOnt3as74bLtJXq4ICCJ/Zu3s5GZEaH3hM+yJQh+MBcXAzyYF6ghngyYn BoEVbj5PN0Kvz1lK+JGsGMEm7Csc+E+W3xlFAaonCyHpQwZu1XP7uGZV8g7jsTcFSjNE fNpKcmrAZDpgQAKk25UtM3NWz7R2FsedMYoRCbrg5V4+DNaLnNJH8YNv/96r9ktSFimH DIxNFqzyKOXlcWQQDcvAka0euOPewG4pscuJ5h0SqEDiwxjrzKyAy7+8gqp0WT+mG5WK /LOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rGwdwajHmPeO4BJPz1S3ZGt6jC32SKD30PM7BnISZb8=; b=w0HQh2IaUoTnRw9RvQLl8bkBc3wtgCCptL8/GNaRyu5qyqDYqOHCckRZuJBL8HBJGW XHjm4rw+qswJoGJUpvTTqfQ4JDIOpjR+yySyI3EVfJRKE1VPmo27LL1/ckzYqQAocIHG DrF1s8ofmqvLEjs/Kp/y7lEAXL4wylc5coPj+SPtN3f9wetgU5eLLhg7AFDQnqecI6se 3EiharUK/XyCpjTCZ9ql7vurRTYxL9MmHhNy/zfZACuUaP2GDAkO3GFAlYt2r1Z9XKdL e52Dl39OGJ4kUXaTTDspdEwgHJx86q8C5+0bEywD2F+bpM4x6f2hJOYvhFGblkP4qthZ KKhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pa7+jwT6; 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 w18si1077935pjg.78.2021.10.26.08.23.54; Tue, 26 Oct 2021 08:24:31 -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=Pa7+jwT6; 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 S235400AbhJZLUe (ORCPT + 99 others); Tue, 26 Oct 2021 07:20:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50039 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233262AbhJZLUd (ORCPT ); Tue, 26 Oct 2021 07:20:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635247089; 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=rGwdwajHmPeO4BJPz1S3ZGt6jC32SKD30PM7BnISZb8=; b=Pa7+jwT6jovaWUqBsJgoPeQFpMAgXOrf+/ikwulSr82RJ1P+x4JfC68MkW0VkS83/u3Eco bbUORRQqp9X4RhppzPIVU3pOGzXywgtU1oP5JLkrpnBtnxvt+DdMrSk3xTv+xDKw5SQ1AV 40rBtgjXFdg++9s1t1mdbFqKOAet3gg= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-5xrAdXUCMxuLyd_OnzBlTQ-1; Tue, 26 Oct 2021 07:18:06 -0400 X-MC-Unique: 5xrAdXUCMxuLyd_OnzBlTQ-1 Received: by mail-ed1-f72.google.com with SMTP id z20-20020a05640240d400b003dce046ab51so12670176edb.14 for ; Tue, 26 Oct 2021 04:18:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=rGwdwajHmPeO4BJPz1S3ZGt6jC32SKD30PM7BnISZb8=; b=3uRXu0c36TaRpz7TGhnhNFj9RGR5iUW+imFuZXzRqbn1eN5x1Q/0yDAjWUOWJYFeiH wqXz59lIl3G4vxy/QjgEC7FzJt7kVVjABEInxd+5pPubbHFR4qCH8VYKCRLapBYm5hoh 9VMlIuZ2ZrFbUrOVc1+4X7+CW5QGNYzIIWZC1pjUtvJtSAHKSTLA9VRzfWMGcU2jzHiB qScT/YquEBmkdoB74zYjotBNVI8ewNVgLDXK508cY2edAqBUzf/+YQx3BWBNl8+H908U t7VGJ8b3CjjQXjlPzmEe3R4bVKZN9+ESd1xSHSqr83M82tkp7ses9lO4eRMGeR0Yz5lz eRfA== X-Gm-Message-State: AOAM533O24pjfNK3eatbWLAKrn43duon/fFYrUiUpox00F8UbX2l+xBs YIzufUb5PiXSNwiVq0sFcdk7G3zcNkJ3oq1uVE5E3fMFZ4E5tGm8hLfpcEhZ/O05vurwP7sLw+D yvlI0+q2RFjlG295VRUvNAEQY X-Received: by 2002:a17:906:7f8e:: with SMTP id f14mr29844806ejr.267.1635247085375; Tue, 26 Oct 2021 04:18:05 -0700 (PDT) X-Received: by 2002:a17:906:7f8e:: with SMTP id f14mr29844788ejr.267.1635247085237; Tue, 26 Oct 2021 04:18:05 -0700 (PDT) Received: from steredhat (host-79-30-88-77.retail.telecomitalia.it. [79.30.88.77]) by smtp.gmail.com with ESMTPSA id y26sm3644850edv.88.2021.10.26.04.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 04:18:04 -0700 (PDT) Date: Tue, 26 Oct 2021 13:18:01 +0200 From: Stefano Garzarella To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, kuba@kernel.org Subject: Re: [PATCH 06/10] vsock: set socket peercred Message-ID: <20211026111801.vrz4ofs42udz2n52@steredhat> References: <20211021123714.1125384-1-marcandre.lureau@redhat.com> <20211021123714.1125384-7-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20211021123714.1125384-7-marcandre.lureau@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 21, 2021 at 04:37:10PM +0400, Marc-Andr? Lureau wrote: >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); IIUC in AF_UNIX the sock_init_peercred() is called only when the connection is established, so I think we should do the same. In the single transports or in some way in the core when the transports call vsock_insert_connected(). Thanks, Stefano