Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2220864imm; Thu, 20 Sep 2018 09:32:30 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdasg4Ar++lYAnHejzRMPtlk/wG02xP0AbJHKIqNrJpS1/NIw5IGEVbhQG2JtlrWAEZ60QIR X-Received: by 2002:a17:902:6b89:: with SMTP id p9-v6mr39893487plk.272.1537461150698; Thu, 20 Sep 2018 09:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537461150; cv=none; d=google.com; s=arc-20160816; b=fBnFtPNrxmoopMSncbFoXeDd7it0J+1BfWV05+7Ec+RB9FFEhqjkAtLbSLdUBOoNZq rzbaXreJxk8saRilSz7gWM2hY08g5LRoiFyvQKGhR4JnR71zBZiW3fXMGRS6CCblNZQ3 4RSPMKXJcm99Wb0nhMsT/reD7gnDuIxL0RKMRdSutb5vnQaMbkoLzmI85P9dPYow39EU eUpygPEzXnYvW3hdSYVB0P/bOkmv0qiKHZwkaovJRQ4C7/VSYr5Gmn6DFkmNGSP858m+ 9DKGolF1I4UXWx7IOw9MiOeK1/JpL2845Sv3ArN00WkmpC2kSH1uGqdD9DYvLfnRg1Dr peGA== 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=qtAuKUKVjVollDKfCkucnLwtQ83jnd8R7dPZQ4Yx9Xk=; b=TWW5gCwIXgp+bNzdURHXixB4bhw4J1+oABXp/QIyeQbr7bgCylP7wt2riliNuCLUwN 0sVBK4X1x6EFDrn+IvkMusqvMGxMST2swvSqQlC3WGT63BsneNZyFJl9ysrps2MrH2Oi a7gdoCiKv0h3x507Cmsmdwyi6fY8Ps/2rNu3EYD02jjuTrliRL+eXZqJKgEf3JTdPz5G vNqZvneFGRwHro7OFhC/u6zCRaN7chgcsbhbYTIlAU4BJPuZ0xDwLMl4A5y/hD/U+VRh 7onxmWhSkGCBCh2LUhKT80EO1YIM6XcO2/S/frdmnEma9yKrwK81O7cN/UCd82LxGuKq 4lkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Y/dz1OLI"; 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 u26-v6si21803197pge.590.2018.09.20.09.32.14; Thu, 20 Sep 2018 09: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="Y/dz1OLI"; 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 S1733089AbeITWOg (ORCPT + 99 others); Thu, 20 Sep 2018 18:14:36 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44536 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732441AbeITWNy (ORCPT ); Thu, 20 Sep 2018 18:13:54 -0400 Received: by mail-pg1-f195.google.com with SMTP id r1-v6so4668865pgp.11 for ; Thu, 20 Sep 2018 09:29:37 -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=qtAuKUKVjVollDKfCkucnLwtQ83jnd8R7dPZQ4Yx9Xk=; b=Y/dz1OLIolEb2yZ/e8y7bqda98lTHMigYL4o5XmwNCukanc6I/xD6dvGOcYMCBAQn0 0gnTguygwUoAmP96B4iGq+ZqPMOBjBxpSoZEa2oTLIUfocU+XiqDNXO2/cK1XdEo6w0I z5aeq2Ttwocv6sLByapNAVvAE6abLwK025S2c= 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=qtAuKUKVjVollDKfCkucnLwtQ83jnd8R7dPZQ4Yx9Xk=; b=T11XX6VqhTW6HiGIMNgcGH0w7KPm9PrtUUQd3OReBEwjqQPi//OQcBij6vK3I7OR3Y paEY3Kbp6TuGAc3qionEqGx/EiEXYPZPr1j7o4rp0jCG/zrTsnk0zELSruRU3ysaQDlX RPBVlGKhdZT/HICreCW/4lCL21wN2li6PWkEE92EW/C0y7fP8OiLMf6olxP5EdgSuevd tf6LH4wZJ/WF6CyFuoCTJJEaKzFltLN/vEvQLN0gaqP0DHym/ff9hvAEiarv92fUWuQ/ OeMSHMqhj8JlrF5oqEqQ2+ybPHKOJvVSFHSjUJfQ+C+oTXzGL8kPinKqpojWtZpS8Py1 P0YQ== X-Gm-Message-State: APzg51C78QLYRyp9mh9dIFR8Jp7ZSG+0w7MhsGHnm2OwENIddxN5Xwfl 4gE6oNg/l9xSzNpHJwYA4g7qNA== X-Received: by 2002:a63:720f:: with SMTP id n15-v6mr2299368pgc.193.1537460977198; Thu, 20 Sep 2018 09:29:37 -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 j184-v6sm32087992pge.77.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 22/26] Yama: Initialize as ordered LSM Date: Thu, 20 Sep 2018 09:23:34 -0700 Message-Id: <20180920162338.21060-23-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 Yama from being a direct "minor" LSM into an ordered LSM. Signed-off-by: Kees Cook --- include/linux/lsm_hooks.h | 5 ----- security/Kconfig | 2 +- security/security.c | 1 - security/yama/yama_lsm.c | 7 ++++++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 7a38ffdd690f..d75a42eb3ddd 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2092,10 +2092,5 @@ static inline void security_delete_hooks(struct security_hook_list *hooks, #endif /* CONFIG_SECURITY_WRITABLE_HOOKS */ extern void __init capability_add_hooks(void); -#ifdef CONFIG_SECURITY_YAMA -extern void __init yama_add_hooks(void); -#else -static inline void __init yama_add_hooks(void) { } -#endif #endif /* ! __LINUX_LSM_HOOKS_H */ diff --git a/security/Kconfig b/security/Kconfig index f2003bd03ef6..33c9ac3cb759 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -278,7 +278,7 @@ config DEFAULT_SECURITY config LSM_ORDER string "Default initialization order of builtin LSMs" - default "loadpin,integrity" + default "yama,loadpin,integrity" help A comma-separated list of LSMs, in initialization order. Any LSMs left off this list will be link-order initialized diff --git a/security/security.c b/security/security.c index 9ffb76b7655b..3fba28de789b 100644 --- a/security/security.c +++ b/security/security.c @@ -245,7 +245,6 @@ int __init security_init(void) * Load minor LSMs, with the capability module always first. */ capability_add_hooks(); - yama_add_hooks(); /* Load LSMs in specified order. */ prepare_lsm_order(); diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c index ffda91a4a1aa..f2b1f47f98e8 100644 --- a/security/yama/yama_lsm.c +++ b/security/yama/yama_lsm.c @@ -477,9 +477,14 @@ static void __init yama_init_sysctl(void) static inline void yama_init_sysctl(void) { } #endif /* CONFIG_SYSCTL */ -void __init yama_add_hooks(void) +static int __init yama_init(void) { pr_info("Yama: becoming mindful.\n"); security_add_hooks(yama_hooks, ARRAY_SIZE(yama_hooks), "yama"); yama_init_sysctl(); + return 0; } + +DEFINE_LSM(yama) + .init = yama_init, +END_LSM; -- 2.17.1