Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3425699pxf; Mon, 29 Mar 2021 01:44:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9slbD3ZEVm7WZXD1Ke8rrVcYygp0ZYKV9Cu+7cw6dJvfECV9d6N2eJ0SZcm0bpaCFdesb X-Received: by 2002:a17:907:1119:: with SMTP id qu25mr27282913ejb.423.1617007443068; Mon, 29 Mar 2021 01:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007443; cv=none; d=google.com; s=arc-20160816; b=qycYRVJ5gVPrsxqZtTkfkcT0IrY2HUij1s51kIwJBcaSzwUS1nSQldgpMkRebjUss1 uUM9Asokw917QwEqf+n95TV1hwTjbfPBxFJhSy54hzzvHkqPZagcPz9ao26wN+m80QzL kPzq8RgsxmrrCB39xPYbJhimCoUr+2mAjQ6iqNRA7mVo+UIU9D4ZaxBspAb2UR7/uq8A 0jtMzZS/9LFYl6V7Uy39xkA+XQy652Aormdk6YaA2QBO3w6eWUFjG23J9Jz+2yba98Vp GFkxbH1nOiWdmcFB4lC6C9UpF1M0WKJfYMDpmIjvsD8oHb5J7P8MfsSQ5dNOrFZ7yYBJ 2FVQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hIV4r2XIHpK64s32YUTfWci/EBtNreb8XXbtJrhLPO4=; b=H1aeslPGYE+eor2xz+vTbXGR9MAtKhS8cOimHeX1CN0MvlDFaISoeawpKQh1aQlvrD 3FZdTmXr1R0ikBoKGlOfhyGwLTrcdb8jJWMusk6TBrD6fVdZLk9So+7wlbO8PHSAF5ba IVIeOnpIiIQGIlZS1+6EdAuzKwe2yjVvvQi/ieJbQ1JsVyfpUfhutKW1faXKmw+cte/C yPmy9/NpEEm5rn3U9L+hhbKs3PC2ddrzYwFfguiRplh3QbXWPkTVYcC+yAPcyEcPzOs7 +BnDPgn1ZEsRQh7gvX81FR4+iRj0gVUd4teGJrOIBhwqVwOxAzVCC5TumYB+32wUxpJ+ ectg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XsrIWW9y; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si12407186ejq.139.2021.03.29.01.43.40; Mon, 29 Mar 2021 01:44: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=@linuxfoundation.org header.s=korg header.b=XsrIWW9y; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233504AbhC2Il7 (ORCPT + 99 others); Mon, 29 Mar 2021 04:41:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:40964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232585AbhC2IXu (ORCPT ); Mon, 29 Mar 2021 04:23:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C519861601; Mon, 29 Mar 2021 08:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006219; bh=ffgBIZ4vhWgk3gTAttcgT8LCvnRUFSe9UJzLkuJnyrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XsrIWW9yEw8BakkmDiqbct5Wvj+JPNZ5rUQXGTxq0cr5mW3cfPSDBha178k/nCUPU bDULHWiOjnmrW5V3PHywo5nezlT4bv7Rq60P5m+QO6IfxXEsxb0B1Q26n/jw2yZBmP rToOQiqGXSpoG2c+iBb/vdMrkJQwvoczPkwW/l4Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Brazdil , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 161/221] selinux: vsock: Set SID for socket returned by accept() Date: Mon, 29 Mar 2021 09:58:12 +0200 Message-Id: <20210329075634.525785073@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Brazdil [ Upstream commit 1f935e8e72ec28dddb2dc0650b3b6626a293d94b ] For AF_VSOCK, accept() currently returns sockets that are unlabelled. Other socket families derive the child's SID from the SID of the parent and the SID of the incoming packet. This is typically done as the connected socket is placed in the queue that accept() removes from. Reuse the existing 'security_sk_clone' hook to copy the SID from the parent (server) socket to the child. There is no packet SID in this case. Fixes: d021c344051a ("VSOCK: Introduce VM Sockets") Signed-off-by: David Brazdil Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/vmw_vsock/af_vsock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 791955f5e7ec..cf86c1376b1a 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -738,6 +738,7 @@ static struct sock *__vsock_create(struct net *net, vsk->buffer_size = psk->buffer_size; vsk->buffer_min_size = psk->buffer_min_size; vsk->buffer_max_size = psk->buffer_max_size; + security_sk_clone(parent, sk); } else { vsk->trusted = ns_capable_noaudit(&init_user_ns, CAP_NET_ADMIN); vsk->owner = get_current_cred(); -- 2.30.1