Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2213681imm; Thu, 20 Sep 2018 09:25:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZZ9JlIHA7jEhFyNO01k6QjhNJ7v0dwBmaXJ2DgpqxMW47HLlh4If9lC1Pavpe/RhaoLN+m X-Received: by 2002:a17:902:7488:: with SMTP id h8-v6mr40029280pll.16.1537460749098; Thu, 20 Sep 2018 09:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537460749; cv=none; d=google.com; s=arc-20160816; b=TK2RcSSLViV5Zo4nOSRppBJsUBfYOQ40R1Fem6IVaeZpFOqFFk/S+Kx5xcwS1oKl3X gLbhBfBhAtZhdyPg4t8ymENeeU59KBNOeyZWlCyJcfCeLS0yFt+/xVrOqTPutaNuXAbC uHzQ8LNyFwoJvf7HxUMr6dTWKwYu1A2IYiJmbVbNhnLW7d9f468Zr+1F2b+50e6e7pN1 UVBaBUaLlP6h2lPzznKMo9C+QUUcGe2yZh6pJTYbc6yaq+JIyiSuadZKt8A4qNc9lKh1 ofVY5aE2ANKTsRkCI1YK3BOaavZVE6P+3DfzAr+WZfnU0R+/PtKuwgYk23vdMnef8LAQ i6TQ== 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=5TLT0f4fZoyxcv+w2j50Rd/UuLy9YsMhEgdbx0R13nc=; b=KIRz+Yb0k+0xPxJK8cCGdgrV7L4cDWWbnfkaYxSkxBv4PmUTDr24r+HFonUQu62FE6 NWhwQ6Ys9pvewT+KTMNiTvhYl9IkER2TAcXH+nwYdNJuOxBXAdHqWrnt4JnPNQLZz67g YveuN5r1KyveKJk9DMDu9nY1gj1d62Ht7lUVUWH1T4HLrYWKckF51vk3k1gIlst6IjeV outXG5VNsDOEo+F/m/HjqymF9P2vGVtwUKxtpO7a8G1wePOneG46xNYi6xg4XTHUQlQY zC2sn8b3W3wMDqnQaXrwkc39illi6Yf/ABwzmLjizSERvXupTKwNIXHFcqrw9Szr4wr3 oUmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NcJsP5U7; 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 h7-v6si24651933plt.258.2018.09.20.09.25.33; Thu, 20 Sep 2018 09:25:49 -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=NcJsP5U7; 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 S2387985AbeITWIM (ORCPT + 99 others); Thu, 20 Sep 2018 18:08:12 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36832 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387963AbeITWIM (ORCPT ); Thu, 20 Sep 2018 18:08:12 -0400 Received: by mail-pf1-f193.google.com with SMTP id b11-v6so4622141pfo.3 for ; Thu, 20 Sep 2018 09:23:57 -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=5TLT0f4fZoyxcv+w2j50Rd/UuLy9YsMhEgdbx0R13nc=; b=NcJsP5U7+6EjbMYMW/1hKk0ViAKeIKbOwSryqKk9/eHnu/JNS3v455kWl9dqpuTSad n1PM/V5avOJVVhiZNSOP29Lu+gwCBWTDm7IuaVNDeJ3mqZ74bFvrebnJkJ+ya3E7i47b K1VdaGsa0XsaJcgdETZ5UzHBZ0beZPmKkGiMI= 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=5TLT0f4fZoyxcv+w2j50Rd/UuLy9YsMhEgdbx0R13nc=; b=hVFXoGPB2FnXri0E7M4+FGY/QYBNyhsl2q4FL/SWs1Eb+M45DdHwRwXwuntBl/uJyd N/UGXPXn7tlJHHMI7crasKnVF8NP/AG8H85QHHvW+oXoYyX5dnlJxsFsTv6mu1whY3sM 97zyzYCKFgCQsQMcq3Kr3PORcS4E9CReHjAjnwudQmrlpzeKESbu7FbdCZzL/bXledfj YiuxomkdUWgwbnYNT18XDodZliEk1y/2BNyzS/p28H4yD4NHkv19G7iXxxhultGyUPyt DZFcdNljzMOawunfLxW+GFXydOmejcHv8T444XLY/ij1eySWNuJiazvojs5yTD+1S0hC N4gA== X-Gm-Message-State: APzg51DDL6yr38eLaDc2jrjijpkvF6z+y9jRdoaAobz6MCawZfmPAdjg XNPLt7jgAyKbryuWx/Q4KhxrmA== X-Received: by 2002:a62:1e81:: with SMTP id e123-v6mr42012574pfe.24.1537460636734; Thu, 20 Sep 2018 09:23:56 -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 x23-v6sm35186397pge.61.2018.09.20.09.23.48 (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 12/26] LSM: Provide separate ordered initialization Date: Thu, 20 Sep 2018 09:23:24 -0700 Message-Id: <20180920162338.21060-13-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 This provides a place for ordered LSMs to be initialized, separate from the "major" LSMs. This is mainly a copy/paste from major_lsm_init() to ordered_lsm_init(), but it will change drastically in later patches. What is not obvious in the patch is that this change moves the integrity LSM from major_lsm_init() into ordered_lsm_init(), since it is not marked with the LSM_FLAG_LEGACY_MAJOR. As it is the only LSM in the "ordered" list, there is no reordering yet created. Signed-off-by: Kees Cook --- security/security.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/security/security.c b/security/security.c index 1f055936a746..a886a978214a 100644 --- a/security/security.c +++ b/security/security.c @@ -52,12 +52,30 @@ static bool debug __initdata; pr_info(__VA_ARGS__); \ } while (0) +static void __init ordered_lsm_init(void) +{ + struct lsm_info *lsm; + int ret; + + for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { + if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) != 0) + continue; + + init_debug("initializing %s\n", lsm->name); + ret = lsm->init(); + WARN(ret, "%s failed to initialize: %d\n", lsm->name, ret); + } +} + static void __init major_lsm_init(void) { struct lsm_info *lsm; int ret; for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { + if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) == 0) + continue; + init_debug("initializing %s\n", lsm->name); ret = lsm->init(); WARN(ret, "%s failed to initialize: %d\n", lsm->name, ret); @@ -87,6 +105,9 @@ int __init security_init(void) yama_add_hooks(); loadpin_add_hooks(); + /* Load LSMs in specified order. */ + ordered_lsm_init(); + /* * Load all the remaining security modules. */ -- 2.17.1