Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp725857imm; Mon, 1 Oct 2018 18:05:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV60zgWvzz9o8Puy/S6vVp0AmCDFFMdUT8L++vmwZU6qnZK3xrP+ihv72KELQUB2tqQZWLYc8 X-Received: by 2002:a63:c508:: with SMTP id f8-v6mr12606084pgd.412.1538442337180; Mon, 01 Oct 2018 18:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538442337; cv=none; d=google.com; s=arc-20160816; b=aoz2NKcNlwr/nke5WCV4YUJ0ftbPDh7d4wto6Iy2VQoUMvC4uoUIpdAgnWtH9Qi8mL QCJelwWAlYqnbUxRFS4dwr0FI2/3COgdGtHfbMwRlmh8YbcFhqZaxLK4QWTJAN76NwUm fg2hQTyPJUF8urr6bg9kFkcl+riOsU8pwdrO8TfGu5YhQCCfMDGi9M6uty+BnamqNY0a usVodqD5BD2qyxufmIM8kBFyfyYzNc9tsSTF/M5zz4WInYxdNhs3YzNlCJQCw4Kmxn8l aB1TIIphTXVbRqUs0iq1x8uWXK9tcEdyy/Fry9RiTlcDEW5eyFNGqlfJ149OVA1sV2OL 6VkQ== 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=0qW1uF7m4L1ZO2KeQqVjIZsOMVYw9XJu7Iz5ldDGsTM=; b=W0/P0e/q3ixFR94oEp36hkVkKJ8pUKu4Wbu4btehyepne8lGPK/cFI0uHo9mLMveTE Yb2evg3LRp3RiaE+v+EFOy8qaDzI+aUhwscWVVFI7nYwfXBfXJp8PKKC3nL5L+dnCGXY VskuIchuOqlGOmR6yN3V78zQObMO2aWxJVYmZdl4sSIpwG1iGpFt0Ogtlea7VGtVWhcC /mfK0vtHGG2lUOoglskqnsOfR3nWIyGZ33kXpClXEwWjswuZ8X2FgUCoqle07E3MsG6j 1LiGwQxbJkxV/W1xRjy2XDrJ4Wgzus7TVu+bw+/9PmxFrplQcnFwc3GXbHSwJyUAWae4 z2UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NDhrsbxu; 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 136-v6si12601941pfw.278.2018.10.01.18.05.22; Mon, 01 Oct 2018 18:05:37 -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=NDhrsbxu; 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 S1727251AbeJBHpb (ORCPT + 99 others); Tue, 2 Oct 2018 03:45:31 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:43657 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726898AbeJBHpE (ORCPT ); Tue, 2 Oct 2018 03:45:04 -0400 Received: by mail-io1-f68.google.com with SMTP id y10-v6so267927ioa.10 for ; Mon, 01 Oct 2018 18:04:33 -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=0qW1uF7m4L1ZO2KeQqVjIZsOMVYw9XJu7Iz5ldDGsTM=; b=NDhrsbxuJpH8jCuXv4vA++uSz8lSj1sQmARm/JggoSeY5rzd+87LpdFJG6YVNE5JTC IuuqsE44RAfi7t/wqc2uh4MNhih7NpbPqGZRmhwOAB5T0RyMtBgOU7ui0H709C+WsAON wo4xmL7lr8nSw/gkCJpns1qLaabNLquiH0EM0= 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=0qW1uF7m4L1ZO2KeQqVjIZsOMVYw9XJu7Iz5ldDGsTM=; b=lzEzAgKXYH0zW3ZYS2L70HYmTHoIQV9s95VY3IoUMFpcUhEvthgqgYIDXCjc2J8vx5 Z3nhit4n4tQjJx0XvLir/I+kgAttjVrUWQ2fj7Ucm07k1gl8FTH1JUvZU4nMW4hmgSR+ S1cQCpKJbj2ZjQmlAmMhBGPG4BAEg/+pdXgn8B/vOh6qxYN6lH4wlxt+JPQI87TmDH/x fFzEwPF6HYC/2rsGAIyHvTkyxtsiW6lRKAs92Lxr3tIwcof7yRKcZ1ApH2LvM11r9ETV A/VXykHjHyfKJC7mpIaLzVGaEdBHFA344SaqVipqetve9+BJRmjc9VX4g+EyfFiZOc1I OYWg== X-Gm-Message-State: ABuFfojG1YNwdSqDhPuMNf4zsl/DEi2YS4Ky3GOs6VgtDr9b0D4ZEzTM SKSHvyu5Pyfa2epEayeAbkN/Fg== X-Received: by 2002:a17:902:b212:: with SMTP id t18-v6mr14398304plr.136.1538442273074; Mon, 01 Oct 2018 18:04:33 -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 p3-v6sm19540885pfo.130.2018.10.01.18.04.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 18:04:29 -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 v4 20/32] LSM: Refactor "security=" in terms of enable/disable Date: Mon, 1 Oct 2018 17:54:53 -0700 Message-Id: <20181002005505.6112-21-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002005505.6112-1-keescook@chromium.org> References: <20181002005505.6112-1-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For what are marked as the Legacy Major LSMs, make them effectively exclusive when selected on the "security=" boot parameter, to handle the future case of when a previously major LSMs become non-exclusive (e.g. when TOMOYO starts blob-sharing). Signed-off-by: Kees Cook Reviewed-by: Casey Schaufler --- security/security.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/security/security.c b/security/security.c index 455ba2767965..d7132c181ea6 100644 --- a/security/security.c +++ b/security/security.c @@ -103,14 +103,6 @@ static bool __init lsm_allowed(struct lsm_info *lsm) if (!is_enabled(lsm)) return false; - /* Skip major-specific checks if not a major LSM. */ - if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) == 0) - return true; - - /* Disabled if this LSM isn't the chosen one. */ - if (strcmp(lsm->name, chosen_major_lsm) != 0) - return false; - return true; } @@ -188,8 +180,24 @@ static void __init prepare_lsm_enable(void) parse_lsm_enable(chosen_lsm_enable, set_enabled, true); parse_lsm_enable(chosen_lsm_disable, set_enabled, false); + /* Process "security=", if given. */ if (!chosen_major_lsm) chosen_major_lsm = CONFIG_DEFAULT_SECURITY; + if (chosen_major_lsm) { + struct lsm_info *lsm; + + /* + * To match the original "security=" behavior, this + * explicitly does NOT fallback to another Legacy Major + * if the selected one was separately disabled: disable + * all non-matching Legacy Major LSMs. + */ + for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { + if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) && + strcmp(lsm->name, chosen_major_lsm) != 0) + set_enabled(lsm, false); + } + } } /** -- 2.17.1