From patchwork Fri Nov 1 11:05:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Lee X-Patchwork-Id: 2005086 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 4XfyhB1hmPz1xy1 for ; Fri, 1 Nov 2024 22:05:30 +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 1t6pSy-0007ks-LK; Fri, 01 Nov 2024 11:05:20 +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 1t6pSv-0007jy-PK for kernel-team@lists.ubuntu.com; Fri, 01 Nov 2024 11:05:17 +0000 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (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 87B1F3F1FC for ; Fri, 1 Nov 2024 11:05:17 +0000 (UTC) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5cd50bf580cso1381611a12.0 for ; Fri, 01 Nov 2024 04:05:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730459117; x=1731063917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PIrmWEHzlqqF1fq/PqUpK1OujbRnKcQNeXOp51L9RGc=; b=LAyY+eEcGx67dW1Zhw0aOfR9efFUcc0osnIXHxB9g66iSdjqLawUsIiBCPMFxo7CVy HMPH/dsL9UgnQ/yZUKCuDdeM2trayKKnqyV5gMUnoq3FP9iekcjG3+RiHaxy3cDT4CdI KW65BEUtfaSfjQtXcugnwzLEdlG8XyXeI0beCLLmrrXZMSzzGO+IzEgy09HBxkHJ3OtZ Fcw3Pq4d6ws/4ieWK/ITRk01NNttkT5V76DC7zbLOQsm6lXuO7fJNCp1qrBNanYYCW7p 8HuqBBowxXjCzbwmUKnWZ7lCvRBViq0jX5kKPZejp1Y5Sn+qS2ppnpE5FMhCCSyIvi3A afCw== X-Gm-Message-State: AOJu0Yx3ID0eJ4/gyTdFCekofhXTSCELRic4Ii0Rv+KGnvN1mjEym/Op uJx5F+cGjGfJHmrETpjLCSbSwg+OqruMrChbOd2iLdjroiVpXQIAC7Xn+Itqs55sZHLEjUqPVYH /v/oEkS41q9VIacskPL0zd1olegLFGaC/SqvPGAHyZJ35Wspqrcx4vYpANmkcR5GJhMcs9ahzDB M8ZRZurxZOI5Mj X-Received: by 2002:a05:6402:d0d:b0:5c9:39d8:58b3 with SMTP id 4fb4d7f45d1cf-5ceb935c4f2mr1863645a12.23.1730459117020; Fri, 01 Nov 2024 04:05:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbi98HhOhNzMQKr2E75RENOrf2BRL+xy9f3QVf0RwTJ88WdDgpE6zsj+BHOSUFtHRI03qicg== X-Received: by 2002:a05:6402:d0d:b0:5c9:39d8:58b3 with SMTP id 4fb4d7f45d1cf-5ceb935c4f2mr1863630a12.23.1730459116629; Fri, 01 Nov 2024 04:05:16 -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-5ceac7e9e65sm1404839a12.97.2024.11.01.04.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 04:05:16 -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 12:05:13 +0100 Message-ID: <20241101110514.523356-2-ryan.lee@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101110514.523356-1-ryan.lee@canonical.com> References: <20241101110514.523356-1-ryan.lee@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/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 11:05:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Lee X-Patchwork-Id: 2005087 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 4XfyhC1H2Nz1xxy for ; Fri, 1 Nov 2024 22:05:30 +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 1t6pSy-0007lG-Vd; Fri, 01 Nov 2024 11:05:20 +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 1t6pSx-0007k5-8c for kernel-team@lists.ubuntu.com; Fri, 01 Nov 2024 11:05:19 +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 307293F233 for ; Fri, 1 Nov 2024 11:05:18 +0000 (UTC) Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5c94a70a3f5so1250151a12.0 for ; Fri, 01 Nov 2024 04:05:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730459117; x=1731063917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YPM9aKwdOHZgF8jYgzDflY/qzrLWaSH5Jx2zvWMoMhk=; b=Pf9z/tPRgjugzH+2q0FCk0OrfhToGFoQDkV36gWdOz1ilKfmEJ94xg0fKHS+Gz9+uA yk7xxS8S1FwG6rnxfjCr/FjwprXzkUITWOyC1C2LiPBhoRj5Lyvb3563Wq0YFskvQNrW ffEnA3DvSpqBhW2U6+7LppTghgq30CvupxPFBYbJMk3SMoblcBEq84w3Drt9SctMxaWJ xkyvuK31fkTQhPTkw51XdoyJnXkL1pxBFl42MmEppjFBR0kOgPpbApoRzKq17fDQ/czd XgY8rHl2o3Knov81rDVA+uRZ5WnSf0YtF87VOmuZhpVf37aNhD7N1/YUJZaWFL715Vbw utsQ== X-Gm-Message-State: AOJu0Yxhx7uFZHSznQkt29rOENHiwBrZYGIaJGCVNWVZ5XjZf06tOJx6 nHoSP9ziCKgJXvfMNKfom4IBH7J1UQrtZ8BaFKEQDdMbEaPAzGugICip3DI2cE/E0JVspyzYfIz nOoL4MDg8obG4YeSfPs+82rbq+o27XjVLfOnDxLty4pNGgKThGEdrsTZ9YMFE9exZQvyDhih5Y4 npjkufboX9arpr X-Received: by 2002:a05:6402:84f:b0:5cb:b65d:2b6 with SMTP id 4fb4d7f45d1cf-5cea975527bmr5170634a12.32.1730459117491; Fri, 01 Nov 2024 04:05:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzP7bq1vTQ5CjfggoQV/hep+T2DKSY1XHpFmoayKBYBK5xsOo7K9TFVibqlKQb0C5mesh59w== X-Received: by 2002:a05:6402:84f:b0:5cb:b65d:2b6 with SMTP id 4fb4d7f45d1cf-5cea975527bmr5170617a12.32.1730459117105; Fri, 01 Nov 2024 04:05:17 -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-5ceac7e9e65sm1404839a12.97.2024.11.01.04.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 04:05:16 -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 12:05:14 +0100 Message-ID: <20241101110514.523356-3-ryan.lee@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101110514.523356-1-ryan.lee@canonical.com> References: <20241101110514.523356-1-ryan.lee@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/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;