Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1372169pxf; Fri, 19 Mar 2021 06:01:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKSmdujtwG5qwUG9Sp1qx2gTHFSaaoblgfJh8tJtsQfVwEWVoIzjyzYnGnC92s4gA6LvA9 X-Received: by 2002:a17:906:26c9:: with SMTP id u9mr4170605ejc.520.1616158897021; Fri, 19 Mar 2021 06:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616158897; cv=none; d=google.com; s=arc-20160816; b=Ye5W8LV4kyBMQHPlynfT07mKfolg6zqtmFwQkoeD7Po2lKPmyvakGqTumXC9+cmLed ZikCnXKt47cM6WOM/UgTl335i+BoWabopzFrc5Mj1wPY+kVsjOMctJZAiGuz1IdaLZ7/ koSQmbl5G1fLGO0dsiWDqaG8kzRP3/Ly78wPQaajt10lPVGKxObOYMYO2nSrFJpNbNue QCLbtmvKt+6h2W43DMb67fXCUJKeTJgD+fw3O4pDsGxvdcbBuBlKwV7cpdK/+4wmgY+F 3iIs9g2EJAvH1qkXoLATXlaRfs3MCkkRrs3x9I4wmNvSABNhaSAifIIF7Ro8rR4MAH7j ra4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XpPGUE6BByswa3Ep4l8WzlVumVFkgxbvdRbN1GhWJbU=; b=hiNXXdE4AABMZsyufshjGuEhP5s5/7DJH8fQqkA8e+lCdQGfeFH9chrjefz8OzvNnP yF5vL/dC8B88S7gcSzYTJDeBB2pnXnM75x/gSd3oL0YWUg6Cbi8xmZ8BKtauVhHSaWoK oYmEwRbbTCIrz/uxQDMCf8N0mc9GF+KyLHierbBoJd3gIngbxaK/8Ll1y+tE9D33LlEL TcLS4rAoDY45WpTR4ejSDMGiGesm5whDOGkb+HtsCSMfjyPz1DWTLKfAUhy/CeJhleNd nK/xJrc9zxce93ucZyqv0itoNy7MHeeGMImEQD5ohE9d3HJF8yAJyf57E/oYAwpeJO10 YxTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eQ2OMBnw; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j9si4176059edw.509.2021.03.19.06.01.13; Fri, 19 Mar 2021 06:01:37 -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=@google.com header.s=20161025 header.b=eQ2OMBnw; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229952AbhCSM5s (ORCPT + 99 others); Fri, 19 Mar 2021 08:57:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbhCSM5X (ORCPT ); Fri, 19 Mar 2021 08:57:23 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 487E5C06175F for ; Fri, 19 Mar 2021 05:57:23 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id u5-20020a7bcb050000b029010e9316b9d5so5185340wmj.2 for ; Fri, 19 Mar 2021 05:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XpPGUE6BByswa3Ep4l8WzlVumVFkgxbvdRbN1GhWJbU=; b=eQ2OMBnwvXNj4Zdcbf4Hf8XhhOBTeJwVU8tZfivPCrGq/tqqyHwo+0+7sVu6f/FsOF 2OxuJiRcYb+ik93a+6pEZWp7tjd8+5ZGYphQIC53Le4n8JIjcX44lFddF1HSGvwZed2B Kdty/Fkttsnba/u2wxbAW5PS5T45tIkJ0NOMrBS5T1OqETZjK5ywTXFrxyTHOnG0UEDs YwqAQK/gQEYhzSjBYukkAxpoaF+2mwqUDnY9us+Z2wK1PX5EK6/psOtGTwp+gwxvvLao 0b4J3h/UircWR7ovcTz20HRQhi0PF74RiV9kaVNlVJ+dVdgg+O5M2++cy91mMuVOguqX kI7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=XpPGUE6BByswa3Ep4l8WzlVumVFkgxbvdRbN1GhWJbU=; b=WyEe0jkV/4lx652w6RA2jsY3UP0pZ0TEzeK4qYmcmxLUrYFPGjzgraqFNFDbBA601q rxTTNgirxEKvlqGoV3aBub8iMhpXUC+FS7lXQbEFxrMrHfIPHDy1yDg+xfBIQNAe7O6v arGpLopjH3ricj7PrhXD1QKXAGK5mAJb+VZ/R7Aadlma2yoMgQGXtRIcUCW86FPhay1J g1mCpI58gjuDHfja0X0NqhQ2qdvoYcW7HgQ4tyA+pbpN0IsectayXj1NF0kOVKvvDy6E Ow/OAM79Debgm4bEc99Q4jLEF5QjXpeWRyOlVBb6RJcxxZRsYY/9jPgm0VEOU2ooD4qi sbaQ== X-Gm-Message-State: AOAM530exj/pDpJJqmVKYlbtNcqDar2A/7hmrnit54LzHVDlLxBf4SfJ wpDq5w5MKPvtK7tdhQvjDMSBig== X-Received: by 2002:a1c:448a:: with SMTP id r132mr3621997wma.157.1616158641830; Fri, 19 Mar 2021 05:57:21 -0700 (PDT) Received: from google.com (216.131.76.34.bc.googleusercontent.com. [34.76.131.216]) by smtp.gmail.com with ESMTPSA id s84sm6605286wme.11.2021.03.19.05.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 05:57:21 -0700 (PDT) Date: Fri, 19 Mar 2021 12:57:16 +0000 From: David Brazdil To: Paul Moore Cc: selinux@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-security-module@vger.kernel.org, "David S . Miller" , Jakub Kicinski , James Morris , "Serge E . Hallyn" , Stephen Smalley , Eric Paris , Kees Cook , Jeff Vander Stoep , Alistair Delva Subject: Re: [PATCH] selinux: vsock: Set SID for socket returned by accept() Message-ID: References: <20210317154448.1034471-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, I'll post a v2 shortly but will address your comments here. > > include/linux/lsm_hooks.h | 7 +++++++ > > include/linux/security.h | 5 +++++ > > net/vmw_vsock/af_vsock.c | 1 + > > security/security.c | 5 +++++ > > security/selinux/hooks.c | 10 ++++++++++ > > 6 files changed, 29 insertions(+) > > Additional comments below, but I think it would be a good idea for you > to test your patches on a more traditional Linux distribution as well > as Android. > No problem, I was going to add a test case into selinux-testsuite anyway. Done now (link in v2) and tested on Fedora 33 with v5.12-rc3. > > diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c > > index 5546710d8ac1..a9bf3b90cb2f 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_vsock_sk_clone(parent, sk); > > Did you try calling the existing security_sk_clone() hook here? I > would be curious to hear why it doesn't work in this case. > > Feel free to educate me on AF_VSOCK, it's entirely possible I'm > misunderstanding something here :) > No, you're completely right. security_sk_clone does what's needed here. Adding a new hook was me trying to mimic other socket families going via selinux_conn_sid. Happy to reuse the existing hook - makes this a nice oneliner. :) Please note that I'm marking v2 with 'Fixes' for backporting. This does feel to me like a bug, an integration that was never considered. Please shout if you disagree. -David