Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2429875imm; Sat, 15 Sep 2018 17:32:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZt1YnBoTDeLjZS7CdcdmeK7QiJRYq7xckITm76Q2s4WmaI9oB1zadlTogeZ+kJtO+JS0F2 X-Received: by 2002:a62:6690:: with SMTP id s16-v6mr19271212pfj.152.1537057950177; Sat, 15 Sep 2018 17:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537057950; cv=none; d=google.com; s=arc-20160816; b=oE4lfHXd6wzuPhtxrCpJGrv3M44wNHhN+URJfCP7rdzoq49New7OHryRxp3LeDzbCM voCR+bY/HZnew2Wu2ynjnM2HcTPefdGa4j+2a9iVMON92ViQhl5N3tnWwx6VGrZUhSfE n2eq2b2xtrmB996tvGpXe2gQZXQt0kkTsXvtZ1pwaIYcMoZhtnt1RmKhrB+DfZbv0ud6 d4P6hbKSE63UaBwR+hBEi82vTBsbRZX8OPfk/ZnuUGB1Z7Pzj5UbRvdzzcDSLbfCJaUh VXyIPgZlC8pQ+HvEBC/aGZMAwO7LIMKN7OxOkcI5edcAlDAUDLx2abDSOTWzzbd8Fv+O nEDQ== 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=7Q3mcDF1Iy+AcAiBKA1xOkax77BkrDyqj4tYhY6FxOU=; b=IdyBpminwhRFHP/cC3h52elojurlgei+Pf67CmoOEoyo1T7NRzcksxFxo4IV+RPgP0 ZtMjF57yUgn3C8fB8T5m1qC3iNaaMyzOW3NqiiU9HD6r5elHgPn/nSVXpkB3UOx3lkAx QzGMrPG+UjroZgl4k7l5ACzObVSE6WZ5Wob8NaW0c/jj2rhY0IO0pxEjjTLSvuqV7zdq nRIjR79seVorRbMBCKmpVzRtkEI4wWN0ztA+dMtpFRLXLmhgFxSC+HtkoDGcI9surwsh HUZMrbkVVgytcPT74oizHb5ok9bXRvOQCX1b7AHryJ6GIThiC1D8MkmpcujWGXiZUTqw HKRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OYdbjjnP; 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 h30-v6si11513070pgb.269.2018.09.15.17.32.15; Sat, 15 Sep 2018 17:32:30 -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=OYdbjjnP; 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 S1728378AbeIPFwo (ORCPT + 99 others); Sun, 16 Sep 2018 01:52:44 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44485 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727324AbeIPFwL (ORCPT ); Sun, 16 Sep 2018 01:52:11 -0400 Received: by mail-pf1-f195.google.com with SMTP id k21-v6so5918885pff.11 for ; Sat, 15 Sep 2018 17:31:16 -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=7Q3mcDF1Iy+AcAiBKA1xOkax77BkrDyqj4tYhY6FxOU=; b=OYdbjjnP+4pUdSlKS3IllhrM6tfxmk8S05p1bdi2Clng4x+WiVYoYSyp16do6zrazv I48L5xu4zB+bQ/LQivc+/JS5+BgnvPs0rhrLCGnRmgwvgBUSEidI74LCH1AnK9vYvGr7 4KhkJ6vyOm1/NKO+gSuvFehqWx+v4qldOVoyY= 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=7Q3mcDF1Iy+AcAiBKA1xOkax77BkrDyqj4tYhY6FxOU=; b=NgxqIAHJjcrdwv0589kLVv27XNK49h32uRLQXiimDlnkhcU+w22aCX0qy0jr9BLVWq HDhTYKIcrRmtKe1To6y6NEiGGAOS56wOf4s0ujs1tkJqyVP1vEuYzS04ezBR6JTtopPp GK2UkEtiS+A7ASKkwYKtuu74xBVBWbZWS0VVDJctfJ/XZxuaBTuM6QDwEpyBni8ZNQ/T ckEIbXPffYlR2qsqrJA3axq9vfFZCGYDXqkqp+uPdn+/EZwpKSHnU8GBGbA9dYWEI2Ub jweTNjK+xZYW8DaYlIJqqBOZRG2cjUG7k7aepLzAKA6yDmJUKT190vm/6K1Sgg5PHBDQ URaw== X-Gm-Message-State: APzg51BFDHybGHxYtQIZYXYnSeuvAYULL4aDXZ52I8pwCQTp76x8H1Q9 Ssa766SzFP4TOlA9bQ7JvrO10w== X-Received: by 2002:a63:8f17:: with SMTP id n23-v6mr15987784pgd.131.1537057875922; Sat, 15 Sep 2018 17:31:15 -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 j27-v6sm20611906pfj.91.2018.09.15.17.31.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Sep 2018 17:31:14 -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 13/18] LoadPin: Initialize as LSM_TYPE_MINOR Date: Sat, 15 Sep 2018 17:30:54 -0700 Message-Id: <20180916003059.1046-14-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 This converts LoadPin to use the new LSM_TYPE_MINOR marking. Signed-off-by: Kees Cook --- include/linux/lsm_hooks.h | 5 ----- security/loadpin/loadpin.c | 11 +++++++++-- security/security.c | 1 - 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 89e6ec8eac07..5e0ca4a05091 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2107,10 +2107,5 @@ extern void __init yama_add_hooks(void); #else static inline void __init yama_add_hooks(void) { } #endif -#ifdef CONFIG_SECURITY_LOADPIN -void __init loadpin_add_hooks(void); -#else -static inline void loadpin_add_hooks(void) { }; -#endif #endif /* ! __LINUX_LSM_HOOKS_H */ diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c index 0716af28808a..8798d0b9b8e9 100644 --- a/security/loadpin/loadpin.c +++ b/security/loadpin/loadpin.c @@ -184,12 +184,19 @@ static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = { LSM_HOOK_INIT(kernel_load_data, loadpin_load_data), }; -void __init loadpin_add_hooks(void) +static int __init loadpin_init(void) { - pr_info("ready to pin (currently %sabled)", enabled ? "en" : "dis"); + pr_info("ready to pin\n"); security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin"); + return 0; } +DEFINE_LSM(loadpin) + .enabled = &enabled, + .type = LSM_TYPE_MINOR, + .init = loadpin_init, +END_LSM; + /* Should not be mutable after boot, so not listed in sysfs (perm == 0). */ module_param(enabled, int, 0); MODULE_PARM_DESC(enabled, "Pin module/firmware loading (default: true)"); diff --git a/security/security.c b/security/security.c index 19afd7949426..65d7ba1bc1ef 100644 --- a/security/security.c +++ b/security/security.c @@ -126,7 +126,6 @@ int __init security_init(void) */ capability_add_hooks(); yama_add_hooks(); - loadpin_add_hooks(); lsm_init(LSM_TYPE_MINOR); /* -- 2.17.1