Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2471480imm; Sat, 15 Sep 2018 18:48:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaP9NdiaQCbg7vCPsRzyiJxWLsHM+RwmkPWALOjhoR1aiWU0Icgw5ezi1pGyX7dmy8PpdEW X-Received: by 2002:a17:902:4503:: with SMTP id m3-v6mr18541122pld.168.1537062486625; Sat, 15 Sep 2018 18:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537062486; cv=none; d=google.com; s=arc-20160816; b=gMWSLwdQPYE7CwIwL/QcwUh3HAC2vB5r2g095ZMc6UAYfLu1Gs9d7EnBGmg4qHjucc PoFEnflCsRCe/vh/HPrx/UM+tunKeB0Jvs9cL4BvRlqwRHFFU7lxRecOyn60XHvwJGi+ m5+gAwPjm8oiVBm6BC4Fmh6sOVRw7SUJph1IXND+7+pTuiv1PPPYaB5ZZLqccRXpZGzE ZMvqJf3S97eOhqmIA36QN2HMmWv0jKIXc9He1Npt8XWF51WlyKulHEI8NaxXKPYuXirB IgP3al5GeqWXrvQWxCo4p/cD95Aev2BEuiA2XqNHWAmtp9q0RghIbBHmTzRV/q2RiZ1k 67XQ== 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=4D4fvnp3QPX9Q4pNR4VeHpaUXUgOJTpCfrPxcjYJ84I=; b=GJ/+llU01sKPebuez0IwxYGRfV8Dagvie+E8YEv7KK7e2yyIG2y+Xgl07/w/HfFtoE Ul0FaKcJtiNrSpxr0LC/mWXmAlcZ1uMoV9D57YFh6F1iqB6bMfICrUaz+u9W2pmvAlAP iJbzUh6Ba1AxQ4DbnRuoHDOiLinYE5hCY7ECLWhQt3QI/ESubTMJl73yqVz0zgRzjx/2 KUJt8vIxjVPfs1s9QCEEU/bADvl45yytcqKEVoTDIwLyPDjfSsCi0auGK2JgfJI1OSj+ AaBzRGNemClh5u/1410Jw0DGESOU6VAGSym1FGeFr4YIF2nNlF3u4j8Q5MVJ81OrByT8 gppQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="f3Cz/ez9"; 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 b24-v6si11362252pfo.54.2018.09.15.18.47.38; Sat, 15 Sep 2018 18:48:06 -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="f3Cz/ez9"; 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 S1727312AbeIPHIo (ORCPT + 99 others); Sun, 16 Sep 2018 03:08:44 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:39624 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726848AbeIPHIo (ORCPT ); Sun, 16 Sep 2018 03:08:44 -0400 Received: by mail-yw1-f65.google.com with SMTP id m62-v6so4158494ywd.6 for ; Sat, 15 Sep 2018 18:47:34 -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=4D4fvnp3QPX9Q4pNR4VeHpaUXUgOJTpCfrPxcjYJ84I=; b=f3Cz/ez9xgFjWuLm5aHtZVCmYdQeV6TgDZ7qMHKDhnVmpm5pfgBcHDvCoSYffRg9m/ 9KTOljtgEcAVl1T+bpaHZjeDNMIW/Lx3LwEpbiqKMU/y1umUHOVBWKs37lmDO1pcF/ye G08/lCLRl+/GaIYA4ozSo8VjmM6IGPeiXf7tY= 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=4D4fvnp3QPX9Q4pNR4VeHpaUXUgOJTpCfrPxcjYJ84I=; b=sZ6LO/PmnX86rH3DzLHqNMD77DBPdbDCln6rUFxtUGYstecSrkBEnDvkXv9+SbOHM+ d1gOExs5tf1N4XS1FcBRNSKJryQ+PCzdPL6NPltwujWq4Zi96XJ6vZNjc+ATzZ+ol7/R SO5eG7iKIL7N+bZ9YnCAIez73+NF0HJ4eSgK4AFFcnXGuOctmfi7uGL4cM86xObhw9et bOebG7VhBEB+5vk97PVq1pFwDdpXtHmMN+WRJ5jMby49WMzhkO6p9p327XoMdIXJQ7ri c0J01MCpwxUie5LGAjEmaW2ySXuSA+iQGVpQWvN8yOkr1wuZLO0EZUY4CNt2APUnuK57 whxw== X-Gm-Message-State: APzg51Cm0Qbpe/Ehncv+4VeOhEjbfF//kg7WL522Ko/K1Avm7hRggSmp BbhDOp9ALRTu9J6narQtUCPQ9X56caw= X-Received: by 2002:a81:5155:: with SMTP id f82-v6mr7659032ywb.30.1537062453887; Sat, 15 Sep 2018 18:47:33 -0700 (PDT) Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com. [209.85.219.174]) by smtp.gmail.com with ESMTPSA id v18-v6sm4624194ywv.9.2018.09.15.18.47.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Sep 2018 18:47:31 -0700 (PDT) Received: by mail-yb1-f174.google.com with SMTP id o63-v6so723270yba.2 for ; Sat, 15 Sep 2018 18:47:31 -0700 (PDT) X-Received: by 2002:a25:5c87:: with SMTP id q129-v6mr8312837ybb.403.1537062450735; Sat, 15 Sep 2018 18:47:30 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:5f04:0:0:0:0:0 with HTTP; Sat, 15 Sep 2018 18:47:30 -0700 (PDT) In-Reply-To: References: <20180916003059.1046-1-keescook@chromium.org> <20180916003059.1046-12-keescook@chromium.org> From: Kees Cook Date: Sat, 15 Sep 2018 18:47:30 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 11/18] LSM: Lift LSM selection out of individual LSMs To: Jann Horn Cc: James Morris , Casey Schaufler , John Johansen , Tetsuo Handa , Paul Moore , Stephen Smalley , Casey Schaufler , linux-security-module , kernel list 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 Sat, Sep 15, 2018 at 6:32 PM, Jann Horn wrote: > On Sun, Sep 16, 2018 at 3:14 AM Kees Cook wrote: >> In order to adjust LSM selection logic in the future, this moves the >> selection logic up out of the individual LSMs, making their init functions >> only run when actually enabled. > [...] >> +/* Is an LSM allowed to be enabled? */ >> +static bool __init lsm_enabled(struct lsm_info *lsm) >> +{ >> + /* Report explicit disabling. */ >> + if (lsm->enabled && !*lsm->enabled) { >> + pr_info("%s disabled with boot parameter\n", lsm->name); >> + return false; >> + } >> + >> + /* If LSM isn't exclusive, ignore exclusive LSM selection rules. */ >> + if (lsm->type != LSM_TYPE_EXCLUSIVE) >> + return true; >> + >> + /* Disabled if another exclusive LSM already selected. */ >> + if (exclusive) >> + return false; > > What is this check for, given that you have the strcmp() just below > here? From a quick look, it (together with everything else that > touches the "exclusive" variable) seems superfluous to me, unless > there are two LSMs with the same name (which really shouldn't happen, > right?). > >> + /* Disabled if this LSM isn't the chosen one. */ >> + if (strcmp(lsm->name, chosen_lsm) != 0) >> + return false; >> + >> + return true; >> +} Mainly it's for composition with later patches where the name check is moved. It seemed easier to explain the logical progression with the hunk here. -Kees -- Kees Cook Pixel Security