Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2221321imm; Thu, 20 Sep 2018 09:32:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaadHT+aBYc1JS5Oo/p+L4xgG3PMiCICEIEkFzq7QcF0hzIPztcHqwJ0GnNZIkmK6JATg2i X-Received: by 2002:a63:5706:: with SMTP id l6-v6mr38744313pgb.118.1537461177697; Thu, 20 Sep 2018 09:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537461177; cv=none; d=google.com; s=arc-20160816; b=G5CLPUtFkJzVLbIwliG6Axg9Uab2uBtKF6SKo0sVyxmnfMNpTluFYTMGRX1Qr44geQ gVrDg+ezMiEYR9uGaVGuw7iVMB2h2Sntw0qygXdfyQrMtKqhzeeckeYPuS3iplHPVGNy fAm/paT0V3TVs6ODrMVaCtzBrht8H7MCIypI9wEcqIiGXZcVRtR9NpACTjeDrOdSUWZu rMkBTJTDFtLyela1ESNxOELtJPVZs1RSYbZ8CQznxRZHiDldFsQMIfDscpQxN2zT9/hJ djf2feH0DONayHetDCFY9UU3I9t1RHgvpvKDsIqk8fMz0r+G+zBltUwK0PkgR9bWnfV5 Wmug== 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=1R3OyL5qZwtVctuoKGY5KtAiw4R0ChLxsIprVubIdKY=; b=We6t6rnljtlXpBkh5aR38z+d6oE7doUvBX3cIH+e54xYdrjYl8E7SjrbMvKrwQC5k+ /+QgkYyydmoiJ1Te8/Yp5QCfGF0zgM3LMW+jdkNVyQKHBGLQURxvppTCT6gK1BrLORDS Dby5sP39ZKLCBlEFLG4GXCyqQV+kXHVseeVzS9/RMt0gnpIGVAp5ayjbAhLWFJjmk7Gy 9Jrh9SO0fT2plXEjwFNCRL2lgvSeXnMqkKRGfFqSrlz/4oapGQyOPxLY7OQ0fE3YhUZk IrDTVGWT/1uSY0q+4ByIVSOgwP7Qog1Jrsrjf7H35p++eKjkTQngZUv+pDR79iD9c2l5 RwCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cA2l9yp5; 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 7-v6si23967046pll.369.2018.09.20.09.32.41; Thu, 20 Sep 2018 09:32:57 -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=cA2l9yp5; 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 S1731752AbeITWNx (ORCPT + 99 others); Thu, 20 Sep 2018 18:13:53 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44810 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730919AbeITWNx (ORCPT ); Thu, 20 Sep 2018 18:13:53 -0400 Received: by mail-pf1-f194.google.com with SMTP id k21-v6so4609873pff.11 for ; Thu, 20 Sep 2018 09:29:35 -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=1R3OyL5qZwtVctuoKGY5KtAiw4R0ChLxsIprVubIdKY=; b=cA2l9yp59kBSM66Ek4dMpVBzmjS7OG6j+25ylPsFYwXzqkxEtpMvK6SDkZX3dOIcIu mrm1eg624plsw7/ZZKLEZnBJbvTnhPCkZQYgZLEKEgHngwO8enaDtRK5tTaC1emHaP5x YcwoB9yIPKsJV2Tg/RHhGh/a4OEeQ/q3PVUl8= 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=1R3OyL5qZwtVctuoKGY5KtAiw4R0ChLxsIprVubIdKY=; b=a6EMGg5rFmEsc3Jh1SeoB3q5C37I3n+i/cI8z9QORroyUyl+3S2W2+99jb0qsjIOXp /kXBd6lfv+vebzR8t/bk5FnNsDsJnPPDiUzKKfhCcsv0ehyS0lvyX/mxtCdDFB3DBLWx SGueRkni81Fzb5r//soJPHjp0JbxQa6T9rxbKamQa4GWf8+fx9Dct4T1YPGC0UpiL+Nz yLKh4lgGlFcC/k+rN4M78dIQkFGLQHmh4pd12J7J3dfGO1PtueziTYPuGogpmxzPMDIr kVGOuXBS8SnwKdsrcij97DDj6j9d/exRzjo/M2lXTRySSz1EmrrOHMRyIErNBvTiobuR OSzw== X-Gm-Message-State: APzg51CpO4dRfB87GVBJ1VOsOFbGrPkMulIniYdqFCNz7UWzTOTv6uHX DoVi4KlA3PQb2nw9QNwcHq2Uzw== X-Received: by 2002:a65:41c6:: with SMTP id b6-v6mr38007537pgq.174.1537460975559; Thu, 20 Sep 2018 09:29:35 -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 77-v6sm30867694pga.40.2018.09.20.09.29.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 09:29:34 -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 24/26] capability: Mark as LSM_ORDER_FIRST Date: Thu, 20 Sep 2018 09:23:36 -0700 Message-Id: <20180920162338.21060-25-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 converts capabilities to use the new LSM_ORDER_FIRST position. Signed-off-by: Kees Cook --- include/linux/lsm_hooks.h | 2 -- security/commoncap.c | 8 +++++++- security/security.c | 5 ----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index bf29851baf47..8e843eaacffb 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2098,6 +2098,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..7a6abaec65de 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -1366,10 +1366,16 @@ 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, + .init = capability_init, +END_LSM; + #endif /* CONFIG_SECURITY */ diff --git a/security/security.c b/security/security.c index d649e7dea4c4..a40e938db1b0 100644 --- a/security/security.c +++ b/security/security.c @@ -259,11 +259,6 @@ int __init security_init(void) } } - /* - * Load minor LSMs, with the capability module always first. - */ - capability_add_hooks(); - /* Load LSMs in specified order. */ prepare_lsm_order(); ordered_lsm_init(); -- 2.17.1