From patchwork Mon Mar 29 07:58:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 410818 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3434719jai; Mon, 29 Mar 2021 01:39:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtg1TT0lK/kIe2GgeEDY6giBEIh654gcCMpPiZyfAcuAIeBpa9C5H/y8UjzV3AuDOMpMmA X-Received: by 2002:a17:906:c9d0:: with SMTP id hk16mr1924141ejb.512.1617007158964; Mon, 29 Mar 2021 01:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007158; cv=none; d=google.com; s=arc-20160816; b=SnUew6T8Hsh6srcfVUQQF9bC6uTVBANoUYI9usgon7Zp7vQOViHR2C7pBf6sqdrJOo Jx49fYYh/eBiJKs3BM3bJMU1W0qfs0bm0HXX/2bNdT+4bNilHx5pv0G0aCvhkDFhOA1U kvSWMjPtDVOG80zypmVv/cnDpVUxCHEvqHyeTJ4RkUgWSQS00iUran25k3JCPjRrKlP/ aCUbwuXHD6PyZOHHz+Lh0TxXBeZdvygOfumwhdPUtBjuDNbKOfuy/MtPthq1jbRo38fX hhhBGqYT65mYeO8pisqgtBIfmgzaImr4OD4Lq4tr8bIRqrejaEB2KSTl5P8iwKfbQiCs FiCQ== 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=XVvSjtjnzrVSnmnkbQ4SIkmIburhClxQxSS98nROYe8=; b=hmgEOEYCuF1j+WIcvNvURQeYVh+pWVGQoaAKmppqqjrWtS64lvDiz+TuPY9Dotqc6m TRRA171zsKQTRAchmPllrrtUls8EEgieNr+r3hRWfp2LkVlwrNdY7QJT2qYr3osN1IeU 2SzTHIUMl4tDFCJV1yYbsd06kkU77KX9wpfMPQX5wzF9EH20rclM3AXNZ3H1v6gP1ihb Y69VLCjhiwFO+QgKFMp/AChPgcFr8M7s9C8XeWH2Az2/tj8mDztdgwinTrnGCGhK2yuR /FUxKCD9WlZbAWKlwXtiT1Vdm34JVPFtwXYNAVUy2WCvluOiV7hikeCRW4VX/qzonUyO G8vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GOBukRRk; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 t22si11690307ejj.746.2021.03.29.01.39.18; Mon, 29 Mar 2021 01:39:18 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=GOBukRRk; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S234100AbhC2Iit (ORCPT + 12 others); Mon, 29 Mar 2021 04:38:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:53654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234785AbhC2IhV (ORCPT ); Mon, 29 Mar 2021 04:37:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F40E8619C4; Mon, 29 Mar 2021 08:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617007002; bh=50bq1V/OJBYTOS4GglO9HpASZA32TGS3U7ESGsOpvcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GOBukRRkSPQc4lUFfMr6SLkDS1bSZeAKoAT2uSXjjbkNcnry4itMc+tG0naIhxMKC wTNsRo1SK6QzjufIHBD2hoZQcE0w0sRHVfU6N6cF73BH3Bceknq/7XrROE7tNKCHkI HQcIYHLAnTpI0K10OzfQIbHfkB4IRc3sy9xeGqZ8= 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.11 184/254] selinux: vsock: Set SID for socket returned by accept() Date: Mon, 29 Mar 2021 09:58:20 +0200 Message-Id: <20210329075639.181254030@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075633.135869143@linuxfoundation.org> References: <20210329075633.135869143@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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(+) -- 2.30.1 diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 5546710d8ac1..bc7fb9bf3351 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -755,6 +755,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();