Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp720134imm; Mon, 1 Oct 2018 17:58:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV63NrTCG4H+uXZhnLySn54VPunQmQDJWxHE9Z2GO3riDGFooIn6FY7nn5GKQ4YVQeVBdLKXy X-Received: by 2002:a62:c957:: with SMTP id k84-v6mr14027630pfg.205.1538441896655; Mon, 01 Oct 2018 17:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538441896; cv=none; d=google.com; s=arc-20160816; b=fr80r3dGHAlwDSSQ6S27uLtYu3/iMwv+R71p+3arz2nlyMtiRRAnQEgdXI1a8yczq+ yFsSP2BX5s43SivmSOhJJQXMe/spzuGTgLM957+POVOAosvYbs3n06UrE6T8n/WCAUWw /3j40rVo5EK/sHA4lqnInYLQTZhxM4r8wuAa7xoHPFYr0CZhH2bUN0VsKDuZeZLgjQNl X79YGy80W+sZbbFWEelPKFke1t3loOzg4eG6j/vZLvmFivWrLt2fltV9cY2snAbYkVu0 zxBdKkMPAXccP/UZxkeqnnnOjfovzOc0uXharF24FNdtucdTh6ElhnVtv1od80bYaF4V 8Y8w== 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=K8Z4hRQ9RjNB3cw7dID4X7rT0mlxEqRr67feJ2NB/9c=; b=eX9mcjZ28PzHV4XCji8CxMTYcdjI1Bef5dCDyY2vfeUHCFdtSkcr1Z6R6dff7TMmS3 rFdXQRr5XtWpK34CQdKyUiughZqDllO10vJVMEilciwrNjz9hy/YkbWwvi+PJgj0IinB R1ZflEdOrRYcaJ+l4ADICOjer1lTbdd/m59B9g+0DVUIHTCwHJe7RCw7QCboE9lLt5bR wbKaYHMyRVKB8PUAhjNcaSSGM9MltN0pxPkCCC9tZwPCwWelMRlFV3wMmPBT/je6Ry6y MppzWbqE0obH/lOrnBBflkJR7Ohy/7OjVB52Wtl0on1kHiBKfMyLgS09LKyPAh6KncTf GMkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LVblWbAN; 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 c21-v6si4313051plz.283.2018.10.01.17.58.02; Mon, 01 Oct 2018 17:58:16 -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=LVblWbAN; 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 S1727400AbeJBHgu (ORCPT + 99 others); Tue, 2 Oct 2018 03:36:50 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:38072 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbeJBHft (ORCPT ); Tue, 2 Oct 2018 03:35:49 -0400 Received: by mail-io1-f66.google.com with SMTP id y3-v6so253194ioc.5 for ; Mon, 01 Oct 2018 17:55:20 -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=K8Z4hRQ9RjNB3cw7dID4X7rT0mlxEqRr67feJ2NB/9c=; b=LVblWbAN149pKjvi/TQyVOztj+MqZCELBs+pFQ9zZZ3rdPQ6OerOCyG+HZhHoBDDjl 1NVwR//kQ8OUuQWlwoAJ4UCW8/0/iPcqdVvmX1BNm/AeUZa1CEUyYmx5vPGGuWpXyxW9 +ZAoaVcHw740JE62LbcteksEmFJ+XduA8WsdE= 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=K8Z4hRQ9RjNB3cw7dID4X7rT0mlxEqRr67feJ2NB/9c=; b=E8+YTHblWAezk6D4kCsj3o31Q2QSzNhX60gdaUMDkfSbKGg79ZAPt04KLh7ScY+wOZ vY7W+rGZaVFyuX2KnvTA3mnAedW77lbX9G2CLaXIFRRDl0TZdv7r5K8PfU7R054TEHQn XqrbW31XxCezAPMf7pYsGxuKbR/hBsMRyRR2btzvFvTo1NN1UcQuY4OUHzPHGVCy6yPx 2pDyZzTvHHtTNVGi7mVdjKcRIlM49y3rs7A+MZPvOW54AWP66AiO3t8RKGH1XND4h1EI 7H8wAzIojUds81V5gJ+6pEcOwHFPavJwmt2894iYBgO6oU+FfykJIPAigIeeuL4wlYHq hQLg== X-Gm-Message-State: ABuFfohDp/ijkNTGmYykU60VagrzokVIt3abo44gFhJSQnPxBm1WODad e1X7Hu+KPxAhcJsdVndGwbPV1Q== X-Received: by 2002:a62:8490:: with SMTP id k138-v6mr13802325pfd.177.1538441720500; Mon, 01 Oct 2018 17:55:20 -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 z22-v6sm19576710pgk.21.2018.10.01.17.55.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 17:55:16 -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 v4 12/32] LSM: Provide separate ordered initialization Date: Mon, 1 Oct 2018 17:54:45 -0700 Message-Id: <20181002005505.6112-13-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002005505.6112-1-keescook@chromium.org> References: <20181002005505.6112-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 Reviewed-by: Casey Schaufler Reviewed-by: John Johansen --- security/security.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/security/security.c b/security/security.c index 2055af907eba..ebbbb672ced5 100644 --- a/security/security.c +++ b/security/security.c @@ -52,12 +52,30 @@ static __initdata bool debug; 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