From patchwork Mon Aug 29 05:54:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ruffell X-Patchwork-Id: 1671271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=j3J50YYO; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MGKQk5Dglz1ygm for ; Mon, 29 Aug 2022 15:54:53 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oSXjK-0006Q1-6G; Mon, 29 Aug 2022 05:54:38 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oSXjG-0006Pf-W4 for kernel-team@lists.ubuntu.com; Mon, 29 Aug 2022 05:54:34 +0000 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id C1A9A3F0C8 for ; Mon, 29 Aug 2022 05:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1661752474; bh=/TyIFLTiCgt2grtemJDex6ctSfir4A/c8H3Qo7CTNIM=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j3J50YYOON7xi4J+hQjeuMK7oTN13ZHpv7StuIbxVHwHkG/4uk/jpzukWtXSke4My f2SymEkZdBVtWUhVpAfJ3K1FYsXxH330gyrYYl79Vqf6eXJScNH6xrespw74ZKapZC hd8VkKWQ1PNSFteRx4SE2qsybWP91ktODOovwqMS3qBrNFc9tA3sj2dOsfX+Zs3DHn Pr3bP28fE7rYmssIUTACAkJaCvd1L3N9n5QsgyI7mrvTpt+S00/InPZep0TvmV5/Kq xYR1+SD3ne77vx77sUo/EW/AGMJgHS+5n5WncX6LeKbuVCPSmkFBFt1JZ8DYP0EB+z sZ1cZnWx3jJlw== Received: by mail-pg1-f200.google.com with SMTP id h5-20020a636c05000000b00429fa12cb65so3644388pgc.21 for ; Sun, 28 Aug 2022 22:54:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=/TyIFLTiCgt2grtemJDex6ctSfir4A/c8H3Qo7CTNIM=; b=MaZ9LyY08MRfroTDyCLhXgHenPbXh3czR2FTsFhR7ZuXlBXYXiQd/zZF2K529TP9Zb ViU5TRuh6D6VOWICUSfzK0dvWXPPnVPC6ZKgruTv89XSDm1kRogJOcRBadfhyTLXHk/B zIsgerINJmjUUcovPGTzJVIM+vlWef6N6gnsWiG6mGdxvxboy8uHm1u7az/Txgf42HwG ewKDF4j+iDv+CpmjANwMn3mK+c8LYZdXhNlG18suufjNkgJ/f5p3TxBGTDYT2J7XSiH/ +M4M0Tx7qSbsWslnb3VPYkZlLq1UOMzBV52lWmQodPtrdnKSMBmtXZXcTObQJDxugV44 jRWQ== X-Gm-Message-State: ACgBeo0D1QbsCSQJCgQW3ABwRHxoDjlNRDSvDK8+y/giQcr1TmuvxI4Q th5rqKacGPIVdJG83Z8WWdlWoyHcWPQHSm8jS83aczuZjShyUhv4I8HWi+HoPh0UebZrGPrAdme 8igy14Dcrbie6cS92P7ke3NBc5+HtY16PicerKge1CQ== X-Received: by 2002:a17:902:cec1:b0:172:e677:553b with SMTP id d1-20020a170902cec100b00172e677553bmr15063963plg.99.1661752473449; Sun, 28 Aug 2022 22:54:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Gl+VVI/oAwk2SvR6/fs7KOV+jllbz8q2sF3Z21iF1pA3dSN654/hT+pp3AgSp2uKaJNhy/Q== X-Received: by 2002:a17:902:cec1:b0:172:e677:553b with SMTP id d1-20020a170902cec100b00172e677553bmr15063946plg.99.1661752473110; Sun, 28 Aug 2022 22:54:33 -0700 (PDT) Received: from desktop.. (125-239-70-54-fibre.sparkbb.co.nz. [125.239.70.54]) by smtp.gmail.com with ESMTPSA id l9-20020a170903244900b0016dbdf7b97bsm6452610pls.266.2022.08.28.22.54.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 22:54:32 -0700 (PDT) From: Matthew Ruffell To: kernel-team@lists.ubuntu.com Subject: [SRU][J][K][Unstable][PATCH 1/1] UBUNTU: SAUCE: LSM: Change Landlock from LSMBLOB_NEEDED to LSMBLOB_NOT_NEEDED Date: Mon, 29 Aug 2022 17:54:24 +1200 Message-Id: <20220829055424.19055-2-matthew.ruffell@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829055424.19055-1-matthew.ruffell@canonical.com> References: <20220829055424.19055-1-matthew.ruffell@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1987998 The Landlock LSM does not register any hooks which use struct lsmblob, and does not require a slot in the secid array of struct lsmblob. Change LSMBLOB_NEEDED to LSMBLOB_NOT_NEEDED. This is required to fix a panic on boot where too many LSMs can be configured, since while we currently mark Landlock as LSMBLOB_NEEDED, we do not actually make LSMBLOB_ENTRIES large enough to fit it, and we panic when more than 2 LSMs are configured, like: GRUB_CMDLINE_LINUX_DEFAULT="lsm=landlock,bpf,apparmor" LSM: Security Framework initializing landlock: Up and running. LSM support for eBPF active Kernel panic - not syncing: security_add_hooks Too many LSMs registered. CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.0-46-generic #49-Ubuntu Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 Call Trace: show_stack+0x52/0x5c dump_stack_lvl+0x4a/0x63 dump_stack+0x10/0x16 panic+0x149/0x321 security_add_hooks+0x45/0x13a apparmor_init+0x189/0x1ef initialize_lsm+0x54/0x74 ordered_lsm_init+0x379/0x392 security_init+0x40/0x49 start_kernel+0x466/0x4dc x86_64_start_reservations+0x24/0x2a x86_64_start_kernel+0xe4/0xef secondary_startup_64_no_verify+0xc2/0xcb ---[ end Kernel panic - not syncing: security_add_hooks Too many LSMs registered. ]--- Also refactor the Landlock support by going to just one struct lsm_id, and extern it from setup.h, following upstream development. Fixes: f17b27a2790e ("UBUNTU: SAUCE: LSM: Create and manage the lsmblob data structure.") ubuntu-jammy Signed-off-by: Matthew Ruffell --- security/landlock/cred.c | 5 ----- security/landlock/fs.c | 5 ----- security/landlock/ptrace.c | 5 ----- security/landlock/setup.c | 5 +++++ security/landlock/setup.h | 1 + 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/security/landlock/cred.c b/security/landlock/cred.c index e3bd04cc7177..2eb1d65f10d6 100644 --- a/security/landlock/cred.c +++ b/security/landlock/cred.c @@ -14,11 +14,6 @@ #include "ruleset.h" #include "setup.h" -static struct lsm_id landlock_lsmid __lsm_ro_after_init = { - .lsm = "landlock", - .slot = LSMBLOB_NEEDED -}; - static int hook_cred_prepare(struct cred *const new, const struct cred *const old, const gfp_t gfp) { diff --git a/security/landlock/fs.c b/security/landlock/fs.c index b81db9d184bd..d8842a2ac58a 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -37,11 +37,6 @@ #include "ruleset.h" #include "setup.h" -static struct lsm_id landlock_lsmid __lsm_ro_after_init = { - .lsm = "landlock", - .slot = LSMBLOB_NEEDED -}; - /* Underlying object management */ static void release_inode(struct landlock_object *const object) diff --git a/security/landlock/ptrace.c b/security/landlock/ptrace.c index 0f3bb8ea12db..eab35808f395 100644 --- a/security/landlock/ptrace.c +++ b/security/landlock/ptrace.c @@ -20,11 +20,6 @@ #include "ruleset.h" #include "setup.h" -static struct lsm_id landlock_lsmid __lsm_ro_after_init = { - .lsm = "landlock", - .slot = LSMBLOB_NEEDED -}; - /** * domain_scope_le - Checks domain ordering for scoped ptrace * diff --git a/security/landlock/setup.c b/security/landlock/setup.c index f8e8e980454c..759e00b9436c 100644 --- a/security/landlock/setup.c +++ b/security/landlock/setup.c @@ -23,6 +23,11 @@ struct lsm_blob_sizes landlock_blob_sizes __lsm_ro_after_init = { .lbs_superblock = sizeof(struct landlock_superblock_security), }; +struct lsm_id landlock_lsmid __lsm_ro_after_init = { + .lsm = LANDLOCK_NAME, + .slot = LSMBLOB_NOT_NEEDED, +}; + static int __init landlock_init(void) { landlock_add_cred_hooks(); diff --git a/security/landlock/setup.h b/security/landlock/setup.h index 1daffab1ab4b..38bce5b172dc 100644 --- a/security/landlock/setup.h +++ b/security/landlock/setup.h @@ -14,5 +14,6 @@ extern bool landlock_initialized; extern struct lsm_blob_sizes landlock_blob_sizes; +extern struct lsm_id landlock_lsmid; #endif /* _SECURITY_LANDLOCK_SETUP_H */