Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1032741ybi; Fri, 21 Jun 2019 12:28:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyKxPubA7rlxnw5vyPbAHk4XCvLz003CtdkrGdP9x4aeBsGAlBbAOLGWR9IH2u4AJx5WVc X-Received: by 2002:a17:90a:37ac:: with SMTP id v41mr8355961pjb.6.1561145318958; Fri, 21 Jun 2019 12:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561145318; cv=none; d=google.com; s=arc-20160816; b=qBKeS5F/ARoY9FvK4epCAurnjekVqqjWJJpDnT1ZTYKfQ2fXqaK/PbCcETnFTrJmYC kJ6qXyqrWtwGqYLH/EW6TwmkyPsp/KhPcsCXiUgsawL2VGi9LGHujglX6bJvMxcafi6I ij3Z+AVAD7sLFyThBENp3zVhsA+TedPVkR3XWzeQPpdXECICLEWujVieViYKSfB95d+r 248OxvWoBi7I9yae92VUptPA1f9nxMAhK484yhimNeMQI2zaPcguXFKf51N5VfhM/5nP bZOsSniIJ/swpNTpypAdzZ0ORZKLt2duoFV1tG/zT/gP/CxH+X2mC7xBUq/RMl4+zwi3 RRQQ== 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=i7qxT+JyYemN2hqE07BFZyjlht15uSkSm2YTk/bCQH0=; b=vpfIJ7nUL3l28f6+giNL7RzEArBWrAp0uoH/Hv6GCLwn6zmLeTEp1fZtQUCqlQ1A3P lLSReVavqCpPpLtTeHWySlaCQibnph82hkTmkuscUexjmj9fpueEkTESPP+dAar9dC07 AUqy9VC5N8bvRwDWWoIrifgH3E+0P81+L6NWA5FKzGjMaGlrCfJFfHi+L6jSquZxtNwq PZK5u/XOqTJNIVBk4m0ws1Veck52i7M4vhriGcsMjMJ3u7Cy1RZnlJLyhpkHDd2FzRzy oNuuC+m/cAO17Y4nRHbNrm3Y4/X+mu0AABbv/Wp1S+o50fvfCf6pt9ehRlPML4n5JMNV 2hNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mb31X2uN; 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 x10si1723529pfm.71.2019.06.21.12.28.23; Fri, 21 Jun 2019 12:28:38 -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=mb31X2uN; 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 S1726534AbfFUT1E (ORCPT + 99 others); Fri, 21 Jun 2019 15:27:04 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:43290 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726401AbfFUT1D (ORCPT ); Fri, 21 Jun 2019 15:27:03 -0400 Received: by mail-io1-f67.google.com with SMTP id k20so210190ios.10 for ; Fri, 21 Jun 2019 12:27:03 -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=i7qxT+JyYemN2hqE07BFZyjlht15uSkSm2YTk/bCQH0=; b=mb31X2uNEiuhmlvxhmDHThl7mXed7roK4NpDrZdWL7O7D7j+OVqXumpvzGacwpsmlQ /jyBV+LH7UFWBTz9UKUsuCm+HDezOuVOw0u7EmWIyrPNdJttFWBH38798aIqqwY3nKl4 zJme8EeOphK0YtRMs1aeVPg9lssrz1TSz4IsDl6YFEpPNf9Qac1uqQAkvb/UXsyQLnSm IKUFMEVrUsBWgMj8r/+J/bDg5+kRLFBizc3hw8yp9DrPWd/ePAiYMWgIuIahfuaGwE0H TZ/t4oWhdT/47YhLERjc3+atxojsDZ3AliE5wu4iU2FhCR4T8WK+RiS+S5Jcptqoa0FP a1gA== 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=i7qxT+JyYemN2hqE07BFZyjlht15uSkSm2YTk/bCQH0=; b=Gt1468IxTvGrEhnssYn2iXoqbBkNyhoyEjJF+ttwUZf2V3GVaMZauCjpimsXTTVktY EoGOVtd/4zCuudur16JSmVbjl9NVIGbYpoViodcSVkMisZiRTI4ppZCNCEpKvqj/kwUA X1KMoDPFeC47ZDggxfUFuVuaKB4iWuwJ8vFlpO+Nkuw48ebLuADEIT9ZEt0xRgWZuuyK 4D/EkGd3KHtlu09ppLkOmBkTWWGFtmuWJmUmjPCOhrnWqDf7+cueZ7CgG/UEROkUm5Ds 9JfHVDNxz5Rw0SOExNAdP2lV6pg/6OBFPwjCSriFYiYrLEX4JjDpcVUeG4GRL3Ig/Rwt Z1tw== X-Gm-Message-State: APjAAAWoQlD6nUpsFARFIg30kDI4Ljtrr/lCy/GDV0AWZywE+i+Wm15h YacOe1+McYlV4rPeq3+P9zSg6MUAa7VXZgZw/pha2Q== X-Received: by 2002:a05:6602:220d:: with SMTP id n13mr19008846ion.104.1561145222426; Fri, 21 Jun 2019 12:27:02 -0700 (PDT) MIME-Version: 1.0 References: <20190621011941.186255-1-matthewgarrett@google.com> <20190621011941.186255-2-matthewgarrett@google.com> <201906202010.49D16E03@keescook> In-Reply-To: <201906202010.49D16E03@keescook> From: Matthew Garrett Date: Fri, 21 Jun 2019 12:26:51 -0700 Message-ID: Subject: Re: [PATCH V33 01/30] security: Support early LSMs To: Kees Cook Cc: James Morris , linux-security@vger.kernel.org, Linux Kernel Mailing List , Linux API 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 Thu, Jun 20, 2019 at 8:22 PM Kees Cook wrote: > > On Thu, Jun 20, 2019 at 06:19:12PM -0700, Matthew Garrett wrote: > > The lockdown module is intended to allow for kernels to be locked down > > early in boot - sufficiently early that we don't have the ability to > > kmalloc() yet. Add support for early initialisation of some LSMs, and > > then add them to the list of names when we do full initialisation later. > > So, if I'm reading correctly, these "early LSMs": > > - start up before even boot parameter parsing has happened > - have their position in the LSM ordering ignored > - are initialized in boot order > - cannot use kmalloc, as well as probably lots of other things Accurate. I've expanded the description. > > pr_info("Security Framework initializing\n"); > > I'd rather this was kept in security_init() since it's the string to > search for when debugging normal LSM initialization. Ok. > > > > @@ -343,6 +342,30 @@ int __init security_init(void) > > i++) > > INIT_HLIST_HEAD(&list[i]); > > > > + for (lsm = __start_early_lsm_info; lsm < __end_early_lsm_info; lsm++) { > > + if (!lsm->enabled) > > + lsm->enabled = &lsm_enabled_true; > > + initialize_lsm(lsm); > > + } > > This should call prepare_lsm() before initialize_lsm(). While not needed > for this specific LSM, it would be nice to at least do the blog size > calculations and keep everything the same as other LSMs. Ok. > > + > > + return 0; > > +} > > + > > +/** > > + * security_init - initializes the security framework > > + * > > + * This should be called early in the kernel initialization sequence. > > + */ > > +int __init security_init(void) > > +{ > > + struct lsm_info *lsm; > > + > > + /* Append the names of the early LSM modules now */ > > I would clarify this comment more: "... that kmalloc() is available." Ok,