Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp600269pxb; Thu, 25 Feb 2021 10:07:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlOtpiMZ+NjtVPUIl047cKN/5E9/2c/hiVcRa10mDxVZctKZ3U0T2QkTopuVE/sujTs/Qb X-Received: by 2002:aa7:c95a:: with SMTP id h26mr4266424edt.166.1614276433871; Thu, 25 Feb 2021 10:07:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614276433; cv=none; d=google.com; s=arc-20160816; b=YJaBHh18hKyqUDudL8Th2Y7xchARmLsnQnrikrVP/eYtyBpEzE9lK8N9Y0Da58U5Gt RvLh5vFKVz1dHEnuPiAx4U1An5lJ3pNP/OkQsWDqPt35hSfc1Sje/ENMmEGlq+66dxF3 pwgbJFW0Zzla1mLlPiA5GpZAivs5OmzdllMsa/Iu5tB3r9EGioB3Q5crIn9KpxjWZTDj 2Cnv6VSW10XiNYFsv5bSxOrLyReXreLetLQtrzcgJTlpO7OfKc9XXBPPQIjcmgwr7HDB ynzMkOgBu9cLR2pzX9AsHxpuP7J97/VbdLMrVgIBWn/L+5vY6IcqoMLpRd5psW/mHMXZ PJEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pA/LDAVmSyo/M2z0Ab6U1eFLC9Pa8ew081+3mLjJXhg=; b=aW+t2WJH/KJNmQn3SxF100u14Z/7nUeGgoZylrob/nXA8eWuU/6eAaAdoBqZR6gqZO vYhjH0cN0V40F4ak+FSq+mTBl5VgjiYD8Ozz68yirDEYFl2/mfPNybYj1JeMu2o6lZG+ 8p0ZWaLpxr3PB/zIIa60bwCybjmFfQ4iVXpSLgdMsCO1FFOIc+MeBxYa7QfL7dDfaruC 6IlSeECd7TjV5DjsHIkp/VlsHH914WoD/wdllrb6d99JgzEVTkp5rs38F20LjIeY2cn1 N7LuAI4njeK5YQ4dORQEhqiAgTCoDGCwbbn9MBVXQv+gDA8NU1C1kMQtQncw9PKAkpkS h4rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NmtjAsDl; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y9si3251270edm.453.2021.02.25.10.06.44; Thu, 25 Feb 2021 10:07:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=@gmail.com header.s=20161025 header.b=NmtjAsDl; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232816AbhBYSGD (ORCPT + 99 others); Thu, 25 Feb 2021 13:06:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233364AbhBYSD6 (ORCPT ); Thu, 25 Feb 2021 13:03:58 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F8F3C061574; Thu, 25 Feb 2021 10:03:18 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id g3so8028489edb.11; Thu, 25 Feb 2021 10:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pA/LDAVmSyo/M2z0Ab6U1eFLC9Pa8ew081+3mLjJXhg=; b=NmtjAsDlT5kvpzKR6hvseAIlWwcPz7x4k6mlzG7ctVMiZoIdebGYIRXsYwcqwG1NsJ EkdkJF3I+xOwDLK5aDXcsUcfE4hPuor5Dg0NvKHaFRD+X51Xp9aGlgJ040HOXZcnJoZW ZzRpnCwCWPXrDxfxJzuQA9BWWq+/aE8Vm1PM9Nud0FrO48lG7B7BzyiCqP7ZCE6YRDb6 6+YQIupL4FuK9c0S0O9Fm5MmgVFx9ri4oZpYhjExRy7glnjtOlZxBowH8G5WUWmKXZ/5 JAYfGKDA/7VVzECE7Z1oSrkmX88NZlfbxRIBtRm5dMtTYIsE4tjmf71+CySoAcYFcszf KlHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pA/LDAVmSyo/M2z0Ab6U1eFLC9Pa8ew081+3mLjJXhg=; b=fqC8Uhk03vIcOcMoFry3wc+6mfe1z5QP6SA7KZ8k2i9JEPEq1J1sn+cxkk9crqNVfV ZjCk9JBHqYG69jb8OMZB+HkDbU0GgTnES1qqmyHJmFl55jhvGRHGbWy30qKKphfN5BdW oGABY/+ET3274tAHBIBEoURPEMQjXXrBvDeko4e1iNkdYK9woVigwzsuJsdSXfREdj5L gfBzQ6VxSlpQNU0VnWj+YFZ0aidyhFfryJHAbBsFnIjm2uOWyG7uZsUxAS7R7Oa7RSRM A02YXby0dxbawmrswdIeRtlegHeGKJ+6iWsc2pUlLuvilyq6QLashS83GzS0ePuw4FTS 7oXg== X-Gm-Message-State: AOAM532q+XORLDvzPcTU6TmlRP/FEridHhrkjA/Hp4hZkY1zi3LkTgNj SnKupVzIRCtKInS1ifOiGGej2U9HWE8plO2SUsdqPgit X-Received: by 2002:a05:6402:5194:: with SMTP id q20mr4242766edd.267.1614276197084; Thu, 25 Feb 2021 10:03:17 -0800 (PST) MIME-Version: 1.0 References: <20210219222233.20748-1-olga.kornievskaia@gmail.com> In-Reply-To: From: Olga Kornievskaia Date: Thu, 25 Feb 2021 13:03:06 -0500 Message-ID: Subject: Re: [PATCH v3 1/3] [security] Add new hook to compare new mount to an existing mount To: Paul Moore Cc: Trond Myklebust , Anna Schumaker , linux-nfs , Linux Security Module list , SElinux list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Feb 25, 2021 at 12:53 PM Paul Moore wrote: > > On Fri, Feb 19, 2021 at 5:25 PM Olga Kornievskaia > wrote: > > > > From: Olga Kornievskaia > > > > Add a new hook that takes an existing super block and a new mount > > with new options and determines if new options confict with an > > existing mount or not. > > > > A filesystem can use this new hook to determine if it can share > > the an existing superblock with a new superblock for the new mount. > > > > Signed-off-by: Olga Kornievskaia > > --- > > include/linux/lsm_hook_defs.h | 1 + > > include/linux/lsm_hooks.h | 6 ++++ > > include/linux/security.h | 8 +++++ > > security/security.c | 7 +++++ > > security/selinux/hooks.c | 56 +++++++++++++++++++++++++++++++++++ > > 5 files changed, 78 insertions(+) > > ... > > > diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h > > index a19adef1f088..d76aaecfdf0f 100644 > > --- a/include/linux/lsm_hooks.h > > +++ b/include/linux/lsm_hooks.h > > @@ -142,6 +142,12 @@ > > * @orig the original mount data copied from userspace. > > * @copy copied data which will be passed to the security module. > > * Returns 0 if the copy was successful. > > + * @sb_mnt_opts_compat: > > + * Determine if the existing mount options are compatible with the new > > + * mount options being used. > > Full disclosure: I'm a big fan of good documentation, regardless of if > it lives in comments or a separate dedicated resource. Looking at the > comment above, and the SELinux implementation of this hook below, it > appears that the comment is a bit vague; specifically the use of > "compatible". Based on the SELinux implementation, "compatible" would > seem to equal, do you envision that to be the case for every > LSM/security-model? If the answer is yes, then let's say that (and > possibly rename the hook to "sb_mnt_opts_equal"). If the answer is > no, then I think we need to do a better job explaining what > compatibility really means; put yourself in the shoes of someone > writing a LSM, what would they need to know to write an implementation > for this hook? That's is tough to do as it is vague. All I was doing was fixing a bug. Selinux didn't allow a new mount because it had a different security context. What that translates to for the new hook, is up to the LSM module whether it would need the options to be exactly the same or if they can be slightly different but yet compatible this is really up to the LSM. Do you care to suggest wording to use? It is hard to find words that somebody else is looking for but one is unable to provide them. > > > + * @sb superblock being compared > > + * @mnt_opts new mount options > > + * Return 0 if options are compatible. > > -- > paul moore > www.paul-moore.com