Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2720419pxb; Fri, 5 Nov 2021 03:39:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDhLRRWRMwAPb455xkbOZzYGIJX6FewDSHWtLb8OwR2c5WBWeW9MaNSfq/IU2nhodYi3Zz X-Received: by 2002:a05:6402:b5c:: with SMTP id bx28mr52521058edb.130.1636108772389; Fri, 05 Nov 2021 03:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636108772; cv=none; d=google.com; s=arc-20160816; b=SKPGOxAx8Ayccy/yYyA2fuzuLcZx9U9K/ozA+bdKWw5ZVzsPpT9fniT3UuG7Jcm8zh uFbfdkibQTAdHZsuP1UAyYTi/tlIG9UmGRCL63a+a+zUSBcH3yXJG0zPW7Fv8EkvBvjS R+asGyzSoVIP3/kla4bb+yjjHprBcHYZd1kyUoXnOioIWMyuXTdj1I4JwwWd+22oZwVR 5dZyCHesK8MjGsQPHReuvy8MmIeTxUp9mFOiKI737D+Muh7EnmcGrgH0M5poAEmjWi6R bsLM1ASoqfv5Cf06tNhDUR2jNPXGvpRrpVNIlmO/JVrpKmZb6nARJ0W9wAQmTEpChfqi uKpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=eXP5U3uNsWvkcsdX8yeKebSDhuiPkgqH2wJBMCP0fuY=; b=RzeQjbB8AfHkcqMY85czq192W7DZG68OOdKuoBqo/UeEeEn3sQUL1/hqcwzhHAb+qb laK0ny87qA9oFNIsX9Os40LcfrnovIYMs9oRbDPmjRuVsQg2dZbxDJzZ1NCWiSQ40j5i PcVLdCMsvyq/3YBoLWYVXhcZPSm1QdwQu5RZokIhCRJ6atevqd56gK4N2+NPD2Zw57M+ mTWyryobcGANlZ8lndGwT0eNQCkuCXjtu2pCZvZtzN/shOTbqN2sfycQVgBN2I8iFvwX Pr7MCJdvb8yc7IY0C1X8o3uh8SJrlnONYJSMCv7X5wGTvHV9srMjT570mPH7Ee3JDMnm g1Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UIZRi0Gf; 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 a5si11167307ejf.478.2021.11.05.03.39.07; Fri, 05 Nov 2021 03:39:32 -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=UIZRi0Gf; 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 S232650AbhKEIYX (ORCPT + 99 others); Fri, 5 Nov 2021 04:24:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21387 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbhKEIYW (ORCPT ); Fri, 5 Nov 2021 04:24:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636100502; 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=eXP5U3uNsWvkcsdX8yeKebSDhuiPkgqH2wJBMCP0fuY=; b=UIZRi0GfuugTWvEK1CfCiDscTxU5PZBZhb8VyBkSPK0dxxe9CzlBHyQiBj4kwFiKVS8s0Y KUCKizgESQij6urHdc9XmSUB59WbO0LHujh2/z+TO71eXG6nwAjYC0E4FX2v0GwDFnrlIw tn6hJNz5LVolIk8qynhsWO7hoDtcNa8= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-e7HZJ8uGOPizEGN9jZv6VQ-1; Fri, 05 Nov 2021 04:21:41 -0400 X-MC-Unique: e7HZJ8uGOPizEGN9jZv6VQ-1 Received: by mail-pj1-f72.google.com with SMTP id m4-20020a17090a2c0400b001a1f07cc9c4so1929679pjd.8 for ; Fri, 05 Nov 2021 01:21:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=eXP5U3uNsWvkcsdX8yeKebSDhuiPkgqH2wJBMCP0fuY=; b=cm+kW2Zo0Be6Ym0hGgR7Plj/GoAsbPXrOlDgL1wi6kHRThQeD/sBmEtbYQv5Lq+KcL IS+gq8hXZGCQHhvCeRElR/8YTr2BsAbdY7iJIIXCOLlcXymRKD/Rv/kVcXZc7DAkYcOE x7RksYDzwJMigOw9LyJ6J9lE61ybZnsZxSxFOxupJawjnn5LI3H9/D+AvfAAEE/EXdlD Dnfr2eB0GCoZsGiE4mNM93lpPoGznuw9E7HpEtMTGt1Ci7ev98x6jZulFQXlIgofLhVj WSfuM13AK3XfDhQJgVTu8Bs1QlzrVUPMH1eE0XoPN+3oyAIwXEy2/YrfzLXzIXxEbc4N xafg== X-Gm-Message-State: AOAM532BLgO7I4mBA6YztcepiV4+kyKSmzWG+G/nBGjHDSw4vb2p+ovz oll94UjhoG1FKHghBRxubykI1QdkvgPwkPK5ejHhG9+Cnmnj5yf69P+i5pXwoUgxvb74nuDcq7m lkoFLTYdyNxVGusVG5iXmy4SJTzBHaNqfh+5hxfdu X-Received: by 2002:a17:90b:2252:: with SMTP id hk18mr9550547pjb.36.1636100500727; Fri, 05 Nov 2021 01:21:40 -0700 (PDT) X-Received: by 2002:a17:90b:2252:: with SMTP id hk18mr9550531pjb.36.1636100500505; Fri, 05 Nov 2021 01:21:40 -0700 (PDT) MIME-Version: 1.0 References: <20211021123714.1125384-1-marcandre.lureau@redhat.com> <20211021123714.1125384-4-marcandre.lureau@redhat.com> <89E7CE3A-364F-4D42-8B7A-651A105524D7@vmware.com> In-Reply-To: <89E7CE3A-364F-4D42-8B7A-651A105524D7@vmware.com> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Fri, 5 Nov 2021 12:21:29 +0400 Message-ID: Subject: Re: [PATCH 03/10] vsock: owner field is specific to VMCI To: Jorgen Hansen Cc: Stefano Garzarella , netdev , kernel list , "David S. Miller" , Jakub Kicinski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi On Wed, Oct 27, 2021 at 12:13 PM Jorgen Hansen wrote: > > > > On 26 Oct 2021, at 13:16, Stefano Garzarella wrot= e: > > > > CCing Jorgen. > > > > On Thu, Oct 21, 2021 at 04:37:07PM +0400, Marc-Andr=C3=A9 Lureau wrote: > >> This field isn't used by other transports. > > > > If the field is used only in the VMCI transport, maybe it's better to > > move the field and the code in that transport. > > If the transport needs initialize these fields, that should happen when w= e > call vsock_assign_transport. So we would need to validate that > get_current_cred() gets the right credentials and that the parent of a > socket has an Initialised owner field at that point in time. > > sock_assign_transport may be called when processing an > incoming packet when a remote connects to a listening socket, > and in that case, the owner will be based on the parent socket. > If the parent socket hasn=E2=80=99t been assigned a transport (and as I > remember it, that isn=E2=80=99t the case for a listening socket), then it > isn=E2=80=99t possible to initialize the owner field at this point using > the value from the parent. So the initialisation of the fields > probably have to stay in af_vsock.c as part of the generic structure. > > Is there a particular reason to do this change as part of this series > of patches? No particular reason, it was just related code. thanks > > Thanks, > Jorgen > > > Thanks, > > Stefano > > > >> > >> Signed-off-by: Marc-Andr=C3=A9 Lureau > >> --- > >> include/net/af_vsock.h | 2 ++ > >> net/vmw_vsock/af_vsock.c | 6 ++++++ > >> 2 files changed, 8 insertions(+) > >> > >> diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h > >> index ab207677e0a8..e626d9484bc5 100644 > >> --- a/include/net/af_vsock.h > >> +++ b/include/net/af_vsock.h > >> @@ -41,7 +41,9 @@ struct vsock_sock { > >> * cached peer? > >> */ > >> u32 cached_peer; /* Context ID of last dgram destination check. = */ > >> +#if IS_ENABLED(CONFIG_VMWARE_VMCI_VSOCKETS) > >> const struct cred *owner; > >> +#endif > >> /* Rest are SOCK_STREAM only. */ > >> long connect_timeout; > >> /* Listening socket that this came from. */ > >> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c > >> index e2c0cfb334d2..1925682a942a 100644 > >> --- a/net/vmw_vsock/af_vsock.c > >> +++ b/net/vmw_vsock/af_vsock.c > >> @@ -761,7 +761,9 @@ static struct sock *__vsock_create(struct net *net= , > >> psk =3D parent ? vsock_sk(parent) : NULL; > >> if (parent) { > >> vsk->trusted =3D psk->trusted; > >> +#if IS_ENABLED(CONFIG_VMWARE_VMCI_VSOCKETS) > >> vsk->owner =3D get_cred(psk->owner); > >> +#endif > >> vsk->connect_timeout =3D psk->connect_timeout; > >> vsk->buffer_size =3D psk->buffer_size; > >> vsk->buffer_min_size =3D psk->buffer_min_size; > >> @@ -769,7 +771,9 @@ static struct sock *__vsock_create(struct net *net= , > >> security_sk_clone(parent, sk); > >> } else { > >> vsk->trusted =3D ns_capable_noaudit(&init_user_ns, CAP_NE= T_ADMIN); > >> +#if IS_ENABLED(CONFIG_VMWARE_VMCI_VSOCKETS) > >> vsk->owner =3D get_current_cred(); > >> +#endif > >> vsk->connect_timeout =3D VSOCK_DEFAULT_CONNECT_TIMEOUT; > >> vsk->buffer_size =3D VSOCK_DEFAULT_BUFFER_SIZE; > >> vsk->buffer_min_size =3D VSOCK_DEFAULT_BUFFER_MIN_SIZE; > >> @@ -833,7 +837,9 @@ static void vsock_sk_destruct(struct sock *sk) > >> vsock_addr_init(&vsk->local_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY= ); > >> vsock_addr_init(&vsk->remote_addr, VMADDR_CID_ANY, VMADDR_PORT_AN= Y); > >> > >> +#if IS_ENABLED(CONFIG_VMWARE_VMCI_VSOCKETS) > >> put_cred(vsk->owner); > >> +#endif > >> } > >> > >> static int vsock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) > >> -- > >> 2.33.0.721.g106298f7f9 > >> > > >