From patchwork Fri Nov 1 08:58:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Lee X-Patchwork-Id: 2006083 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=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (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 4Xhm3m0Syrz1xyD for ; Mon, 4 Nov 2024 20:13:39 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1t7t9N-0002Aa-J5; Mon, 04 Nov 2024 09:13:29 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1t6nUV-0006yZ-6w for kernel-team@lists.ubuntu.com; Fri, 01 Nov 2024 08:58:47 +0000 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (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 13B853F31D for ; Fri, 1 Nov 2024 08:58:47 +0000 (UTC) Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5cbadbef8edso1200080a12.3 for ; Fri, 01 Nov 2024 01:58:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730451526; x=1731056326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PIrmWEHzlqqF1fq/PqUpK1OujbRnKcQNeXOp51L9RGc=; b=BdG6fFjsHUEI36KKpvuHISPVQd7lHngsz24ZnHggjK11CS4k0A3xYy65+T8j6NDNxg jTp3oQBCe89mccwRqRmk1e/tamqor1bdsvEcwdpQ091VVZ0xS87+Va3F4qWwxrxqip1T Z1MTv31HzAKtrHqDMynQzdYNCX42PxmybdyqH4r04N2jFxHOOoi4St2xk4wy143aRyep oGmG5JQOeB8MJghntvtwdxPFwSVck7ircjn0SnBiUkiuaPlenjvjv2bwlMOcxl+XuoAc /kBuqb5gU2c5FOzEWDM7op0aZoR2e8ee+JHozG3HwgKcRowBuYJvBy6nYzc7PtjmtHAZ fnVA== X-Gm-Message-State: AOJu0Yx8aaNPhNRaT+Dl+VYkQm/p53dkOBJSex1ziRk/pHa8c8SmYpH5 r6k46U2iKGgR1gkbqtyzhSjFwEdJubDeAXeUq5Ta4YqylL7ecgZqK4g77F7IDlJq5238dy1JD0M jk3S06kcBSP3JAJ87S+nZZvI2xuEC913DsoNfiNWi6lV+/FTcfhhQvlX2p2wMUwKQenYDEzkMru jkQXTVrTowJaqh X-Received: by 2002:a05:6402:34d1:b0:5c9:6ae4:332e with SMTP id 4fb4d7f45d1cf-5cea967a284mr4927213a12.8.1730451526572; Fri, 01 Nov 2024 01:58:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2ARPxa0A9af4sSBkmqQWVU+sXcujymgY5NtNs2hYN6mXLcN0CAQIpFusFjiYTBP0YaA4yvQ== X-Received: by 2002:a05:6402:34d1:b0:5c9:6ae4:332e with SMTP id 4fb4d7f45d1cf-5cea967a284mr4927201a12.8.1730451526161; Fri, 01 Nov 2024 01:58:46 -0700 (PDT) Received: from ryan-lee-laptop-13-amd.CtrlMice (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ceac7c8d58sm1347786a12.73.2024.11.01.01.58.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 01:58:45 -0700 (PDT) From: Ryan Lee To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH 1/2] UBUNTU: SAUCE: apparmor4.0.0 [94/99]: apparmor: allocate xmatch for nullpdf inside aa_alloc_null Date: Fri, 1 Nov 2024 09:58:41 +0100 Message-ID: <20241101085842.453201-2-ryan.lee@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101085842.453201-1-ryan.lee@canonical.com> References: <20241101085842.453201-1-ryan.lee@canonical.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 04 Nov 2024 09:13:28 +0000 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/2086210 attach->xmatch was not set when allocating a null profile, which is used in complain mode to allocate a learning profile. This was causing downstream failures in find_attach, which expected a valid xmatch but did not find one under a certain sequence of profile transitions in complain mode. This patch ensures the xmatch is set up properly for null profiles. Signed-off-by: Ryan Lee Signed-off-by: John Johansen Signed-off-by: Timo Aaltonen (cherry picked from commit 2de989ae726b14b6236fdb848563d607e12287b8) Signed-off-by: Ryan Lee --- security/apparmor/policy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c index f503dcd3ac74..638b0d6753ef 100644 --- a/security/apparmor/policy.c +++ b/security/apparmor/policy.c @@ -659,6 +659,7 @@ struct aa_profile *aa_alloc_null(struct aa_profile *parent, const char *name, /* TODO: ideally we should inherit abi from parent */ profile->label.flags |= FLAG_NULL; + profile->attach.xmatch = aa_get_pdb(nullpdb); rules = list_first_entry(&profile->rules, typeof(*rules), list); rules->file = aa_get_pdb(nullpdb); rules->policy = aa_get_pdb(nullpdb); From patchwork Fri Nov 1 08:58:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Lee X-Patchwork-Id: 2006085 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=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (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 4Xhm3r5XqPz1xxN for ; Mon, 4 Nov 2024 20:13:44 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1t7t9S-0002CA-RC; Mon, 04 Nov 2024 09:13:34 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1t6nUV-0006yh-Ik for kernel-team@lists.ubuntu.com; Fri, 01 Nov 2024 08:58:47 +0000 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (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 6BCF040F41 for ; Fri, 1 Nov 2024 08:58:47 +0000 (UTC) Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5c938ae4152so2927406a12.1 for ; Fri, 01 Nov 2024 01:58:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730451527; x=1731056327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YPM9aKwdOHZgF8jYgzDflY/qzrLWaSH5Jx2zvWMoMhk=; b=XoljEhmfLBJZOyNOcDZYf/eAj82WfJklIWIbZMsq/jV2j0M23ihrX/6xu6nskcSfd5 5MZsQ5dX+No4HYH/wQNplvmnP0RnlduStK0MhVf7axAhPlZKExqPG9STFGFKGVSwt71y EX9J3+36Z65Zk+A2u+JDq8YrD+qgV4ZpJnc4TTZnVDGiDaJyS7zFsb3O9lOJrz63B7H8 oY1nPOipBcs2c+Hfxi6fvSpm21WCWil/AlLl+s/GXDOuHNM5nqrl9sKnaJnCOiEsu1QJ gpkPB+Bw4ZeKoPLTvqD+7lVjTROtYg3X4jjIQG+GSiOQ9dxWzGNZ5gEe4SVrDUnoMuUm oi8Q== X-Gm-Message-State: AOJu0Yw/9eS3D4wueEJ/GdNOhcx0PXMsJZ4ylbxY/wCzIJDiHOf2KYli ip+wjVQ30L4FOfOa138q/3SY47iMN9YyD1Z9+2fLBB18beXx+gPA7PH4Bj4k2UbapH7pv/bE0Bp 6DKfYecBF6ROP3XOqJfRW1dhuKCDOcCXAG7i52ToD+NeVmA79cbiV+UJ8z5apt3Q4GpWafcXs9L MGiqSJ6dOvs5uI X-Received: by 2002:a05:6402:1ec8:b0:5c9:813a:b1c1 with SMTP id 4fb4d7f45d1cf-5ceb8caf814mr3005752a12.1.1730451526946; Fri, 01 Nov 2024 01:58:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF188r3/tJ7oZv0Sc3GTcOpiQwkSKvGSLnNHrV4kjPGbdB3UvhWgP3KfTXxppb53S68BBEKUg== X-Received: by 2002:a05:6402:1ec8:b0:5c9:813a:b1c1 with SMTP id 4fb4d7f45d1cf-5ceb8caf814mr3005738a12.1.1730451526561; Fri, 01 Nov 2024 01:58:46 -0700 (PDT) Received: from ryan-lee-laptop-13-amd.CtrlMice (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ceac7c8d58sm1347786a12.73.2024.11.01.01.58.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 01:58:46 -0700 (PDT) From: Ryan Lee To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH 2/2] UBUNTU: SAUCE: apparmor4.0.0 [95/99]: apparmor: properly handle cx/px lookup failure for complain Date: Fri, 1 Nov 2024 09:58:42 +0100 Message-ID: <20241101085842.453201-3-ryan.lee@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101085842.453201-1-ryan.lee@canonical.com> References: <20241101085842.453201-1-ryan.lee@canonical.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 04 Nov 2024 09:13:33 +0000 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/2086210 mode profiles When a cx/px lookup fails, apparmor would deny execution of the binary even in complain mode (where it would audit as allowing execution while actually denying it). Instead, in complain mode, create a new learning profile, just as would have been done if the cx/px line wasn't there. Signed-off-by: Ryan Lee Signed-off-by: John Johansen Signed-off-by: Timo Aaltonen (cherry picked from commit 62bd5d5f21495c300939475bc491af545755bf10) Signed-off-by: Ryan Lee --- security/apparmor/domain.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c index dd457eaedab8..b2937dce4b8f 100644 --- a/security/apparmor/domain.c +++ b/security/apparmor/domain.c @@ -686,12 +686,17 @@ static struct aa_label *profile_transition(const struct cred *subj_cred, /* hack ix fallback - improve how this is detected */ goto audit; } else if (!new) { - error = -EACCES; info = "profile transition not found"; - /* remove MAY_EXEC to audit as failure */ + /* remove MAY_EXEC to audit as failure or complaint */ perms.allow &= ~MAY_EXEC; + if (COMPLAIN_MODE(profile)) { + /* create null profile instead of failing */ + goto create_learning_profile; + } + error = -EACCES; } } else if (COMPLAIN_MODE(profile)) { +create_learning_profile: /* no exec permission - learning mode */ struct aa_profile *new_profile = NULL;