Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp128732oof; Mon, 24 Sep 2018 17:28:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV60BRLBl6qA1JZrJiFU38wUXut6ePFosBsTS2B2ZInteeIe2+0dh/uLzTouELCCKacKXbf+b X-Received: by 2002:a62:5882:: with SMTP id m124-v6mr978292pfb.249.1537835304059; Mon, 24 Sep 2018 17:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537835304; cv=none; d=google.com; s=arc-20160816; b=azvHQv4Q/w7lNLcJKQmr0Y78ondXc2wIO5LXo1GkPBpCa5BQE1FK42cTuY8lim/o7B B8tPdQVf2044p45zj2IXr4c8FlxEQ/qS5aY+k+XDLU/qbKI4XFuEH+lobyAZLuM2q1b8 gTWBYNAEFBeqmISj8GxRrlCieLk+f4HdLlVe6Bl6cczLCDPK8XYec+3jFUW0yP/FCVFt qlUGVoOJ1pIfYxDiSPpKjyzsMwGOip5X8uRyNTkbdiEmLyNFC2N3RjWZj4wgNH8MOXGq 7YCpPvhNAJ9EzrNa8YpHb79sidaWbsitfDJhwCxcu09GQXuaHpPxYoWSw5uzGqLsVpvN rilg== 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=dcnxUGdM4FO17eHYuUfeuK9JPR89ogJMNeQRUezwAjU=; b=s6suCcVHiVjtJ6CvHNTVM696PmgG/suRFSYp47iy3MW9EAslgmYVEWeW8q42qnu9ER SFy9TWBwFE6vU8jjYb4dkA2aS0exWIbYF9RmchrBru4FWOR75BXbkZBEkiBqz3a44HHm 4on7UjzdtzzPIdPxnAZvwj7BnwWm1+fJcd+rPaPy1jGOGE+WA9hz7f2ydrDQfsu/flts VGW6RgOfv/T0QiQ7B6Sw7ntZbYpnZEJvu1lHZAYrTH8C+V1nxsc8ylRvBggqizPbr8Pb DIcWTPUgwIe0ruYmJQLm+Y+MHzv3SJX45GuXzGUSy8nTzp6sa94a+me4P2KubYlsmPHp TlpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="AQGOY/Zd"; 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 60-v6si767013pla.487.2018.09.24.17.28.07; Mon, 24 Sep 2018 17:28:24 -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="AQGOY/Zd"; 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 S1728744AbeIYGas (ORCPT + 99 others); Tue, 25 Sep 2018 02:30:48 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44626 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727482AbeIYGaG (ORCPT ); Tue, 25 Sep 2018 02:30:06 -0400 Received: by mail-pf1-f196.google.com with SMTP id k21-v6so9913976pff.11 for ; Mon, 24 Sep 2018 17:25:19 -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=dcnxUGdM4FO17eHYuUfeuK9JPR89ogJMNeQRUezwAjU=; b=AQGOY/Zdh0wpfhlnTaQch+gsKeEk2rOe2ektyYESqmESf62tM1EDmSsoYn5JLLhMdK 9JTT3o7hxp+V3R+MkaEoprJW2RdJp6xsOqZiUW+kkUTc+7yXMlxIUNZ99LlmGuyRWG1I BZNXLBlfyMJjcLD/IL+KADS6U0NNut/sGwkw8= 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=dcnxUGdM4FO17eHYuUfeuK9JPR89ogJMNeQRUezwAjU=; b=dhSZ/NcLWu7ir6nCABQhyOWeHzpjjQcnpdSrKgJiKHZELeTi3i4JZdFy1ZfsLEk/MW 1vkSc/57XYSpVkMYHKomLJtAzVmnLYjhU0knvlmE6whPQVNlb99dPEzdXveTO+2ODdJG 4AJ7YpuElEsfeZrQZQZ44KzKyINSY9F8XBm27lUEDDUU4tFiqzVMNFSN3kvZKLskTBMY K6kwlssMYjAVbi9ks5soYDA70NWLafRdVPbsN8VbVQc7E9TBwj2JdAY7YYxfg3uHwAF5 o9XVM+pPeJmMSpfK3Gi/ID1IWYiA8HvWPcvjMwq7d3qgF7IOE0irRm79Ucxm12P0q9vz 3Mgw== X-Gm-Message-State: ABuFfoggW/aSLc+U94uc1vq2nOuvvidMQSSxKu4OF1MauhFBajdn7vOf il5n0mgvHgiQLe3H2dKR+gbp7w== X-Received: by 2002:a63:e918:: with SMTP id i24-v6mr992063pgh.64.1537835119019; Mon, 24 Sep 2018 17:25:19 -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 g15-v6sm562058pfg.98.2018.09.24.17.25.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Sep 2018 17:25:16 -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 v3 19/29] LSM: Prepare for reorganizing "security=" logic Date: Mon, 24 Sep 2018 17:18:22 -0700 Message-Id: <20180925001832.18322-20-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180925001832.18322-1-keescook@chromium.org> References: <20180925001832.18322-1-keescook@chromium.org> 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 --- security/security.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/security/security.c b/security/security.c index 456a3f73bc36..e325fcc41f00 100644 --- a/security/security.c +++ b/security/security.c @@ -34,18 +34,14 @@ #define MAX_LSM_EVM_XATTR 2 -/* Maximum number of letters for an LSM name string */ -#define SECURITY_NAME_MAX 10 - struct security_hook_heads security_hook_heads __lsm_ro_after_init; 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_enable; static __initdata const char *chosen_lsm_disable; +static __initdata const char *chosen_major_lsm; static __initconst const char * const builtin_lsm_enable = CONFIG_LSM_ENABLE; @@ -112,7 +108,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; @@ -191,6 +187,9 @@ static void __init prepare_lsm_enable(void) /* Process "lsm.enable=" and "lsm.disable=", if given. */ parse_lsm_enable(chosen_lsm_enable, set_enabled, true); parse_lsm_enable(chosen_lsm_disable, set_enabled, false); + + if (!chosen_major_lsm) + chosen_major_lsm = CONFIG_DEFAULT_SECURITY; } /** @@ -231,12 +230,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); /* Enable LSM order debugging. */ static int __init enable_debug(char *str) -- 2.17.1