Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794193582; b=HXlYCR2d3mfu21p7InUJdPhGHv91w1PFnidd/b9sZkGiSlHmEeFS9saASUZRZxdZde35 Z4DMNgrF03QXSKjpxziVmNi3b5SH1FYgCFuuuaPGJhkMy9Ynzyl/rIS04tKUcCOC24l7C KTULE17juGSay1UfisHcMmVYs3TNILlDyNnuSiEFzCEn/wtk+vQfn4eatt1txxRisAnTX kVtMm524HAfyYxPHxQveCHP10OU30fn9mbsI5P/bDISu9qal4vjeIYhk9WUdnNIEJSjGi W9AmtPVPB2udG8Jhb1Sl93aPQXLw7Pfwyn6Fa6AbefYUx5wwoL7DKDUCxTPG8Y96Y6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794193582; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=72xNvZVGemunEq7nh4QxvyqYU22yqRPKDUXrgmykUsA=; b=M9r1MMUlUU7DuuacyrdGrlzI7NwM4mcu7/gZCdpcFipFoyhlLH6WpZUHXgvon4B3eV9b CTcmIcNWQ8LR3W7eRwglnDtAVKMLcaHKU3NYi6zuET1S7NeytTOrBgeeMRaJtmDqghvAW 4aHx6+pgH0GhVagJYnuuLPGFGyfB/V7tzh7WGKgN35UrFasqDO+zpmfVL+VrdNaHUaWqj bC5KbeFTJfoyHXufAx/5E0RH0SAEjSvXFKMP0Is9JR+AxZajZyj4g7HZ1POGWqbnEMnwj sKSqLJ+Z4Xavvzd2Uq6sQ6bfI5dDQEnC38kFuFDjjlimzYvXAUkqv4jDxig2SQ7/YQA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=xiaopeng.com; spf=pass smtp.mailfrom=xiaopeng.com; dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=j3m7zHX2; arc=none smtp.remote-ip=115.124.28.124 Received: from out28-124.mail.aliyun.com (out28-124.mail.aliyun.com [115.124.28.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F2DC606A31C for ; Mon, 9 Nov 2026 03:06:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6F2DC606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xiaopeng.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xiaopeng.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=j3m7zHX2 DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=xiaopeng.com; s=default; t=1794193577; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=72xNvZVGemunEq7nh4QxvyqYU22yqRPKDUXrgmykUsA=; b=j3m7zHX2MNomnosYG7IFyEmhC+WbgVRjBRBlrCPT9C3FDdKCk2g72kmltRdbgwJ8B3i/x+ETitGIoycSCkUg4/ORDkzADyz4h6A14wMGCgA3UToxy3GI3sgpOjaIXTflKkko0hKA7H31zCBSEfNVMoGYdLCDXrIA8WilM498P50= X-Alimail-AntiSpam:AC=CONTINUE;BC=0.08376567|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.00326324-0.000194435-0.996542;FP=4424648679000448758|3|2|3|0|-1|-1|-1;HT=maildocker-contentspam033037071049;MF=zhugl3@xiaopeng.com;NM=1;PH=DS;RN=2;RT=2;SR=0;TI=SMTPD_---.jzgY-s-_1794193576; Received: from DESKTOP-UL5U09E.xiaopeng.local(mailfrom:zhugl3@xiaopeng.com fp:SMTPD_---.jzgY-s-_1794193576 cluster:ay29) by smtp.aliyun-inc.com; Mon, 09 Nov 2026 11:06:16 +0800 From: Guanglei Zhu To: stable@vger.kernel.org Cc: John Johansen Subject: [PATCH 6.6.y] apparmor: check accept index + 1 is in bounds Date: Mon, 9 Nov 2026 11:06:16 +0800 Message-ID: <20261109030616.419429-1-zhugl3@xiaopeng.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261107054036-failed-6.6-afe5d5a74739@kernel.org> References: <20261107054036-failed-6.6-afe5d5a74739@kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit [ Upstream commit afe5d5a747393cb3d00795db31d7fce5108a766a ] aa_lookup_condperms() returns perms[index + 1] when an accept entry has ACCEPT_FLAG_OWNER set and the subject uid does not match the file uid, so such an entry consumes two slots in the perms table. But verify_dfa_accept_index() only checks that index is within the perms table, so a policy that sets the owner flag on the last entry is accepted, and the runtime lookup then reads perms[index + 1] one entry past the end of the table. The perms table is allocated by unpack_perms_table() with a u16 size read from the policy blob, so a crafted policy can place the owner flag at index size - 1 to reach the out-of-bounds read. Check that index + 1 is also in bounds when the owner flag is set. Fixes: 6f442d42c0d89 ("apparmor: fix profile verification and enable it") Cc: stable@vger.kernel.org Signed-off-by: Guanglei Zhu Signed-off-by: John Johansen [ Adapted for 6.6.y: verify_dfa_accept_index() takes a non-const dfa here. ] Signed-off-by: Guanglei Zhu --- security/apparmor/policy_unpack.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c index 589b43c..f002290 100644 --- a/security/apparmor/policy_unpack.c +++ b/security/apparmor/policy_unpack.c @@ -1201,6 +1201,15 @@ static bool verify_dfa_accept_index(struct aa_dfa *dfa, int table_size) for (i = 0; i < dfa->tables[YYTD_ID_ACCEPT]->td_lolen; i++) { if (ACCEPT_TABLE(dfa)[i] >= table_size) return false; + /* + * Accept indexes for owner-conditional permissions come in + * pairs, so the non-owner entry at index + 1 must also be + * in bounds. + */ + if (dfa->tables[YYTD_ID_ACCEPT2] && + (ACCEPT_TABLE2(dfa)[i] & ACCEPT_FLAG_OWNER) && + ACCEPT_TABLE(dfa)[i] + 1 >= table_size) + return false; } return true; } -- 2.43.0