Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4608125imm; Mon, 17 Sep 2018 17:46:31 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYqX6aQBDnZGljoS2OpMPB2U3PaaKi6ISLy4fYK7kmOhW6dZQEwQmLH+b5hqACXc0thXvAq X-Received: by 2002:a63:4b47:: with SMTP id k7-v6mr25047215pgl.351.1537231591388; Mon, 17 Sep 2018 17:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537231591; cv=none; d=google.com; s=arc-20160816; b=CvO1B/ZBxTjtfAgeXH+gSakY2HRuMVU1+61MOIRMkRA+vt+31gqsaP4OUw4bpmi48A T6xAt6+NKqnRkT0qp7eome1dmg94sKxjZvC0fAvVxBTVmy9GRBbdtJIQwMmqjhzfSXsU wuKd+h3ThjQ6DDEQFixo3EQbjWNNvpM6NbDqLPBSnMtakTxsuT1DlXIYT7D4QOFMm7u7 PEqhhsJniTN7DDb3DGnUffkqWoRAWOdQnl5tuDA9Sb7j7rCxX3MvwLXLKAwvja8aecmv 5SMLF63NzljDyvfHqggLemeFZhrNhHUKNJteXkkYkGJjP4iRloI/m/BSSpyuRFPwEnRV Yqbg== 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=RLTFXtCKHlXSPakm8BOXJ+hCRLLkcB5u6dQOtHaqioo=; b=As00eGQbLFY2RebWlL9POMz3Vogi/ZkEK7ZPxLyqdLMef0fk0qS47IKFWqxofAJkwt klBIO3i63+4IpzLHpBKBOKuk6AWvUtt0XYZywLPfkjFYG/+B1vmIxY/M1cQVQpnJndaD FivzYYbbMFJP8Xw9xKVn7JPKqvv5D6/pSIpUh5/W69nkL+BwI9lekKhlpWxPoEqdN7Ru 1XAZ4Kz42VoZNXmQfyiHIBWS4lXXeq8TjD1sPBQNBzligs66ov5+1B+BGoYkDv1laHmI RVY3qoEGosfHfXneO7YtaDw7kAQsVFUoXye34MbteHwPNveNS1Pe/WJCj29Na+jRzw6/ 74gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OpAFDQ+u; 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 h14-v6si16545209pgl.289.2018.09.17.17.46.13; Mon, 17 Sep 2018 17:46:31 -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=OpAFDQ+u; 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 S1728922AbeIRGPZ (ORCPT + 99 others); Tue, 18 Sep 2018 02:15:25 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:37987 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725807AbeIRGPZ (ORCPT ); Tue, 18 Sep 2018 02:15:25 -0400 Received: by mail-yw1-f67.google.com with SMTP id n21-v6so91297ywh.5 for ; Mon, 17 Sep 2018 17:45:31 -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=RLTFXtCKHlXSPakm8BOXJ+hCRLLkcB5u6dQOtHaqioo=; b=OpAFDQ+u8r1pvUVD30z54DccG0hIGjjSaEeJGw4vktbmSKPAKbsTQI6lc270tAQezd qFlVdqWGsqlGhhFwDpjaIjRIN3sjVznoLmYDwR56AsLrb3ORNDjng/il24tCKcHm4MPO jpGz2WRTUn/r1qGhBjV+KhJFn1Brft7zFwSMQ= 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=RLTFXtCKHlXSPakm8BOXJ+hCRLLkcB5u6dQOtHaqioo=; b=m9+gHvWSBd69Wn5qKlqg2uj/kFbMYSIe5jvKqHDQ4IOfo0TPPCUgQP5PaZsHPJsiGe IhIrm0j/ywLCfZXycsp3WMM1Sjx4XCMNKlM915ZJb44G49Dd6ZEeYRgTCyR38sJOozUG MiFs7sL/VPBk9bYBYXPdsJuWl/Emz0bY/KMMhVuNO+2rVfgoRBQ92ZLkuBYGqU9skECe T3rxB1VR7BOG4H7wBodhYKR4aBvTkjnM2mSa20caTZtlNhxjqFGhtMQMyGgvld9cBs1r mkB6rTyPkFa2OVS+na/Ij1Wd5JfSsaxnGJN6AN+u3wk8kDdmjw/2YHB+Us8vlz0cLQHA ChkA== X-Gm-Message-State: APzg51CW0luzQMvGcThQqrB/maOVUhFpBx0XvnsHGi6U26PfUTP0VyFg 3ltNNzOJcLWDufIvYezcuRe+s2YFu3g= X-Received: by 2002:a0d:e847:: with SMTP id r68-v6mr11025181ywe.17.1537231531077; Mon, 17 Sep 2018 17:45:31 -0700 (PDT) Received: from mail-yw1-f51.google.com (mail-yw1-f51.google.com. [209.85.161.51]) by smtp.gmail.com with ESMTPSA id k130-v6sm1292825ywe.29.2018.09.17.17.45.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Sep 2018 17:45:29 -0700 (PDT) Received: by mail-yw1-f51.google.com with SMTP id l9-v6so79745ywc.11 for ; Mon, 17 Sep 2018 17:45:29 -0700 (PDT) X-Received: by 2002:a81:1194:: with SMTP id 142-v6mr11742647ywr.168.1537231529171; Mon, 17 Sep 2018 17:45:29 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:5f04:0:0:0:0:0 with HTTP; Mon, 17 Sep 2018 17:45:28 -0700 (PDT) In-Reply-To: References: <20180916003059.1046-1-keescook@chromium.org> <20180916003059.1046-17-keescook@chromium.org> <84e1a5a8-8997-829f-cf09-1d29895a3f99@schaufler-ca.com> <35b0af5b-e37e-e192-73b5-0d0b37d9e37f@schaufler-ca.com> <8f0bd39b-29a6-325d-4558-d9f484249c22@schaufler-ca.com> <53377892-695f-6336-8574-54c7aa0a4201@schaufler-ca.com> <7ecfffc3-d2a4-3ff7-4bf5-db3029d73c59@canonical.com> From: Kees Cook Date: Mon, 17 Sep 2018 17:45:28 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 16/18] LSM: Allow arbitrary LSM ordering To: Casey Schaufler Cc: John Johansen , James Morris , Tetsuo Handa , Paul Moore , Stephen Smalley , "Schaufler, Casey" , LSM , LKLM 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, Sep 17, 2018 at 5:24 PM, Casey Schaufler wrote: > On 9/17/2018 5:00 PM, Kees Cook wrote: >> The legacy per-LSM >> enable/disable ordering is the same, but ordering between >> lsm.enable/disable and the per-LSM options is NOT ordered. i.e. the >> precedent mentioned in the prior paragraph. > > That is, capability,yama,loadpin, Yeah, sorry, I didn't mean LSM order there, I meant the commandline order of appearance of the options. If you mix them, the last lsm.enable/disable for an LSM is the "real" setting, and the last $LSM.enabled= setting is the last of _that_ one. >> To support "security=", we'll still have some kind of legacy >> LSM_FLAG_MAJOR to perform implicit disabling of the non-operational >> other "major" LSMs. This means "security=$foo" will be a short-hand >> for "lsm.disable=all-LSM_FLAG_MAJOR-who-are-not-$foo". This will >> exactly match current behavior (i.e. "security=smack" and if smack >> fails initialization, we do not then fall back to another major). > > Right. Cool. >> I think we have to support runtime ordering for the reasons John >> specifies. Additionally, I have the sense that anything we can >> configure in Kconfig ultimately ends up being expressed at runtime >> too, so better to just make sure the design includes it now. > > Right. > >> What we have now: >> >> "first" then "order-doesn't-matter-minors" then "exclusive-major" >> >> - we can't change first. >> - exclusivity-ordering only matters in the face of enable/disable >> which we have solved now (?) > > I'm not sure where you get the conclusion we've solved this. > Today I can't say "lsm.enable=smack lsm.enable=apparmor", and > there's no mechanism to prevent that. > >> so, ordering can be totally arbitrary after "first" (but before some >> future "last"). We must not allow a token for "everything else" since >> that overlaps with enable/disable, so "everything else" stay implicit >> (I would argue a trailing implicit ordering). > > There's an assumption you're making that I'm not getting. Where does > this overlap between ordering and enable/disable come from? Handling exclusivity means the non-active LSMs are disabled. We had been saying "the other majors are disabled", but the concept of major will become arbitrary. If instead we move to "first exclusive wins among the exclusives", we still have the "the others are disabled" case. So exclusivity begets disabling. >> The one complication I see with ordering, then, is that if we change >> the exclusivity over time, we change what may be present on the >> system. For example, right now tomoyo is exclusive. Once we have >> blob-sharing, it doesn't need to be. >> >> so: lsm.order=tomoyo after this series means >> "capability,tomoyo,yama,loadpin,integrity", but when tomoyo becomes >> non-exclusive, suddenly we get >> "capability,tomoyo,yama,loadpin,{selinux,smack,apparmor},integrity". >> (i.e. if selinux is disabled then move on to trying smack, then >> apparmor, etc.) > > We're missing a description of what happens at build time. > It's hard to see what you expect to happen if I want to build in > all the major modules and don't plan to use the boot command line > options. > >> I would argue that this is a design feature (LSMs aren't left behind), >> and order of enabled exclusive LSMs "wins" the choice for the >> exclusivity (instead of operating "by name" the way "security=" >> works). > > I think I see more, but I'm guessing. At build time it looks like > you're dropping the specification on the "major" module. We can't > do that because I want to build kernels that run Smack by default > but include SELinux for when I'm feeling less evil than normal. Do we need build time _ordering_, or can we just go with build time "first exclusive"? For the v1, I went with "first exclusive" from CONFIG_SECURITY_DEFAULT, and left the rest of the ordering up to the Makefile. -Kees -- Kees Cook Pixel Security