Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2218365imm; Thu, 20 Sep 2018 09:30:15 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY5cb4COdmiAV5zDSK5vhPPkk9if5W7cgcBFgPK8xPnrZ8sVy5A6z8Z5dNeNvHNvaTXUJEm X-Received: by 2002:a17:902:ba95:: with SMTP id k21-v6mr115370pls.38.1537461015543; Thu, 20 Sep 2018 09:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537461015; cv=none; d=google.com; s=arc-20160816; b=N8nJFOm+nrkZB71nzbdwBgGj4sskQSPbo+pH6sAAD5ihNZXLlmQShnTLEOPAaPbP7+ nIum/ZgMuxYI0hpq+OKeSq+suatPdD4Xujyd4i73bToC496oCjKz0senB9y6nRPFh1yi DZ5TI+FK4/RUEN6hK5t5n51QWExrugRoAxQR4cwZa+XpFf+v7fUcOTpXWQyugaoNoI6M ca3J+fRUO1WyGkQ3XE8mivYoUf2WW9QkS0rMnVjO1pyIs1KXwKy/Tztw/cGeFt5qsbPG bFt4Nt8uxJ6CmavtbgzngGwWq0OYtpU4PBIAGrl4l0mRU/Zx5xRWRmVhUjAH1ZyvyT1w in+g== 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=AcW3F/O+fl3XT2ZLqa+o+qWhOJ9ucCkwfwLeB76MZXo=; b=zMIkljvyoT/l1QIZ54JlWuOpgsQ90si0hr4JvPNxAGJEOHsG/x57GEJjHMi2dG+XeQ EwSX26B/eCjt5rlGTcdEQ6mFT8yYBKXmGgQ+rIe9Q4CIlwo8wwavzmmyTFbY1z0oHx0/ 8mPDeft8WenrbFD+zKAhpONF9afWE2ltro9GqtwPZkWwTDK1f+eUj+mUUUVOdFrvIhMO dWuSjz2jxm0DeE3X+Nu1ZDMJw64Fw0EXx21Iuc3jQVzTqOuNJOqr5lyjq5rZtfx3yR4b dLIghl9Ax4NmDQ47Be6tNPCDJeexwyojAquop3hVG2GPHL3w6vlCCOkGOHWeWgR8lOu8 SHig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JeXHPMHH; 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 n14-v6si25253351pgm.11.2018.09.20.09.29.58; Thu, 20 Sep 2018 09:30:15 -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=JeXHPMHH; 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 S2387986AbeITWOB (ORCPT + 99 others); Thu, 20 Sep 2018 18:14:01 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41589 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387948AbeITWOA (ORCPT ); Thu, 20 Sep 2018 18:14:00 -0400 Received: by mail-pf1-f196.google.com with SMTP id h79-v6so4617350pfk.8 for ; Thu, 20 Sep 2018 09:29:43 -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=AcW3F/O+fl3XT2ZLqa+o+qWhOJ9ucCkwfwLeB76MZXo=; b=JeXHPMHHyCZQH9VNVaKgHvagSKYLdbtUuEpEDnIu9WRq5VXUF6pIMIe1YC2FAQfcTL H4AK2mucZZCXLHunN5rEIvVtDZk7RuEFq8nc1Gej5ylMVwlVuCjC7TnXaKo5EJnIyVgW VrYjM81q5d5lamF2qVadA9rR6IUB780UKq86M= 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=AcW3F/O+fl3XT2ZLqa+o+qWhOJ9ucCkwfwLeB76MZXo=; b=W/TOWYOFw/JyM1CPqcayV09YC9xt8GHNnnd7JOi14OeLrEdABw0iywGryWvZfcMQd/ xjTe1LHmGI6vnkk2iMls2+xZnC8c5V3Vily7GRdxPcdMPT6uW+X2Q634tg381v6BAsKI 1nkloIR7OxxVWVG0dqxw1aNSw/Lb7AAa4gHNr/6ZQReIt3X+n6F1lePkBvd+rsMZhkzv 5rk9D5vKOU67v8ALChevKzZ19vOBrnSUDu4zRRlpNe9PgT5xVO/olbUMKQ41cF/naX7q NJaIkXQxDVbcod7OyflF/+bm7VOkzzewk7wEMDyGk1i7Tx0+5EBdtnKz0xQmSt4LU72x Qp7w== X-Gm-Message-State: APzg51BpTiQVmjR8JPdcicWHqzInIjKaMzuPfJszcfy53aqSFm3Ms1gJ jRNLL1mNv8emlv4IMrcsCmDBRA== X-Received: by 2002:a62:1157:: with SMTP id z84-v6mr42279294pfi.66.1537460982880; Thu, 20 Sep 2018 09:29:42 -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 s70-v6sm7430271pgc.16.2018.09.20.09.29.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 09:29:39 -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 16/26] LSM: Prepare for reorganizing "security=" logic Date: Thu, 20 Sep 2018 09:23:28 -0700 Message-Id: <20180920162338.21060-17-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 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 72d1ef2fc4cc..5cacbcefbc32 100644 --- a/security/security.c +++ b/security/security.c @@ -34,16 +34,12 @@ #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_major_lsm; static bool debug __initdata; #define init_debug(...) \ @@ -90,7 +86,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; @@ -154,6 +150,9 @@ int __init security_init(void) i++) INIT_HLIST_HEAD(&list[i]); + if (!chosen_major_lsm) + chosen_major_lsm = CONFIG_DEFAULT_SECURITY; + /* * Load minor LSMs, with the capability module always first. */ @@ -173,12 +172,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