linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Jorgen Hansen <jhansen@vmware.com>
Cc: Stefano Garzarella <sgarzare@redhat.com>,
	netdev <netdev@vger.kernel.org>,
	kernel list <linux-kernel@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH 03/10] vsock: owner field is specific to VMCI
Date: Fri, 5 Nov 2021 12:21:29 +0400	[thread overview]
Message-ID: <CAMxuvaxtukoYOs_7ONnH-=ANGX7Ld5aA4zQH1aOcaVPVD-ePGg@mail.gmail.com> (raw)
In-Reply-To: <89E7CE3A-364F-4D42-8B7A-651A105524D7@vmware.com>

Hi

On Wed, Oct 27, 2021 at 12:13 PM Jorgen Hansen <jhansen@vmware.com> wrote:
>
>
> > On 26 Oct 2021, at 13:16, Stefano Garzarella <sgarzare@redhat.com> wrote:
> >
> > CCing Jorgen.
> >
> > On Thu, Oct 21, 2021 at 04:37:07PM +0400, Marc-André 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 we
> 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’t been assigned a transport (and as I
> remember it, that isn’t the case for a listening socket), then it
> isn’t 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é Lureau <marcandre.lureau@redhat.com>
> >> ---
> >> 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 = parent ? vsock_sk(parent) : NULL;
> >>      if (parent) {
> >>              vsk->trusted = psk->trusted;
> >> +#if IS_ENABLED(CONFIG_VMWARE_VMCI_VSOCKETS)
> >>              vsk->owner = get_cred(psk->owner);
> >> +#endif
> >>              vsk->connect_timeout = psk->connect_timeout;
> >>              vsk->buffer_size = psk->buffer_size;
> >>              vsk->buffer_min_size = psk->buffer_min_size;
> >> @@ -769,7 +771,9 @@ static struct sock *__vsock_create(struct net *net,
> >>              security_sk_clone(parent, sk);
> >>      } else {
> >>              vsk->trusted = ns_capable_noaudit(&init_user_ns, CAP_NET_ADMIN);
> >> +#if IS_ENABLED(CONFIG_VMWARE_VMCI_VSOCKETS)
> >>              vsk->owner = get_current_cred();
> >> +#endif
> >>              vsk->connect_timeout = VSOCK_DEFAULT_CONNECT_TIMEOUT;
> >>              vsk->buffer_size = VSOCK_DEFAULT_BUFFER_SIZE;
> >>              vsk->buffer_min_size = 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_ANY);
> >>
> >> +#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
> >>
> >
>


  reply	other threads:[~2021-11-05  8:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 12:37 [PATCH 00/10] RFC: SO_PEERCRED for AF_VSOCK Marc-André Lureau
2021-10-21 12:37 ` [PATCH 01/10] sock: move sock_init_peercred() from af_unix Marc-André Lureau
2021-10-21 12:37 ` [PATCH 02/10] sock: move sock_copy_peercred() " Marc-André Lureau
2021-10-21 12:37 ` [PATCH 03/10] vsock: owner field is specific to VMCI Marc-André Lureau
2021-10-26 11:16   ` Stefano Garzarella
2021-10-27  8:13     ` Jorgen Hansen
2021-11-05  8:21       ` Marc-André Lureau [this message]
2021-10-21 12:37 ` [PATCH 04/10] sock: add sock_swap_peercred Marc-André Lureau
2021-10-21 12:37 ` [PATCH 05/10] virtio/vsock: add copy_peercred() to virtio_transport Marc-André Lureau
2021-10-26 11:17   ` Stefano Garzarella
2021-10-21 12:37 ` [PATCH 06/10] vsock: set socket peercred Marc-André Lureau
2021-10-26 11:18   ` Stefano Garzarella
2021-10-21 12:37 ` [PATCH 07/10] vsock/loopback: implement copy_peercred() Marc-André Lureau
2021-10-26 11:18   ` Stefano Garzarella
2021-10-21 12:37 ` [PATCH 08/10] vhost/vsock: save owner pid & creds Marc-André Lureau
2021-10-21 12:37 ` [PATCH 09/10] vhost/vsock: implement copy_peercred Marc-André Lureau
2021-10-21 12:37 ` [PATCH 10/10] vsock/virtio: clear peer creds on connect Marc-André Lureau
2021-10-21 13:34 ` [PATCH 00/10] RFC: SO_PEERCRED for AF_VSOCK Stefano Garzarella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMxuvaxtukoYOs_7ONnH-=ANGX7Ld5aA4zQH1aOcaVPVD-ePGg@mail.gmail.com' \
    --to=marcandre.lureau@redhat.com \
    --cc=davem@davemloft.net \
    --cc=jhansen@vmware.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sgarzare@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).