Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1335025pxb; Wed, 4 Nov 2020 06:23:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzkPrQmM9Pc+kuKyOTamiTv61V1MCGoEzAbieAMzqumfD7/rMPvZZZj6zPYiM5kWVye8dh X-Received: by 2002:a17:906:f18f:: with SMTP id gs15mr26043989ejb.474.1604499795761; Wed, 04 Nov 2020 06:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604499795; cv=none; d=google.com; s=arc-20160816; b=VAOnPNZ9sODR7O1emjSLzRtNfgs3kAHmpmwedzl4ZaysrStvvXoWD7XIIvb2Qewp5Z IsfahsGEtNAiiVhOvcfcmpHwuccejyrvBXC+VvHSB9ETHx3Co73oWYiVDSnqZRpcLa16 DNLQ3T+0crOIvJdiVrdJVIrdZwBx3MpYefX/66QsW/bZR9rywECmfU+MInCFb1c9zMYG jx9N8Js6wcw8fkW2B0HyTGqH72eia17D1vOKoHA2Z/oKyqf6wxFASse6h64BqqjCW0fA kLVNfTJ8kwAWCVaHHZOsdP3ubp5qtGWSQ0cPJfAotwFne6WZ25xjNBaNmXuQdNbw+b9M 10Dw== 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=DCfTmW4aQ62j6jmdezgBr0zOm5Qd+OLVYInBG1WvUE8=; b=hPsxwfqV0gwasqQJ6OBOlc9bECD9lAY9+r1fPalwdgGKC0LienHuFLL6YP9fLQpdcB r/JyyHd5rAMeMpgYyNJsvjOiJTjfu7mphfqCRCeoQlGXsBDlYN2tkCF81TYe87M29EZi iB/1qAmoSKgGOgpb4TAWN9RrPlMX4PMNWCJ6Tgp+LlwCiEYExP8aNPjy7Rb2hkEMIMfd KzHboIx5vx9paZY+jeaxCvwcR9iw4ETnCwo4d1fO7l6CfF9NGTUv/XqAv1izIxMWwLdd ozXymj7fD9eune4clgrzb4NWTy9uoAcsdMjkkuCKbIlB5qo2OWc0SgrI9bbwQG/gJ4KP lHgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=RYrzdi56; 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=NONE dis=NONE) header.from=umich.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id da5si1557497edb.261.2020.11.04.06.22.44; Wed, 04 Nov 2020 06:23:15 -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=@umich.edu header.s=google-2016-06-03 header.b=RYrzdi56; 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=NONE dis=NONE) header.from=umich.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726787AbgKDOV0 (ORCPT + 99 others); Wed, 4 Nov 2020 09:21:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbgKDOV0 (ORCPT ); Wed, 4 Nov 2020 09:21:26 -0500 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48B07C0613D3; Wed, 4 Nov 2020 06:21:26 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id za3so29984837ejb.5; Wed, 04 Nov 2020 06:21:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=google-2016-06-03; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DCfTmW4aQ62j6jmdezgBr0zOm5Qd+OLVYInBG1WvUE8=; b=RYrzdi56fiG5T+Z4pLBAbdoEFVS9a018tvCaPSKaRdaiuPp+/Tz5xU8mcqjcyUfXxD ZeXROBIDOWEouOJ91hOa9daYvjKaDy9uSKR0R/vVg658OfPtDRzq35nyIfkr2x0/Pmyu hlwyM+y6TKApP+iLaQOU2ME8MZiZXJI52pVhXQNCBRCjVOTvVyJ/xSRw+ihS/A+yVOye MkX3z8dMKn/1gbn9bGxfxU8TUTGzkNkkt+CW5IQN/Gp9aDeUtZrzkpi+2ZW1xUMq36Ng bG5BWt097lYEVgHEuZDL79KyPyZot1wxqkTe1DwkYW4i+HVan4RGU+eWlV8ByyF/ApVs Kj9w== 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=DCfTmW4aQ62j6jmdezgBr0zOm5Qd+OLVYInBG1WvUE8=; b=DDiu1Jbc/bH/kzYv1IPQzUQ67o4V7WN0dvv+bXocynY++hMVjCy0yplIbIZyscyF4F /Ci697oowzV/fbwlRkzCuyUDpFbSTc0BV5JOj9wX6Wzm6I43UOaK57q73Z1Lmw17iWUu 4rNZV6ceVSXuytppOxLv3LJaLyUk0RUqhq/FXVHz+/pVL7q3UexDeDeW8ViyoTYEFQqZ H4ajngzJIYimxmcNrdKzRxS4yS03IEUTcvhXo8edZ7RMHLwNw7tTXDO24OOQUhIXhd3l btsRx2gA7j9WgzK6jkisswP1uaYd9fPPpamR/SmC4HNj/ghRvrPGyF9KOp1yHS/yotpN 0qaQ== X-Gm-Message-State: AOAM531+pU4IPga/Hebx+H1FnulvixGmaCeo9KoGvdBLIWgmJNFtOZ0E M4dnuq1G1qtbzqyOTaFUhRF+NCJjFLp02o7qTjg= X-Received: by 2002:a17:906:ccc5:: with SMTP id ot5mr12307694ejb.248.1604499684911; Wed, 04 Nov 2020 06:21:24 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Olga Kornievskaia Date: Wed, 4 Nov 2020 09:21:14 -0500 Message-ID: Subject: Re: selinux: how to query if selinux is enabled To: Paul Moore Cc: Casey Schaufler , Stephen Smalley , Chuck Lever , Linux Security Module list , SElinux list , Linux NFS Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Oct 14, 2020 at 8:11 PM Paul Moore wrote: > > On Wed, Oct 14, 2020 at 12:31 PM Casey Schaufler wrote: > > On 10/14/2020 8:57 AM, Paul Moore wrote: > > > On Wed, Oct 14, 2020 at 10:37 AM Olga Kornievskaia wrote: > > >> On Tue, Oct 13, 2020 at 7:51 PM Stephen Smalley wrote: > > >>> I would suggest either introducing a new hook for your purpose, or > > >>> altering the existing one to support a form of query that isn't based > > >>> on a particular xattr name but rather just checking whether the module > > >>> supports/uses MAC labels at all. Options: 1) NULL argument to the > > >>> existing hook indicates a general query (could hide a bug in the > > >>> caller, so not optimal), 2) Add a new bool argument to the existing > > >>> hook to indicate whether the name should be used, or 3) Add a new hook > > >>> that doesn't take any arguments. > > >> Hi Stephen, > > >> > > >> Yes it seems like current api lacks the needed functionality and what > > >> you are suggesting is needed. Thank you for confirming it. > > > To add my two cents at this point, I would be in favor of a new LSM > > > hook rather than hijacking security_ismaclabel(). It seems that every > > > few years someone comes along and asks for a way to detect various LSM > > > capabilities, this might be the right time to introduce a LSM API for > > > this. > > > > > > My only concern about adding such an API is it could get complicated > > > very quickly. One nice thing we have going for us is that this is a > > > kernel internal API so we don't have to worry about kernel/userspace > > > ABI promises, if we decide we need to change the API at some point in > > > the future we can do so without problem. For that reason I'm going to > > > suggest we do something relatively simple with the understanding that > > > we can change it if/when the number of users grow. > > > > > > To start the discussion I might suggest the following: > > > > > > #define LSM_FQUERY_VFS_NONE 0x00000000 > > > #define LSM_FQUERY_VFS_XATTRS 0x00000001 > > > int security_func_query_vfs(unsigned int flags); > > > > > > ... with an example SELinux implementation looks like this: > > > > > > int selinux_func_query_vfs(unsigned int flags) > > > { > > > return !!(flags & LSM_FQUERY_VFS_XATTRS); > > > } > > > > Not a bad start, but I see optimizations and issues. > > > > It would be really easy to collect the LSM features at module > > initialization by adding the feature flags to struct lsm_info. > > We could maintain a variable lsm_features in security.c that > > has the cumulative feature set. Rather than have an LSM hook for > > func_query_vfs we'd get > > > > int security_func_query_vfs(void) > > { > > return !!(lsm_features & LSM_FQUERY_VFS_XATTRS); > > } > > Works for me. > > > In either case there could be confusion in the case where more > > than one security module provides the feature. NFS, for example, > > cares about the SELinux "selinux" attribute, but probably not > > about the Smack "SMACK64EXEC" attribute. It's entirely possible > > that a bit isn't enough information to check about a "feature". > > In the LSM stacking world that shouldn't matter to callers, right? Or > perhaps more correctly, if it matters to the caller which individual > LSM supports what feature then the caller is doing it wrong, right? Hi folks, I would like to resurrect this discussion and sorry for a delayed response. I'm a little bit unsure about the suggested approach of adding something like selinux_func_query_vfs() call where selinux has such a function. What happens when selinux is configured to be "disabled" wouldn't this call still return the same value as when it is configured as "permissive or enforcing"? Thank you. > > -- > paul moore > www.paul-moore.com