From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EBD92E7367; Fri, 7 Aug 2026 15:07:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786115235; cv=none; b=aGQZi0ll2vEOzpaWGJAE8vt7ueJ/Om9mL8wk2ZN7cNMSDXlzAjeMlpElNLtxuJ/ueLsZI6/5vnv+DSOvRQJo5x0TdwMwsALHxRMvJANMZ8HKMQhkZ/1y4wyH9I+JdNmPejBEEyyx/ZS0TCSYjzyXsf0CHHkTrd0Awhq9u2QBKgU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786115235; c=relaxed/simple; bh=QAzz2Ll8EwIpC256vW542lG9jiTjuKugfE/WIDuQ1kQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IZk4izC2flsCv1bOdn6DkcqMKb6IO5lg75NBsgOKtw13rAfSPf/2seCwlARnAZaa94lJzV4xBzy8cE6PGN/5foqrNrxX01HtT88xztbCraoDySDYhSLD5Rjpn5vOluJeOMY4zzT6Dr3UkQtKAekE5eWc03Ke+pqUlB1W3pKwZtI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oxd3taSf; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oxd3taSf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1A931F000E9; Fri, 7 Aug 2026 15:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786115234; bh=BY6DvEHxmNyypbMaowautas9TxDxP0aMY3kTwrxDOyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oxd3taSfxz51XZWHNK4tAndsZYS82feDTfEHb/+0kF9nqipV+OXTi7zufjpjkoZsu Wni/AOEYcITPtYUIbXaDhJcYwSvCmDFg5QLz3spue6g2NjCEVxRpZeOFpDTz9jcvFF 8IHeAExBHY6SM4KamNKXPwDPjy1fiVDb6e/DVI5s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vega , Luxiao Xu , Ren Wei , Paul Moore Subject: [PATCH 6.18 188/396] audit: fix potential use-after-free in audit_del_rule() Date: Fri, 7 Aug 2026 16:35:48 +0200 Message-ID: <20260807143428.342815217@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143424.272339768@linuxfoundation.org> References: <20260807143424.272339768@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luxiao Xu commit 246df90b5f1a8a6e6abbd2f058b029558720adec upstream. `audit_del_rule()` destroys `e->rule.exe` via `audit_remove_mark_rule()` before unlinking the rule from RCU-visible filter lists and waiting for a grace period. Concurrent readers in `audit_filter()` and `audit_filter_rules()` still dereference `e->rule.exe`, while the fsnotify mark can be freed on an independent lifetime path. This creates a use-after-free window during rule deletion. Fix this by unlinking the rule from the RCU-visible lists and invoking `synchronize_rcu()` before calling `audit_remove_mark_rule()` (and other rule removal helpers). This ensures that all existing RCU readers have exited the critical section before any underlying resources are destroyed. Cc: stable@vger.kernel.org Fixes: 34d99af52ad4 ("audit: implement audit by executable") Reported-by: Vega Assisted-by: Codex:gpt-5.4 Signed-off-by: Luxiao Xu Signed-off-by: Ren Wei Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman --- kernel/auditfilter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c @@ -1047,6 +1047,10 @@ int audit_del_rule(struct audit_entry *e goto out; } + list_del_rcu(&e->list); + list_del(&e->rule.list); + synchronize_rcu(); + if (e->rule.watch) audit_remove_watch_rule(&e->rule); @@ -1064,8 +1068,6 @@ int audit_del_rule(struct audit_entry *e audit_signals--; #endif - list_del_rcu(&e->list); - list_del(&e->rule.list); call_rcu(&e->rcu, audit_free_rule_rcu); out: