Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp582320pxb; Thu, 21 Oct 2021 05:40:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziev3x2Uq3nJ2f9C8g6MiPLOpuP1RsbnCLJ6eTuPYvT+8Ysjf9psDSr9HCJtGNMQaOD/9n X-Received: by 2002:a17:907:6e86:: with SMTP id sh6mr7074472ejc.490.1634820028953; Thu, 21 Oct 2021 05:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634820028; cv=none; d=google.com; s=arc-20160816; b=oKQwJdYtDkBU6cfEFsPa+dJ16jJvJ+ORHkqf6SxYDgJHZH5mM/L0BIQs8qcjkUS0Tu PbYyTFi1oj6U+OcYk88CFA/GkMSzSEIN7Cq7mUeWoQRACUPlEzzn1JAPvLddPM3msme1 JKWaf0EBntomqD9AKi408v9vBda1phAkApEMu9P/2wUmgLyByqkK6ozhccjvOrDh1AnM ROk3W8nRxxr5+mW4L3nTwUvFl3c9keYwuM1MazTG8SLR1hHswSQzXzKL6Y54apzzwuMl qLiSfGEdR+t15/DGkvFYXnb7eMdZzVAIADdPuH2rTOboA92rCGORQNjnAbnOdf/Y2+DF RZ6w== 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=rsfspR8ZEWmBnaKu/w2MzUpVUlKGPyAuxvlrmOkq9T0=; b=Gu+ewqDQQcuRDa6Ul6Y71Wi4nlM8+Cnp61gwJC5JQj9wvPhTlRnTcmqVyYE6k2/h5K 075NwgNF2fHPBfivAqDbbgltxM1kSTjsoZJpXXM9VzBfH5DB2Lim9kLWUvmtxl85Ojjy 1a09bqtlbZpPZsmoNRitYbFg+yCUZS1s8KSRfVSScy9hW1uG63uLG3zu3xbUa6bveJ9l cYpTuIA8/lA7x6+/BTR/q/4x5Ogk7UmK8wQVe4vrZDu95ZN6uzQLPumnIlx+k0K8wqmD EtWqbb6+YTm1VriTvm6qMjYoUwjYEgBm2qlYV7S9rsSTO7d2pDAk3WRI8HW666Ayw3Ve DbtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EJhOeKAW; 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 ks15si6906360ejb.305.2021.10.21.05.40.03; Thu, 21 Oct 2021 05:40:28 -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=EJhOeKAW; 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 S230411AbhJUMkL (ORCPT + 99 others); Thu, 21 Oct 2021 08:40:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45152 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231196AbhJUMkH (ORCPT ); Thu, 21 Oct 2021 08:40:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634819871; 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=rsfspR8ZEWmBnaKu/w2MzUpVUlKGPyAuxvlrmOkq9T0=; b=EJhOeKAWeOHIvXIjvapliIGje9fQCoUd6Og2BeXFkzc0DGLLbgoFmxMEmE+tJh3JwcFLly MPL5pbWeaPPScypyBfCdKATEpgK0R9WamSNsDdWBRYxTl2iBtM98uKP/GMXcjEkGhrXWj1 e/l31LoQuFygMAb8eJ/rq9m0+Hi2pi8= 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-95-prZdgGaNPuWIYbpSLZ_bBw-1; Thu, 21 Oct 2021 08:37:47 -0400 X-MC-Unique: prZdgGaNPuWIYbpSLZ_bBw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C312B8066EF; Thu, 21 Oct 2021 12:37:45 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E180100164A; Thu, 21 Oct 2021 12:37:41 +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 05/10] virtio/vsock: add copy_peercred() to virtio_transport Date: Thu, 21 Oct 2021 16:37:09 +0400 Message-Id: <20211021123714.1125384-6-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.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Marc-André Lureau --- include/linux/virtio_vsock.h | 2 ++ net/vmw_vsock/virtio_transport_common.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h index 35d7eedb5e8e..2445bece9216 100644 --- a/include/linux/virtio_vsock.h +++ b/include/linux/virtio_vsock.h @@ -69,6 +69,8 @@ struct virtio_transport { /* Takes ownership of the packet */ int (*send_pkt)(struct virtio_vsock_pkt *pkt); + /* Set peercreds on socket created after listen recv */ + void (*copy_peercred)(struct sock *sk, struct virtio_vsock_pkt *pkt); }; ssize_t diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 59ee1be5a6dd..611d25e80723 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -1194,6 +1194,15 @@ virtio_transport_recv_listen(struct sock *sk, struct virtio_vsock_pkt *pkt, return -ENOMEM; } + if (t->copy_peercred) { + t->copy_peercred(child, pkt); + } else { + put_pid(child->sk_peer_pid); + child->sk_peer_pid = NULL; + put_cred(child->sk_peer_cred); + child->sk_peer_cred = NULL; + } + sk_acceptq_added(sk); lock_sock_nested(child, SINGLE_DEPTH_NESTING); -- 2.33.0.721.g106298f7f9