Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2212288imm; Thu, 20 Sep 2018 09:24:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaaxfG9DdbvUJjni3pN/TqN2LlKAV7jWp8nrvfp6KhTiwFpGKFlchyUYsLwuFIc8Z0Rw7CR X-Received: by 2002:a63:8c0b:: with SMTP id m11-v6mr37356195pgd.372.1537460672369; Thu, 20 Sep 2018 09:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537460672; cv=none; d=google.com; s=arc-20160816; b=GO7AvjnQo/7EUwDPrOac1aZcjVRotyXxjIuNTOGA1/egJkH25RHQwDTnyORCKJ85om f1fLnWqVxakoQ8zmYy+oiXQf57XAzIU7X2769uxd9Tw2OWuhruB5SmnVBvQ035OFfkU2 xtvNITeclI+/tL4ycQWQfqMCLaIFgTeAe33FNH05zT8Zj8l5AZ7kbTvLM8kufF6FdBRd 3qFmrf817oQtVn2QVzr5fdvTGiRrjSoMqmJXu9K1L7KzLyoZohTUzQ1DXezAKyqoe/VK /ie8oH122LT1+z2bFr4e8op74z/JH15NHRv6MCKOjYsrikNWvNfaGORH/SMKNHv6rjCW t59g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=dj661ofWrIevUkOjpEMxgFKe/xflRUudjm72RcAWxpw=; b=JCyCgHfFDXvQskFgwmxzknCJYHTn+9dGJVM8i1lCP8S5aHQ/adMGdYs9GanC9moase Yp27VArJVFsSFePDj/Lm7pZgf6VwNsn1yjT43jMZ/ddz45bJDU9Y4RMzALMS/2XhN9BK if4GMSmx15i8Uh4T5rCM5bTmlCuJp6DvwPVo9ZI74UFBkt2J7Hs8IMPuG7d2OuXRkIub dwwXIKJfesaytccQhJmbfQ2ufkoRJqIsDh6j2KQyCjN1D4tVhmGzPxA+OYprw2MpLmj8 /bneJ2w/yc6jeGQ1/iTi730sio2aOZgthu4Y4jgSOUVGl1XsolZ4bH1cvTqYji4IhjCr eqQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Xzr75Puy; 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 az1-v6si23597981plb.513.2018.09.20.09.24.16; Thu, 20 Sep 2018 09:24:32 -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=Xzr75Puy; 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 S2388049AbeITWIS (ORCPT + 99 others); Thu, 20 Sep 2018 18:08:18 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38847 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388045AbeITWIR (ORCPT ); Thu, 20 Sep 2018 18:08:17 -0400 Received: by mail-pf1-f193.google.com with SMTP id x17-v6so4614611pfh.5 for ; Thu, 20 Sep 2018 09:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dj661ofWrIevUkOjpEMxgFKe/xflRUudjm72RcAWxpw=; b=Xzr75PuyPMjChpDxxAd5r9+6AhusmkdlEV7ZXnkFp2FPl71FEA54aVfPu+dM0YsmIm H6NdFLUQLe52sx2DUbIErzIspSGfK7goeUapLNpocp32yG/9QttxEMIaLS5ZyNRMOIMq JNpwTsplJpOu7B1JqZoAohZ1ajUhXKjse6UTg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dj661ofWrIevUkOjpEMxgFKe/xflRUudjm72RcAWxpw=; b=IQd0uCCiDZAvda1PVJeme9PS6eVG19DWa7wzzNBJqKT0qoBwnn0Zqu9fhAjJGAo16m pyPx4USFQfGPB0/oEdGtBE3WBMEUb0RY8ez77WxzEWEvJMNmJcQYGzyzNFI9ZIDfFB0c olJOw++RvIDsYMPQEJfIGnjoixjdsue3UllXdKDwrB0QpwtXJAAeVRmnO+0spTPpFL1Z 454NUjZCvQ8TgjXPPkVw83nT8MUlQqy9Xbdlv90RnyySWRtJG1sa0/0zGU4YBZFzG06u agSLHzMAsIGfotEA2WBx2tQGVrbHTi7N1yGQBZTcA+I+uU9aDJe+bwFZpKxx2prRX6/f nhQg== X-Gm-Message-State: APzg51D2SjUo0ghEbtfYngVacooD6AJL/1pkAOBZ8pUM4++ZYGd1Zvig jixuUlzQDO4nu9NN/wX7dKH8Xg== X-Received: by 2002:a62:f909:: with SMTP id o9-v6mr41908083pfh.141.1537460641405; Thu, 20 Sep 2018 09:24:01 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id v8-v6sm30976479pff.120.2018.09.20.09.23.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 09:23:55 -0700 (PDT) From: Kees Cook To: James Morris Cc: Kees Cook , Casey Schaufler , John Johansen , Tetsuo Handa , Paul Moore , Stephen Smalley , "Schaufler, Casey" , LSM , Jonathan Corbet , linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH security-next v2 20/26] LSM: Introduce "lsm.order=" for boottime ordering Date: Thu, 20 Sep 2018 09:23:32 -0700 Message-Id: <20180920162338.21060-21-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180920162338.21060-1-keescook@chromium.org> References: <20180920162338.21060-1-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide a way to reorder LSM initialization using the new "lsm.order=" comma-separated list of LSMs. Any LSMs not listed will be added in builtin order. Signed-off-by: Kees Cook --- Documentation/admin-guide/kernel-parameters.txt | 5 +++++ security/security.c | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 32d323ee9218..5ac4c1056ffa 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2276,6 +2276,11 @@ lsm.debug [SECURITY] Enable LSM initialization debugging output. + lsm.order=lsm1,...,lsmN + [SECURITY] Choose order of LSM initialization. Any + builtin LSMs not listed here will be implicitly + added to the list in builtin order. + machvec= [IA-64] Force the use of a particular machine-vector (machvec) in a generic kernel. Example: machvec=hpzx1_swiotlb diff --git a/security/security.c b/security/security.c index 063ee2466e58..4db194f81419 100644 --- a/security/security.c +++ b/security/security.c @@ -43,6 +43,7 @@ static ATOMIC_NOTIFIER_HEAD(lsm_notifier_chain); char *lsm_names; /* Boot-time LSM user choice */ static __initdata const char *chosen_major_lsm; +static __initdata const char *chosen_lsm_order; static __initconst const char * const builtin_lsm_order = CONFIG_LSM_ORDER; @@ -136,11 +137,15 @@ static void __init parse_lsm_order(const char *order, const char *origin) kfree(sep); } -/* Populate ordered LSMs list from builtin list of LSMs. */ +/* Populate ordered LSMs list from commandline and builtin list of LSMs. */ static void __init prepare_lsm_order(void) { struct lsm_info *lsm; + /* Parse order from commandline, if present. */ + if (chosen_lsm_order) + parse_lsm_order(chosen_lsm_order, "cmdline"); + /* Parse order from builtin list. */ parse_lsm_order(builtin_lsm_order, "builtin"); @@ -264,6 +269,14 @@ static int __init choose_major_lsm(char *str) } __setup("security=", choose_major_lsm); +/* Explicitly choose LSM initialization order. */ +static int __init choose_lsm_order(char *str) +{ + chosen_lsm_order = str; + return 1; +} +__setup("lsm.order=", choose_lsm_order); + /* Enable LSM order debugging. */ static int __init enable_debug(char *str) { -- 2.17.1