Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp598456imu; Mon, 26 Nov 2018 15:34:59 -0800 (PST) X-Google-Smtp-Source: AJdET5fLR5cvoyEYlgtaqjSOdk5ANoCsP8ET/p1CO16nQh+PHrsuB+pJOpOHUBL9wLBLV37kegBR X-Received: by 2002:a62:7c47:: with SMTP id x68mr29890838pfc.209.1543275299384; Mon, 26 Nov 2018 15:34:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543275299; cv=none; d=google.com; s=arc-20160816; b=jbuDlL2xvgZXwINHtTycuBDrrVSvqjvDjTPWu9ZQuFtTV0ydIjDz9VMSpN7x2SXUI+ CDBvCQX/VKZ3QULQ4lARAq4a9qrxNAmcy9UjGBmyKH3lBbTgVWpGqteu4krlzeE/CvWa GM2POmOkFmR8dwNP23FyBYHe1qmKbIskcV/6lYOYcZN7B64dDV5qNVSeiIZlrx2hS0rJ 37/PTsEeFnj4Pkh38/Xe4tnA0Hyw4Eac0j8Dory56Dy3IVPmpeeCvI7YNNzffzDLhvQI XncqRr1kQ7HMRkLl6q8rOtdJx80wl+BICptPxkZNCzEq3b37G04621k5vCob4pPHydQz 7yIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=ujgfotxrQ01hsR5Dk4QiWiX3I+MyR/d1upQJsg3YCs8=; b=U+uTwauncsU0CIXFftkH67N2VDx77QUV6H7z5/jbm3jCCMtF2tESIAFKU3qSnXP2uZ KZ/WnMHM78/hDXrsL7+TCsjzSDm6bQsCf+bXd8H2oj7iR2pKLe6erBBdZbxRO10dPDjS FKxUYRbmmbiy6SA6/K3Aa3kgvRqY8fTRwCfxN/8GsiUSo8NLQ6Xb8c/PrejTzOHDZHT0 tVBi4B9RWBdLZylqv/1cUG0sTgO0VzIKQmyq8lDYYD+s6GmxRAfG0vBgTVVE0iHE06R1 W6GF9wqt/uh80y/t1PXRRPCc2Gz5u2gvPYcCmKVVvS+e0YA/zwZ5X0xSJL+HdL1pkbzw fG1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=NSvzzqnH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si1821003pgs.8.2018.11.26.15.34.42; Mon, 26 Nov 2018 15:34:59 -0800 (PST) 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=@yahoo.com header.s=s2048 header.b=NSvzzqnH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727707AbeK0K3a (ORCPT + 99 others); Tue, 27 Nov 2018 05:29:30 -0500 Received: from sonic315-27.consmr.mail.ne1.yahoo.com ([66.163.190.153]:43057 "EHLO sonic315-27.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbeK0K33 (ORCPT ); Tue, 27 Nov 2018 05:29:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1543275221; bh=ujgfotxrQ01hsR5Dk4QiWiX3I+MyR/d1upQJsg3YCs8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=NSvzzqnH4M8ixMRthcT6nGUkN/uZMR4JJmYFNfmiYXPCFzI3QOF6IU8f3zKpvWxa8x4rxQhp7E88dSOfI2+EO8E3DJ05xLMq24IdYDNp+TGSUy3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uO410PL0eLlJ1YD5b4fXTCwNs5ZlYGF9hxubwgNLCuDuyM7F5s_b0iIOb_D9PA jjA_8lKlKG2uM37JlMB5iVS0YjXoCdgzmftTYfmG2JS7j6KbkQslsjaE3FYrEO3t041T7q_S4CUv 2ENsUABsYf7LQfE7oBXEehTAy0G.fqEHfawz4BZY1A.XT4YW0Zt9uMuP2W6NEHL7kp.FRWpHCuML IYfiA5etyCCNjQxfzK4H.rP5L6QZmg72_NLliwoLcX9YMd2iuJLCFzVu.aIC2k_X2yFT3KpW4wu7 rGHb0nSTDjsk9NJBB4Au20tQ0FugpK2XCY.d3gx.beJ4p Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.ne1.yahoo.com with HTTP; Mon, 26 Nov 2018 23:33:41 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.105]) ([67.169.65.224]) by smtp429.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID f7adb105e9d2d5472fff1733906b2c81; Mon, 26 Nov 2018 23:33:40 +0000 (UTC) Subject: [PATCH v5 09/38] LSM: Prepare for reorganizing "security=" logic To: James Morris , LSM , LKLM , SE Linux Cc: John Johansen , Kees Cook , Tetsuo Handa , Paul Moore , "linux-fsdevel@vger.kernel.org" , Stephen Smalley , Alexey Dobriyan , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , Salvatore Mesoraca References: <50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler-ca.com> From: Casey Schaufler Message-ID: <26e368e6-fe18-c408-e4a9-915e87a4adc9@schaufler-ca.com> Date: Mon, 26 Nov 2018 15:33:37 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler-ca.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This moves the string handling for "security=" boot parameter into a stored pointer instead of a string duplicate. This will allow easier handling of the string when switching logic to use the coming enable/disable infrastructure. Signed-off-by: Kees Cook Reviewed-by: Casey Schaufler Reviewed-by: John Johansen --- security/security.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/security/security.c b/security/security.c index ea760d625af6..f4a7b7d52d71 100644 --- a/security/security.c +++ b/security/security.c @@ -34,9 +34,6 @@ #define MAX_LSM_EVM_XATTR 2 -/* Maximum number of letters for an LSM name string */ -#define SECURITY_NAME_MAX 10 - /* How many LSMs were built into the kernel? */ #define LSM_COUNT (__end_lsm_info - __start_lsm_info) @@ -45,9 +42,8 @@ static ATOMIC_NOTIFIER_HEAD(lsm_notifier_chain); char *lsm_names; /* Boot-time LSM user choice */ -static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] = - CONFIG_DEFAULT_SECURITY; static __initdata const char *chosen_lsm_order; +static __initdata const char *chosen_major_lsm; static __initconst const char * const builtin_lsm_order = CONFIG_LSM; @@ -138,7 +134,7 @@ static bool __init lsm_allowed(struct lsm_info *lsm) return true; /* Disabled if this LSM isn't the chosen one. */ - if (strcmp(lsm->name, chosen_lsm) != 0) + if (strcmp(lsm->name, chosen_major_lsm) != 0) return false; return true; @@ -168,6 +164,9 @@ static void __init ordered_lsm_parse(const char *order, const char *origin) struct lsm_info *lsm; char *sep, *name, *next; + if (!chosen_major_lsm) + chosen_major_lsm = CONFIG_DEFAULT_SECURITY; + sep = kstrdup(order, GFP_KERNEL); next = sep; /* Walk the list, looking for matching LSMs. */ @@ -257,12 +256,12 @@ int __init security_init(void) } /* Save user chosen LSM */ -static int __init choose_lsm(char *str) +static int __init choose_major_lsm(char *str) { - strncpy(chosen_lsm, str, SECURITY_NAME_MAX); + chosen_major_lsm = str; return 1; } -__setup("security=", choose_lsm); +__setup("security=", choose_major_lsm); /* Explicitly choose LSM initialization order. */ static int __init choose_lsm_order(char *str) -- 2.14.5