From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796291014; b=mW69ZbybcVxUkLGJyvqbknEpAud+jzZ9nphcRobBUYea8kWlUnf/Jc095Isz23aruVQa RzQ4Nr/WVjX3EpSrkKVpM7VAbd5vKvHj9m0vb/PcadJMnqgt++FP2Ll/hDsqf2fKPqmZp bc1G+1jpjHeMSmVp36ZfLbUM5IegDygcxPx14FVPEg4wtvBe/4BwaS1ztD4E/28N4uqTl v0n4k3dvQdQnRf87x2FDRGvT1Ni3vgpdoCOEv6ZkB1fDmorvQKJpKUZpBO5kclyumNcTH 2Hn8Se8RN+nv5xoLq1erIjJdnBTeujZXFLh9BEWbrclfGYzm1GH5JPEdLjOkyJoU2dw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796291014; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=RUktCa0pLiP+bRnNODKFfEkH4vSRnYcAOVQbErt1+rQ=; b=X92lt2ECOdefmcEFjVn5WzP3BE2GsxnKDJBNfVX1Mi5uvP/Q1Vo+UCTAniwOLu+MX+S8 cx+LeFjP2BHxzqjpNVlDTKsfI2zqptBYcxyJTEGL/2vb3C4e64fJzIQyBM9XbzECysyhj UljqXR2p8wGXHy61k55izZadZxQB/zjos3cE1crZwR+kl9iav902c6bGkjLfVr+cO3BXH kBGvmfR9b1DWedvvYkz4hLz8A9xptlqDDUMZXpnngCc3kgLkE8QWlml6coVbr+euIaDHE 8lbClE9ZDyvFbOfShtqh9v3F2IbeAym7ds2jKaac36y3JgSKNQI8KokCIbxR+0brQWQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dAF9yAIj; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78874606A322 for ; Thu, 3 Dec 2026 09:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dAF9yAIj Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8C691F000C1 for ; Thu, 3 Dec 2026 09:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796291014; bh=RUktCa0pLiP+bRnNODKFfEkH4vSRnYcAOVQbErt1+rQ=; h=From:Subject:Reply-To:Cc:In-Reply-To:References:Date; b=dAF9yAIjFbd2RTlJ+OehOkpdYctXO0GOgx3+HSUZOn7tWy2UMq5qRd9+3ROCriiKx 3oNpWmauRvlybXlDW7zxgH8Ok4cJ9KJd9EpewCGUotzvpPuJMEqXnQ1UZALu5D0C9h 5UKyp6ECJMx1vkVkQjUfnNbuH0s4YK+icyBxcgPVofCjr9HIBYCjBFedKes7HGyJku ebO34NdfXuDnXoNhsbZGzid1ihBiIq9FMwp18/ZE4kREVwj6vowKXx2W3TuFhXPlH8 fJZR/MMfgW7EnWS9MBUFu3J+f3oAScUjrxbThDKGfCFUSonBvOU1O3qrH4Zck/Zj/h kpiIbx6AOq8+w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] audit: unlink tree rules in the update_lsm_rule() error path Reply-To: sashiko-reviews@lists.linux.dev Cc: =?utf-8?b?b3BlbiBsaXN0OkFVRElUIFNVQlNZU1RFTQ==?= In-Reply-To: <20261203092331.2258226-1-hdthky0@gmail.com> References: <20261203092331.2258226-1-hdthky0@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 09:43:33 +0000 X-Mailing-List: audit@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] audit: data race on rule->tree in update_lsm_rule() error path -- commit cac8913d0efae9fad82939eb55583b67b3cf861a Author: Xingyuan Mo audit: unlink tree rules in the update_lsm_rule() error path This patch calls audit_remove_tree_rule() in the update_lsm_rule() error path when audit_dupe_rule() fails on a rule with an associated audit_tree. > diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c > index cf91ba6f3617b..06fe7ab13eb7a 100644 > --- a/kernel/auditfilter.c > +++ b/kernel/auditfilter.c > @@ -1422,6 +1422,8 @@ static int update_lsm_rule(struct audit_krule *r) > audit_panic("error updating LSM filters"); > if (r->watch) > list_del(&r->rlist); > + if (r->tree) > + audit_remove_tree_rule(r); > list_del_rcu(&entry->list); > list_del(&r->list); > audit_rule_unaccount(r); [Severity: Medium] Can calling audit_remove_tree_rule() before list_del_rcu() and without synchronize_rcu() race on r->tree with lockless RCU readers? audit_remove_tree_rule() performs a plain store setting rule->tree to NULL while entry is still reachable on the RCU filter list. Concurrently, audit_filter_rules() reads rule->tree under rcu_read_lock() and passes it to the static helper match_tree_refs(): CPU0 CPU1 update_lsm_rule() audit_filter_syscall() audit_remove_tree_rule(r) rcu_read_lock() audit_filter_rules() match_tree_refs(ctx, rule->tree) if (!tree) /* non-NULL */ rule->tree =3D NULL; /* reloads rule->tree as NULL */ audit_tree_match(chunk, NULL) <-- data race / false match list_del_rcu(&entry->list) Because match_tree_refs() is inlined without READ_ONCE(), the compiler can reload rule->tree after its NULL check and pass NULL to audit_tree_match(). Since remove_chunk_node() clears chunk->owners[n].owner to NULL in place, this can match a cleared slot and cause a spurious AUDIT_DIR rule match. Unlinking entry with list_del_rcu() and list_del() followed by synchronize_rcu() before calling audit_remove_tree_rule(), matching audit_del_rule(), avoids the race. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203092331.2258= 226-1-hdthky0@gmail.com?part=3D1