From patchwork Fri Nov 8 01:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Lee X-Patchwork-Id: 2008204 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 4Xl1n74DxZz1xyk for ; Fri, 8 Nov 2024 12:38:50 +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 1t9DxK-0004Jc-Vb; Fri, 08 Nov 2024 01:38: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 1t9DxI-0004I3-MS for kernel-team@lists.ubuntu.com; Fri, 08 Nov 2024 01:38:32 +0000 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.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 69BE93F2B5 for ; Fri, 8 Nov 2024 01:38:32 +0000 (UTC) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-7202dfaa53fso1975039b3a.0 for ; Thu, 07 Nov 2024 17:38:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731029911; x=1731634711; 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=2q/atr0F1XBd1dWhz1rnSbGbrgoV+2NhpEb3Brjcqa0=; b=u8WyvgyMmmaWkyfJnHbRl7qchXc6ecUl9FZo5+h9/w+S/zqrkPtEpv4J+u89bEEene QS3qSVv7dAdM0ibSJNXCNu65snlXIMHF0LPTTqmG8QbeOuzAp4skH5grR0NCHXX++7Om q3drouwnblxnJedFQfsJ74dOw6/8AmlPBF8QsQaTUre3mMUKcQagHrfkxGeLBFf9JaCF oHW/vXTuT6CKMWuxTvNTZktlhTiyAOsPteKKDvNzQT2jy+hOdRsHL8OJWRrhi0RI5D8H 7M8sVnKhLQVtLW+y7EF9KtMyuVelJxeHuj8nhAC9Twhdwo0Ts6LzqQ7UTI0Nrdp0qhgO rvGg== X-Gm-Message-State: AOJu0YzBmvMju8wpKqX/lw+fiHxhWTo1Y4OZ4TNEppESUtckJ8fuoGw5 TUmOI8IbnWzdk/ua/TeCQwiUPH73NTHd2Q9TLCrjVXUPjioJfYFyLq6PPE0RE4LmlhptpFMgtc4 wVtpg7odcqrN6RY5HTOXvtoVs/whKj6/lEmQa79CE+KrYOyoQLneVhrXLrRUYk5CA0grLUt4nvA NaneOfLaVqJCmo X-Received: by 2002:a05:6a20:1588:b0:1d9:76a3:634 with SMTP id adf61e73a8af0-1dc22b93839mr1283316637.42.1731029910984; Thu, 07 Nov 2024 17:38:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUu3UVcgDCrx3W04dFbigtsLlZmhIzEoQZU9/JWahyrth3fkNyydjqthRUFoImDhC1uCR4Pg== X-Received: by 2002:a05:6a20:1588:b0:1d9:76a3:634 with SMTP id adf61e73a8af0-1dc22b93839mr1283293637.42.1731029910626; Thu, 07 Nov 2024 17:38:30 -0800 (PST) Received: from ryan-lee-laptop-13-amd.. (c-76-103-38-92.hsd1.ca.comcast.net. [76.103.38.92]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724079b7712sm2476504b3a.103.2024.11.07.17.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 17:38:30 -0800 (PST) From: Ryan Lee To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH v2 1/2] UBUNTU: SAUCE: apparmor4.0.0 [94/99]: apparmor: allocate xmatch for nullpdf inside aa_alloc_null Date: Thu, 7 Nov 2024 17:38:25 -0800 Message-ID: <20241108013826.93748-2-ryan.lee@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241108013826.93748-1-ryan.lee@canonical.com> References: <20241108013826.93748-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 oracular:linux) 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 8 01:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Lee X-Patchwork-Id: 2008205 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 4Xl1n74Kqvz1xym for ; Fri, 8 Nov 2024 12:38:50 +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 1t9DxM-0004Jz-7Z; Fri, 08 Nov 2024 01:38:36 +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 1t9DxJ-0004IN-UD for kernel-team@lists.ubuntu.com; Fri, 08 Nov 2024 01:38:33 +0000 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (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 81DA53F2B5 for ; Fri, 8 Nov 2024 01:38:33 +0000 (UTC) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-71e479829c8so1886846b3a.0 for ; Thu, 07 Nov 2024 17:38:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731029912; x=1731634712; 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=4TAZP9fHkOnnHs0PgtP0jiBJK4OH9HxU2qbYlJD7aDA=; b=SVou26emJBtMJlWZTO/oRsdnYQMutcxfPo7bWwROJh5hePY8rXatX5vcqGhCM9U4Hc Xo6RgtcWnQShRA7dOiy3f8s6iuyGJM7w81EikVXEC0PH7/CMUEGq3NWfHqYkEW7SiJ65 u/UAqxQOGrAsOABl9pMOLnTubV/Vr8DjPwCsY4AFDBhItCRGmMleLr93JEO5PoOHmEIY AnDxRQwhwdXdmomoe5rzeIQmOVWl/3N629BE7+vVIO6xVC/Dafriq2OO7sG8qIqH3Pvm 3AwxJ0885T0RkkKj0wj0u0giPR6QI9vGUVg6RxmwEC2kGsnTgE6UUoZXMOs+ZkgIpD4Q GkpA== X-Gm-Message-State: AOJu0Yw+jJlCb68EwRp8RYaHC0L1Me6d9pjLGgnlsok32yjTKVkhlicY HHBnGL7Jbts5dtZYp0L+qybm+5lP+Qytc/p0f6T1SQPbEsW4XY4wRz1RI1MM2TIeTrsNSN4kKi5 5lvcN2Aohp4AHRbcrWqfl3JUR7xamwoID9N8cpBkfasW+F34ltAIUTXF1BeGCDy8j4QHkrJr9dY pefDDT0pWj9z7w X-Received: by 2002:a05:6a00:14ce:b0:71e:7636:3323 with SMTP id d2e1a72fcca58-724132a3938mr1740259b3a.7.1731029912204; Thu, 07 Nov 2024 17:38:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhZwf8PGJz4pDnPexBB9vD2ASzT9GcD6v9Lc/R4SYfa8Go86S3LFE9gcwbWm5dza01NX9iAQ== X-Received: by 2002:a05:6a00:14ce:b0:71e:7636:3323 with SMTP id d2e1a72fcca58-724132a3938mr1740233b3a.7.1731029911822; Thu, 07 Nov 2024 17:38:31 -0800 (PST) Received: from ryan-lee-laptop-13-amd.. (c-76-103-38-92.hsd1.ca.comcast.net. [76.103.38.92]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724079b7712sm2476504b3a.103.2024.11.07.17.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 17:38:31 -0800 (PST) From: Ryan Lee To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH v2 2/2] UBUNTU: SAUCE: apparmor4.0.0 [95/99]: apparmor: properly handle cx/px lookup failure for complain mode profiles Date: Thu, 7 Nov 2024 17:38:26 -0800 Message-ID: <20241108013826.93748-3-ryan.lee@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241108013826.93748-1-ryan.lee@canonical.com> References: <20241108013826.93748-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 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 oracular:linux) 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;