Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2463331imm; Sat, 15 Sep 2018 18:32:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbA2Qkn5R4596CDoGHIKmAiRceo3OIYopdZgSSLKGKYTfWa736+C6X0LqnCkmOL08YGwdBy X-Received: by 2002:a65:5284:: with SMTP id y4-v6mr16625375pgp.283.1537061570664; Sat, 15 Sep 2018 18:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537061570; cv=none; d=google.com; s=arc-20160816; b=nAMFTUaArOX/9iIr2FzCHWRoezqyz7/tSWqgsWHJW+Vhgx0Pp/yWrTZ0YAhobauTwT +c4tbGJr80QCzJ2G+aD4NZeNAcn/H4uaQgqBgiIfAmzZjJVBZtjuI098X+WvN/SzjCM4 Sv8d7Db13RSOgTInD9j0l1A+JyO4lhJAiV/ggxT1o4eYzxin0Y15o/uOLcFiPL1N9bDx v2PNeG0fzn3RD14nNg3+UTnhRO3vSpdpJyuU1RTVDhvUlrdxs2LSrXfjsc84fZkDkJdN FmPx6sz1S3W3h/exEp2fy9gsIKtj7llFSRx9i59CH9MUoEy6bUPNOAOjH7nXvZ+yzvz+ 7LqA== 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 :in-reply-to:references:mime-version:dkim-signature; bh=onO3wba/2X3vJdtAd/PjEugEkZLBESLYCJ4iwqTwRaU=; b=Uw1L+SifYNGP4q2NGT6B1f0VReIa26Iq4xrR7mWhP+e7Rqf1bcUsM8OaWaHV2DDfW7 tcNvtyoip5XdluVAq2bdfzGbnxX+N4RyLtJruCK5jj13oaAOI0YIyRWtRZkTmmt0tKLc ig45BUM7i0AlMZzXsnUj8Ab+u70DaLBooQKyhi9JOIYm1H6OpemiTuPGn8ZoKe8tT6iE BynU6IMuNjiZwDSu11oik53Z4/OMFsV/kX0nSfSo3OSkUlFvt+MXeiuZCFtcPbx9ZbT5 CPSJiSl10hYCkXfNLcymTKKGBpClPq9G3vnYmksmlO3wjXsW38+48Tgy6ielz+pRKeO7 BQyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="ZaR/SYvZ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12-v6si10808401pfn.322.2018.09.15.18.32.34; Sat, 15 Sep 2018 18:32:50 -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=@google.com header.s=20161025 header.b="ZaR/SYvZ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727133AbeIPGxg (ORCPT + 99 others); Sun, 16 Sep 2018 02:53:36 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:44274 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726198AbeIPGxg (ORCPT ); Sun, 16 Sep 2018 02:53:36 -0400 Received: by mail-ot1-f66.google.com with SMTP id 36-v6so8032813oth.11 for ; Sat, 15 Sep 2018 18:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=onO3wba/2X3vJdtAd/PjEugEkZLBESLYCJ4iwqTwRaU=; b=ZaR/SYvZFeYjirludgPE/FsvV9tWuqcQ5aZiAhLQbpPDfCL44+zElfw+mJTxMCIsm9 s8PpAtZO1JOmWJB5nGytQN43xg5TpdLzjeG6HNlpa9MJeGkX/t5ypRAk9AovwY0CKfej Tu8gE746EWK91Fpbe+yTWkWMHORCxpD1iWLAxTMkz+wvRvnYZsfYGkdd//a+yO6UZZYc L0Takbs9AeZE/mnmVF0MzsmMeKuOZ2WS8MztgaUjpnbKI5U+7vmV+U5leSzxTowqglUe Q2Ad6CytQQzA3m6TgUDhbsx/liDnH1Yman1MrLKd6q+pI6aSKiBsm42qkFAngKj9vkIN nIBQ== 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=onO3wba/2X3vJdtAd/PjEugEkZLBESLYCJ4iwqTwRaU=; b=s/y1eEr9+vBRBcagoMu/+XutMcBBmQMd3aGQKItsFBcJrngtIxqYPgrtloDyIEBCpz UkXvdmWhNMOtqfEy+2HsQsXBR/h41aNpdYbTF03L8R1hu5v6ucCJxxwk8K6Zx4EAK4Du d3G5mMswu+fAW2hTxS/oxUbVdHx6RnMnswmmgltxfLZGkoPw97N4ueVJtqgZXoW2udm0 hxOr7MoUCp4S07QXReXmmgi+jcgXy9w2ZJDDn48oET8zxQZFjL3H3YV29y68mbajYY4n ks+8REuWkiN2akGe4iQRiyIIR4zb+yecLX+9fF6Dkj/lA5ZRt58pt5Buq58+LTYdh+Yg gmzA== X-Gm-Message-State: APzg51A9DKfFySJDAfXTsMiFBzVw025lzCmujOOQwYl9V4/+1hm9QXgy ERiXG9D962O45k6pe0wzrw7liaTp3La012r3omjbmw== X-Received: by 2002:a9d:3224:: with SMTP id t36-v6mr8271500otc.284.1537061548279; Sat, 15 Sep 2018 18:32:28 -0700 (PDT) MIME-Version: 1.0 References: <20180916003059.1046-1-keescook@chromium.org> <20180916003059.1046-12-keescook@chromium.org> In-Reply-To: <20180916003059.1046-12-keescook@chromium.org> From: Jann Horn Date: Sun, 16 Sep 2018 03:32:01 +0200 Message-ID: Subject: Re: [PATCH 11/18] LSM: Lift LSM selection out of individual LSMs To: Kees Cook Cc: James Morris , Casey Schaufler , John Johansen , penguin-kernel@i-love.sakura.ne.jp, 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 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; > +}