Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2429638imm; Sat, 15 Sep 2018 17:32:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZfWDKfCNdaSBTaFXU0zYkRQ8eqsCVFOWvdFPtn9TJXgi9uCIEGnxTkCRQCju0eMBKwcy+z X-Received: by 2002:a63:88c8:: with SMTP id l191-v6mr17745365pgd.340.1537057926450; Sat, 15 Sep 2018 17:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537057926; cv=none; d=google.com; s=arc-20160816; b=q7Ho+s33TnLQMGtsPbKYETBZ+dnFVvMgCL2gO4wLtoGtKlEPkowzLawkBuj7JJYoMK Aj1yNwSgIS3qxfW/7pUcPhgk0Um4Lp5/tdp5noIHVHmO8OFghxROiLZT6o5nif0SbnZa 9iNnfK72wsxrPK87PM1m9oQvru2fnMRy1rZgoqyECJnskW6D+u1UI1GIQdckVEpIYa8t E/EXBGn+uZUhNKAfeCPaF4EDRats2U8mVB8TKn7KO4LmClJkMgDb4o4j7TSkGGEme66e YmLEJkhUBWRYj1ncukuu/Y48R+ngEX3/waCKGdtJqXQSrv6XvXZxUvUNFDr7FmetGOkT xcSA== 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=ZygDN+GKMdmfwM3rhwi50SUesxIf3Y1MGUgzBmc4P3E=; b=P/rh4bMZuWveViakMT+gfq4zswX/DEcI3pcd9/0SisurIdQ5PGCFOPcGhY0Z3yTBE8 M+9XLj2OMU8OiKNE6uL6PntqUbHqXBg1Q1C4qx7wiAsqV6bYwexFOYxS42Gt2Mk4JQrI u/MGZvvBD8a0pYvPl9mXJPV3gc5U0BDAuwZfnwhKYPMcy6bMmFicpXIY3TZ6EmEPK2iP 0olnCIIl9ZvuhLtAT2N1nFjpwJrGXKy4osJsfyHTLQGj+Y1wz6nBpITcLjZNsdQO6SfF 1lGVp+jZA6FtkMQlnEpB39xVMW4Ql0BjqcSvzisd3h+qKT/flShYKYT/6IVc9vdHtLKx G2Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZnQPCYrr; 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 l63-v6si11710231plb.166.2018.09.15.17.31.51; Sat, 15 Sep 2018 17:32:06 -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=ZnQPCYrr; 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 S1728338AbeIPFwW (ORCPT + 99 others); Sun, 16 Sep 2018 01:52:22 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36464 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728315AbeIPFwO (ORCPT ); Sun, 16 Sep 2018 01:52:14 -0400 Received: by mail-pf1-f195.google.com with SMTP id b11-v6so5933690pfo.3 for ; Sat, 15 Sep 2018 17:31:18 -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=ZygDN+GKMdmfwM3rhwi50SUesxIf3Y1MGUgzBmc4P3E=; b=ZnQPCYrrvnEUrw1AEs1QnIOLhqnKniP2gEILD8MCwlx0ZIUjOJUOsWj19vTjRUisJf PcAPlkf1igpkEHCXtF3VUeLdQXPIy7id8V6CsjF9cm51Qv5C+xPHziYnSlPOAa4vfAMv oT1Di4yXwwMVFyOOOxKPhHn04g/apqO1L/ers= 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=ZygDN+GKMdmfwM3rhwi50SUesxIf3Y1MGUgzBmc4P3E=; b=PNb/SO/uEz+mbF2Q946pZPw8RhSSueNIfumfg8z/mCX5BqYOQ/mAk8UaiTLIn9p450 77lQD+aJeO/puj9W+CPPHx99Rm/9BUin8Yvre8aC4h5wpTT2hxlagrmHFeLm/GgsQzMK 0+QebjLjXkBVnsxUIgmb71tO47TGi3yiPpWyN+b3+H/aKCqj2DQC+jfVeLhxnP2oCBgT EYlCoSAiyUfCCXyjQT1TiYXkxhM7wIcmGIuzPN2ZRVPZncldRk0/YRWGNz95nTrERIXB wpfIdqH2qHSb4fi+iPQTQGZ9Ud/hre9O3zNQ0rRY9wwfnC/K56iasqU9URhh4pmU2kuV 2ycA== X-Gm-Message-State: APzg51D8DgJqTLNoLAG4grOcV2/iHQJX1qV4ukNat59tM4+zKOklPKLv r/AZxJhMcLQzA83qK0zeAyJJMg== X-Received: by 2002:a62:c008:: with SMTP id x8-v6mr19211170pff.149.1537057878544; Sat, 15 Sep 2018 17:31:18 -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 s3-v6sm16246688pgj.84.2018.09.15.17.31.09 (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 15/18] capability: Initialize as LSM_TYPE_MINOR Date: Sat, 15 Sep 2018 17:30:56 -0700 Message-Id: <20180916003059.1046-16-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 capabilities to use the new LSM_TYPE_MINOR marking, as well as the LSM_ORDER_FIRST position. Signed-off-by: Kees Cook --- include/linux/lsm_hooks.h | 2 -- security/commoncap.c | 9 ++++++++- security/security.c | 1 - 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 0564153130c8..f2949744a5d3 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2101,6 +2101,4 @@ static inline void security_delete_hooks(struct security_hook_list *hooks, #define __lsm_ro_after_init __ro_after_init #endif /* CONFIG_SECURITY_WRITABLE_HOOKS */ -extern void __init capability_add_hooks(void); - #endif /* ! __LINUX_LSM_HOOKS_H */ diff --git a/security/commoncap.c b/security/commoncap.c index 2e489d6a3ac8..44e7a9260f89 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -1366,10 +1366,17 @@ struct security_hook_list capability_hooks[] __lsm_ro_after_init = { LSM_HOOK_INIT(vm_enough_memory, cap_vm_enough_memory), }; -void __init capability_add_hooks(void) +static int __init capability_init(void) { security_add_hooks(capability_hooks, ARRAY_SIZE(capability_hooks), "capability"); + return 0; } +DEFINE_LSM(capability) + .order = LSM_ORDER_FIRST, + .type = LSM_TYPE_MINOR, + .init = capability_init, +END_LSM; + #endif /* CONFIG_SECURITY */ diff --git a/security/security.c b/security/security.c index c6ca07fc0771..67532326a0ce 100644 --- a/security/security.c +++ b/security/security.c @@ -124,7 +124,6 @@ int __init security_init(void) /* * Load minor LSMs, with the capability module always first. */ - capability_add_hooks(); lsm_init(LSM_TYPE_MINOR); /* -- 2.17.1