Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp577729imm; Mon, 1 Oct 2018 14:57:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ZXUJYKlYy3Ox8pXwD2QN4wuZsKkETIRRnq5DjDQs8Err0krmSRnG9Qre+Y31AIQc6FD0P X-Received: by 2002:a17:902:2e:: with SMTP id 43-v6mr11886075pla.290.1538431054596; Mon, 01 Oct 2018 14:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538431054; cv=none; d=google.com; s=arc-20160816; b=q+y+LKigZ8kajE89ShBWMX7cMzizl1XA7DOh1PpPTU1lcnz1IIW1GrczL7g+0i5VWg 09xqmjjsvcomH9KOIbi6Vh9METTUZ6Cr+5Prs/VPDw2OiooBE+lUecTcZJMVAAH3aGHz 2VcNpsb770uFABJoEB+uWUu7Eo06L5p8azNXXY7gVZD7KshsI+j+94ginRZws3t/I8kz w/ytwXZbiALAgl4oJCKpULOmO4GSOqQ9i9hhXDClrVrPSDGElsnx+CzaE28t+1D9pqI2 C76od0fMp3WAkA29Nd4iT0WnbLfRtgOIXiBYoIOKboFgr8ZXxfb9bE7AGQEwBd49aO9X +qxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=qEzzBMCxb12vY/FYUOpb/kfbgPGZDUraFm4sj/mqu0U=; b=XhpZyngbFCGNwf42w9SvQbrA3PHFSi7L+jClANCfOvrfMgC3/0jsj7Z4DnonrX4Nta ccewTjsVyB1f21JTRQE6hZomV7OgCNjDekZj8YCJxtSXDK66QNmeKwtc5w6DFfbx9wQc cQoIC37FeeEdI4v2mnlEKiYa1wPtjVaXyeNcJ0Y0OrX/bjXNdQjCuQh2rq+pLRoCHwho NAu86DlwBfG8esnBAbBwV71rGzo4ygQDop/3I3pN9LR6O0GE6JF8noUFmgC1C61qCEUK KCwVCa+wFjTNxyf1klYcSmLuZVTQ1wWh1a4BN9iBMabcVwp+Z/KyvibulO7ibAElnzWH EgHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DL62DlLd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r19-v6si13085200pgm.478.2018.10.01.14.57.19; Mon, 01 Oct 2018 14:57:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DL62DlLd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbeJBEgl (ORCPT + 99 others); Tue, 2 Oct 2018 00:36:41 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:41589 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbeJBEgl (ORCPT ); Tue, 2 Oct 2018 00:36:41 -0400 Received: by mail-yw1-f65.google.com with SMTP id q129-v6so6176956ywg.8 for ; Mon, 01 Oct 2018 14:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qEzzBMCxb12vY/FYUOpb/kfbgPGZDUraFm4sj/mqu0U=; b=DL62DlLdJoL5VRrkxAthiGviLnWqwFc2ajZmhsS/NFYfSO2p493+64GvzGdH6przN0 Nh3+vd3a61tlfRYRwbUamxXzFR3XdtWpT7N7WR+wHCigGrh7KSxC3LWdGNBkGJb5/pzF p7Lc2X4KfEfBu2uaXhFx2+bwui7VK0URrTXGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qEzzBMCxb12vY/FYUOpb/kfbgPGZDUraFm4sj/mqu0U=; b=hIRYHt1QqhhaTYHTi5M1oejVqBY1W0gSHKRsOLBRXgjGwD/z62bslJ0hELBqJ+FS5l 5Wt134r3X6rh6RfGK96purTWhDk4T2Me96zZhnClNklWVIimYsBWBTi2REzT05Z6L5o9 cjmtRh9/fx4CxPUttyb0HiyPrDZxWWh69qy+nNkbN0wJr+/KbeL4rHYEwusmU/nSis39 NHKmhSTQMwNx/7WvvYqMmkuR/jy6o73rUzF17dXFwzMSnLiz0SHtiRFoduaimR0jb0DQ FNEm+wxugv8TNnFddqqn8PWdSoTginvaH4HqAolcalA6qR4KfD/sczinq5C+D6VBoUmD YwlA== X-Gm-Message-State: ABuFfojyikkLLkvvG+2ecKVhzzvf+I7hXBdD0lcI9iPL/xLskkIHX2CD taJrxuw8lnGaVy8fbUWMg3jOkuT4Fck= X-Received: by 2002:a81:c405:: with SMTP id j5-v6mr6935331ywi.475.1538431006311; Mon, 01 Oct 2018 14:56:46 -0700 (PDT) Received: from mail-yw1-f49.google.com (mail-yw1-f49.google.com. [209.85.161.49]) by smtp.gmail.com with ESMTPSA id b71-v6sm20910535ywa.48.2018.10.01.14.56.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 14:56:44 -0700 (PDT) Received: by mail-yw1-f49.google.com with SMTP id j75-v6so1248785ywj.10 for ; Mon, 01 Oct 2018 14:56:44 -0700 (PDT) X-Received: by 2002:a81:2288:: with SMTP id i130-v6mr7188157ywi.288.1538431004028; Mon, 01 Oct 2018 14:56:44 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:d116:0:0:0:0:0 with HTTP; Mon, 1 Oct 2018 14:56:43 -0700 (PDT) In-Reply-To: References: <20180925001832.18322-1-keescook@chromium.org> <20180925001832.18322-15-keescook@chromium.org> From: Kees Cook Date: Mon, 1 Oct 2018 14:56:43 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH security-next v3 14/29] LSM: Plumb visibility into optional "enabled" state To: James Morris Cc: Casey Schaufler , John Johansen , Tetsuo Handa , Paul Moore , Stephen Smalley , "Schaufler, Casey" , LSM , Jonathan Corbet , "open list:DOCUMENTATION" , linux-arch , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 1, 2018 at 2:47 PM, James Morris wrote: > On Mon, 24 Sep 2018, Kees Cook wrote: > >> In preparation for lifting the "is this LSM enabled?" logic out of the >> individual LSMs, pass in any special enabled state tracking (as needed >> for SELinux, AppArmor, and LoadPin). This should be an "int" to include >> handling any future cases where "enabled" is exposed via sysctl which >> has no "bool" type. >> >> Signed-off-by: Kees Cook >> --- >> include/linux/lsm_hooks.h | 1 + >> security/apparmor/lsm.c | 5 +++-- >> security/selinux/hooks.c | 1 + >> 3 files changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h >> index 5056f7374b3d..2a41e8e6f6e5 100644 >> --- a/include/linux/lsm_hooks.h >> +++ b/include/linux/lsm_hooks.h >> @@ -2044,6 +2044,7 @@ extern void security_add_hooks(struct security_hook_list *hooks, int count, >> struct lsm_info { >> const char *name; /* Populated automatically. */ >> unsigned long flags; /* Optional: flags describing LSM */ >> + int *enabled; /* Optional: NULL means enabled. */ > > This seems potentially confusing. > > Perhaps initialize 'enabled' to a default int pointer, like: > > static int lsm_default_enabled = 1; > > Then, > > DEFINE_LSM(foobar) > flags = LSM_FLAG_LEGACY_MAJOR, > .enabled = &lsm_default_enabled, > .init = foobar_init, > END_LSM; The reason I didn't do this is because there are only two LSMs that expose this "enabled" variable, so I didn't like making the other LSMs have to declare this. Internally, though, this is exactly what the infrastructure does: if it finds a NULL, it aims it at &lsm_default_enabled (in a later patch). However, it seems more discussion is needed on the "enable" bit of this, so I'll reply to John in a moment... -Kees -- Kees Cook Pixel Security