Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2430583imm; Sat, 15 Sep 2018 17:33:39 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaMU72NXZy2wIr8QiqHUKt87rzQ69Icg/FCoLPjP/6PIAloUErhKIqweiXeK81H6Q160DiY X-Received: by 2002:a62:c90a:: with SMTP id k10-v6mr19198516pfg.180.1537058019334; Sat, 15 Sep 2018 17:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537058019; cv=none; d=google.com; s=arc-20160816; b=PoPBoK8DLDt752s9fVWkhJKTuj68vtLZ24EgAUKKYxGl3Ka9qnJXENCmmEp+/HMeS0 n5fjdim9pdbdzta0K0zNW/WYCMKNMKc0OW2ldnV0mrlvMMDNJ9l3WzHCIYr0pWnbQO+q Mdgoc+qpUMP2yH5jhDB6AmaL/6Dism6VTOoU8MlL8U7CCaP0B0KwUGnQwPmrntWrSmBF YkdQOlg160fVWESccXRP0zwGjxSBJi/sGGXw1S44hkmvucXEuXN3jUHuIQRara94+8iB sj46r4b8cMHpETFn5tPyrKDo2PFDxGBn+y0YytlN0OUxPJLe3M8chyMNBdbpl47kUWo/ LNqg== 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=nLcsl65zXuCwewU4XBNjy0s1JU3SYG9gCRtZLL604ME=; b=UIqFnlMZQB9e2wo4UiDiP8fXVMVBzIK2Row41S6MHW15+qcbBJjDPKQnW8XsQbVPmb tlOUa4xd17xswib1tZ5JALYdKQfwyOlCuh1m3+pEGxM3ZUfI462JarfmWb6UhYC/AmLi /jM4h402yyoG3dTLlKQNl6ic2Hbd9GdA/wQUdvQkoDpbLzew8OLC/qMBMqHyxl+PL5DZ sTo2ahAu2AidVEw6yXrzzUo5wPz4g0czpT1hwMQmUOBe1NYbMfFE5MJfg3gC15AMDUaf 4nFhWGuhQ6XRtRVln1AwniIi+BYZJmjtcTAtT115Y3ZsSsrA6KI6z4eXKasX1Bt/zPeW PvAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=anYDr9YQ; 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 s13-v6si10814502pgo.505.2018.09.15.17.33.24; Sat, 15 Sep 2018 17:33:39 -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=anYDr9YQ; 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 S1728271AbeIPFwK (ORCPT + 99 others); Sun, 16 Sep 2018 01:52:10 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42681 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728155AbeIPFwJ (ORCPT ); Sun, 16 Sep 2018 01:52:09 -0400 Received: by mail-pg1-f193.google.com with SMTP id y4-v6so6014806pgp.9 for ; Sat, 15 Sep 2018 17:31:13 -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=nLcsl65zXuCwewU4XBNjy0s1JU3SYG9gCRtZLL604ME=; b=anYDr9YQ4Fa7NbHA7Q7jOy33HQQET52pJj6Qjgiy6nO2oXibz3UKxmVwFPjN1Kofm+ Iir9FuGDLrUNaJ2m+927D3fTmIwo5dLSaxsbMcIe8ZbSd5TENB8H5dmXeHx7TpeyDGAJ wBp5ZaKk6H7eWIxm+5dF0ihSJpWaKzGP/WcGU= 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=nLcsl65zXuCwewU4XBNjy0s1JU3SYG9gCRtZLL604ME=; b=oQQZF0OH3ylRp9QDA+hH8pwohyqYBWMO9n6qF1ayMJVq8cTJB1L0wjTqKKw8M3r88I YiBDXBCYZJfv/4EfKR9xFmYfRDYrnZH8zvqtrI9A6aXCqfeVOQBv2ORkpEmB7biDtozP i/RjJw7ZyiZL7CKz8lYkLLQQo8qGT3Natogrm3TmEHK8l/IyqKROfzj2l5zs9FNrJEc7 j267pCdSbUJN1CeCuc+SqR1lpFgoLGXm3D910sAfYuj+B4mZuC2caCugqY6eYs198THT JVYp9cBoaej4YhjedjAH2YIuljCEKY81u/GCFf/0PmJiSKGL5ATaGL/xDSSmzgxSd3wG MbvA== X-Gm-Message-State: APzg51DFI6jphPLYyefrb1mVA85xUjYYS4F6iOQvweUzodQZHx+s8+jL Mh4c1je9xp+uRsD3kHCk/skaL9L6EXo= X-Received: by 2002:a62:c699:: with SMTP id x25-v6mr19433799pfk.16.1537057872936; Sat, 15 Sep 2018 17:31:12 -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 h20-v6sm12346317pgg.3.2018.09.15.17.31.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Sep 2018 17:31:08 -0700 (PDT) From: Kees Cook To: James Morris Cc: Kees Cook , Casey Schaufler , John Johansen , Tetsuo Handa , Paul Moore , Stephen Smalley , "Schaufler, Casey" , LSM , LKLM Subject: [PATCH 07/18] LSM: Add minor LSM initialization loop Date: Sat, 15 Sep 2018 17:30:48 -0700 Message-Id: <20180916003059.1046-8-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180916003059.1046-1-keescook@chromium.org> References: <20180916003059.1046-1-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split initialization loop into two phases: "exclusive" LSMs and "minor" LSMs. Signed-off-by: Kees Cook --- include/linux/lsm_hooks.h | 6 ++++++ security/security.c | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index f8e618e2bdd2..ec3419b9b16f 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2039,7 +2039,13 @@ extern char *lsm_names; extern void security_add_hooks(struct security_hook_list *hooks, int count, char *lsm); +enum lsm_type { + LSM_TYPE_EXCLUSIVE = 0, + LSM_TYPE_MINOR, +}; + struct lsm_info { + enum lsm_type type; /* Optional: default is LSM_TYPE_EXCLUSIVE */ int (*init)(void); }; diff --git a/security/security.c b/security/security.c index 74ab98f82d34..da2a923f2609 100644 --- a/security/security.c +++ b/security/security.c @@ -43,12 +43,13 @@ char *lsm_names; static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] = CONFIG_DEFAULT_SECURITY; -static void __init major_lsm_init(void) +static void __init lsm_init(enum lsm_type type) { struct lsm_info *lsm; for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { - lsm->init(); + if (lsm->type == type) + lsm->init(); } } @@ -73,11 +74,12 @@ int __init security_init(void) capability_add_hooks(); yama_add_hooks(); loadpin_add_hooks(); + lsm_init(LSM_TYPE_MINOR); /* * Load all the remaining security modules. */ - major_lsm_init(); + lsm_init(LSM_TYPE_EXCLUSIVE); return 0; } -- 2.17.1