From patchwork Mon Mar 29 07:58:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 410810 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3427237jai; Mon, 29 Mar 2021 01:25:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwewi2lyrTLgMYNCS2VmUgfyR5fAksgsRE5n7JfW7JhMue3MSO2ypF4oD2I4S/cJlnZqsBx X-Received: by 2002:a17:906:7102:: with SMTP id x2mr27869876ejj.355.1617006320694; Mon, 29 Mar 2021 01:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006320; cv=none; d=google.com; s=arc-20160816; b=hlEjnYbavJxuIUtVbQKQS88OZCpe0saLOPA4d31+mfpHeQ+wBtTX4G9FHMHGlWi61S xxtNnZgihLeqP+qaXXIDdKHDwkVaxosP140lanIxojirm1UADMsaXiUX/XljPUXDxWYo WdOuK3NCfGY37lr9JZW+qj8SgSRj9bdfDGWYIPmQ3K6lHf3lOrOBEBIo9+pBDIIwdHMV pCjPCGs8ct8DQKho2ezXAd2KEFQ8KQAFlskdcFK3+qi0V340XiDWD4pP0yX8OvRJb/YR ElqIEoTO53OR8s3aAP0kpRJo9PFyOfBNNK24GbXc02R2BrxpgHWWl+wXApSAfkdcLj1c BOkQ== 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=0ZoJqwZw2kKgc0+kpO+q+PbGwbzrZlm0ZsxSRffknenAr4itscbzbYL5Jp4C/vsytL aSE4LWd7/cvX2+VJAWBodo04IqREkM5r/j6UlNM+AUtg1B8twSfE7fOgkJwp83VzWQ6P scusBJcvQM0qDATxs2Qb3fme9LCVpJNdR+G7h/u/upNY3evs/mbeKFt/SuKkOaxohLoW 8IER81NXFr1Ej32c3U3uCg6LTDCeJO4A0kur233j+op2MEeGlwl8Fyruq8NaCFZEykgv 48DBUAjOqCUeHyq+DypS/XIrsWMCKE/+JSDwWsBYtTON5KC6Nl7RYgYbwqls8sqHxYPF o2Dw== 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 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 a3si10905631edr.505.2021.03.29.01.25.20; Mon, 29 Mar 2021 01:25:20 -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=XsrIWW9y; 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 S231724AbhC2IYv (ORCPT + 12 others); Mon, 29 Mar 2021 04:24:51 -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 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 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();