Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp582780pxb; Thu, 21 Oct 2021 05:41:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvZ0kalZLVpRJD2goqHCkiQWHZtj9D5ix8SxyGeSd7ENrSbyayDb99fF6jml8ORLcmsIA8 X-Received: by 2002:aa7:dc4f:: with SMTP id g15mr7480832edu.76.1634820063523; Thu, 21 Oct 2021 05:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634820063; cv=none; d=google.com; s=arc-20160816; b=nBQPXsgSpyoYuf1LYHMNi3c1aJ42Bve8g9TisobNnOAbOf3CWtyXobEQI3mB8u5Abt XcKuvepf/hyzWUP2bHZjjVkL9VA15pOPWEdxpx0nZiMxQ9Znk5rm2qSfDyh7rsn70icf odLOi5GOLocJdcYfH+DCAf2A+UX03S2eEeGfPZ9OZwJWk60uRSOK62sBu3P+oEB5gbQx wPi45anj0fM0C2tLrg+A7BkPPgPRQRXFT6b2aeePHV9kJ/wSyrVDRX9yH5j9qsfAAfIK cThfg47r2M9OrQLJsuAhXKb0pa71BiEBE/qzLUaoICnU22E3ChSkP5k8HzCjCwdKaAAK XQSg== 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=lZ3V8Nu0/x56ViCtDuyQGZJtbSCLKoN9sbTI1RoP0GU=; b=Z0c4APx3+/x3n/WvccjE0h63zt90csulq9YGwLUtE9JeLACGldhK6+MlHhHOQgNAxV mjIYzz85zx0EWstD8HeX54QLaZkHiPNAGgz9QiEHJahn1BsuV0v6EZzyhD7XfKKJLV3r RK3XppLGgqvWsipIpWw8ci900bNu7+Y/FAFF+4aYT0nteGebSI91bQKS78X3JTYYbEgl 33YsF0DOWai9cwSYJO/ZBw1tBH7BOWONxX6DlOen7zkAQj1L33SnSY9nse8sDMkOTdzi KTbKnXPssb/W14mlDwtl/jU9ueNgiPJOQGq1E0bT2pLPYKle880mZ8TLdt+UqvquKQNf H63g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gUwNzLRA; 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 j22si6944513ejt.173.2021.10.21.05.40.39; Thu, 21 Oct 2021 05:41:03 -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=gUwNzLRA; 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 S231271AbhJUMk5 (ORCPT + 99 others); Thu, 21 Oct 2021 08:40:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27622 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231254AbhJUMkp (ORCPT ); Thu, 21 Oct 2021 08:40:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634819909; 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=lZ3V8Nu0/x56ViCtDuyQGZJtbSCLKoN9sbTI1RoP0GU=; b=gUwNzLRAC7oXQRQnXiW9s0bSllXqspKeTR+RWv/XYhgXuBliDa+cAleTk55liDMM0xs5lq 0BM/Xb4FnRYmNV4aEI6yfgl4o5lQ65UpODUUvFzGpb9s/BziUzsei5O0jxAGFmS9bgSfPk SsDnKXdIKD6D9C5zWy29ifYSzWk/qaE= 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-391-ipFr8KmROiuMXMfm-naHdg-1; Thu, 21 Oct 2021 08:38:24 -0400 X-MC-Unique: ipFr8KmROiuMXMfm-naHdg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F5191926DA8; Thu, 21 Oct 2021 12:38:23 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 258071346F; Thu, 21 Oct 2021 12:38:21 +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 10/10] vsock/virtio: clear peer creds on connect Date: Thu, 21 Oct 2021 16:37:14 +0400 Message-Id: <20211021123714.1125384-11-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.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since providing foreign creds wouldn't make much sense over VIRTIO, let's clear the socket peer credentials on connect. Signed-off-by: Marc-André Lureau --- net/vmw_vsock/virtio_transport.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index 4f7c99dfd16c..705789272a0f 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -449,6 +449,26 @@ static void virtio_vsock_rx_done(struct virtqueue *vq) static bool virtio_transport_seqpacket_allow(u32 remote_cid); +static int transport_connect(struct vsock_sock *vsk) +{ + struct sock *sk; + int ret; + + ret = virtio_transport_connect(vsk); + if (ret < 0) { + return ret; + } + + /* clear creds, as we can't provide foreign creds */ + sk = sk_vsock(vsk); + put_pid(sk->sk_peer_pid); + sk->sk_peer_pid = NULL; + put_cred(sk->sk_peer_cred); + sk->sk_peer_cred = NULL; + + return ret; +} + static struct virtio_transport virtio_transport = { .transport = { .module = THIS_MODULE, @@ -458,7 +478,7 @@ static struct virtio_transport virtio_transport = { .init = virtio_transport_do_socket_init, .destruct = virtio_transport_destruct, .release = virtio_transport_release, - .connect = virtio_transport_connect, + .connect = transport_connect, .shutdown = virtio_transport_shutdown, .cancel_pkt = virtio_transport_cancel_pkt, -- 2.33.0.721.g106298f7f9