From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 669A8317148 for ; Tue, 30 Jun 2026 20:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782850543; cv=none; b=oExi2+I3ShA/tvkCW7MJBuU+aeFzoW4LHI6A7MO/CpJNMJg359SiswRaZc16afWoyBwQTk8DKpUYHMJ0z4FfsE+xQnmmO985R6pBcqoGJFevSmcPEyqqMypNT0Hvq1nIv/XuH57AXOyp7AXEJAUCEcnqpYQ7tcSihhFrhj913rc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782850543; c=relaxed/simple; bh=KIFyvcUp0DrVIt8fHT9eaTmd9j+JW0nG/kc0JEntHo0=; h=Date:Message-ID:MIME-Version:Content-Type:From:To:Cc:Subject: References:In-Reply-To; b=iaPTbtNCx92gR3SFPZ2TYVQv4uhdpCZCf1tUNlfG4aSdZJAFEq+PfW4xvrW07aSlIetIJRZFQRuju9ICTDEdNPur6JZ2a33sgaGyDMv+yXDiKuubSjD2Yi6yjrlV45KMKxdMHuss23gqWk+Gz6SN4Poc1zBakNoD2h2+/Nhugn4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=FD9qNVG9; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="FD9qNVG9" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-519fa6d7a78so43937031cf.1 for ; Tue, 30 Jun 2026 13:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1782850541; x=1783455341; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :mime-version:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=kFbHVAQO3lUQEfR1Rl9bV17oIFy3lRBFLhFrds1anbs=; b=FD9qNVG9ghKZtiCZ6swyuznBfdOg8kXjU5Jm0yZXwtSoAeXruNiPNEjdsQAhtmRH0i mmPLvU5ZegL+75c3MwUYLPPytDjMQEyruqA3pk1x3ohO+VmD8QRwbJtnYrOSxm5ZhtcC evnr1VPbEXFOTKKKPt7pC1l4fkvzBn9sWzWeLa5lRSKOzcqX3EHiZsvtbZWQ4Ai6VaAP arZTc7c44q4iXK5Q66tY72YdXBcIAMjMkRiQmxRJghQIsA3N0aE6VhvB5J6jS1BPjLDj u7Yh4aGZe7xRf7PV/NstOqAIgzXX8kVHZK/o6WrFRgL66O+JnwWNE+mCqAmIILAFcBCs W6wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782850541; x=1783455341; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :mime-version:message-id:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kFbHVAQO3lUQEfR1Rl9bV17oIFy3lRBFLhFrds1anbs=; b=joCpfUJUL4ycTT0sHlKIeawmdwZ/f/1vBXqgOm/7gbB+uSF5paBL05sR7sbwbB5xXH m98CNvHKBXooZ4sMlnUlNlg3ZnLriXdmHyEr4aAd//VAenY8I42zX1FXbrFIlXi+sRol k8QqJDBOQO1EBX+dKvJR7YpRmJLt/4xuy0sn3SBmf505Xz7NLC+mtSsGLo6lxuGEzWFP hqOBO81bdVxou9TuYrbfrugbdAIIC16VY2BxwxVibKeJY9s6vrPDENdY19IUJP6qd7Fc LmqdKz8NJaAx7PDQUTWXqbvdykZmyqGweaB9gIGlo20sTjkzMa69r19Ns8e+DISiPjWs Oq7w== X-Forwarded-Encrypted: i=1; AFNElJ/ldFlHhLtk5dvOM7J5NRTz4dtZ/ukPDGKm2VdMZ2KBljBBNxB3RYlDKh7Yc40waxTCUz8vFZuoHlgJrSA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+HvHlpb/0XOHURiRe4nLpl7w2NFg723tGIX4fZ6TxYyI62itB n2w2Dr+2l+WuSfI37h8zZSqGy/vWLW6xIvsZd1qDYb+QWIfRXQXXyJmeuSOvy4o3UA== X-Gm-Gg: AfdE7cle6cOO/eoJt9I6z7gNRLrTAQrdDqLrfudkWCFxz2tA3jRbZ9gSc4CCiFteWqL 2/QMnLCIQU7yE6MVSEAFaBhBu+3RG51hEJZ5WQmFbFhcSec1UrRzIefdlZmwbllejpY4DwSHTGl PPKQgWVeTZkJTS5GNQnMfAnkHARQ0KdunxisdgClalWiMUfKIQl4vBPisQDItW1Vmp76d5lrBnz +XiGXaI5eP8ClPHqbhtEXR+qHnjOHlHFOuKUNwi03Ng845zo1gtvYLS6VJg+3yj952OrlisFJT8 dyqPztCIknQBh0Ol7fv9yoZpck25aFeRp7xq2RICkgB/zMKL8iXRVCmNJBNvsioPvdiX822QoQn xeNUrvcnxnW1ndoj11gDxtxfiXdzZbbaK7mFl9jT9o4IpE82FavMCpY1fMw1dH6iOVzHmXvobyA +8BIzM3YjfJ04haOpValECiclIqPfnva9TcdoCfNNc1e66caiOQoBqn2/kcA== X-Received: by 2002:ac8:7d52:0:b0:51a:8c97:9375 with SMTP id d75a77b69052e-51c108d823bmr65449501cf.61.1782850540414; Tue, 30 Jun 2026 13:15:40 -0700 (PDT) Received: from localhost (pool-71-126-255-178.bstnma.fios.verizon.net. [71.126.255.178]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8f1a727429fsm32068956d6.37.2026.06.30.13.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2026 13:15:39 -0700 (PDT) Date: Tue, 30 Jun 2026 16:15:38 -0400 Message-ID: <790e5ee50f15c85b8b1e36c85f0e7f2f@paul-moore.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailer: pstg-pwork:20260630_1523/pstg-lib:20260630_1303/pstg-pwork:20260630_1523 From: Paul Moore To: Chi Wang , Eric Paris Cc: audit@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Ricardo Robaina , Chi Wang Subject: Re: [PATCH v2] audit: Fix data races of skb_queue_len() readers on audit_queue References: <20260619074244.377226-1-wangchi@kylinos.cn> In-Reply-To: <20260619074244.377226-1-wangchi@kylinos.cn> On Jun 19, 2026 Chi Wang wrote: > > Multiple readers access audit_queue.qlen via skb_queue_len() without > holding the queue lock or using READ_ONCE(), while kauditd writes to > this field via the skb_dequeue() → __skb_unlink() path with WRITE_ONCE() > protected by a spinlock. This constitutes data races. > > All affected skb_queue_len(&audit_queue) call sites: > - kauditd_thread() wait_event_freezable() condition > - audit_receive_msg() AUDIT_GET handler (s.backlog assignment) > - audit_receive() backlog check > - audit_log_start() backlog check and pr_warn() > > KCSAN reports the following conflicting access pattern (one example): > ================================================================== > BUG: KCSAN: data-race in audit_log_start / skb_dequeue > > write (marked) to 0xffffffff8512ee20 of 4 bytes by task 661 on cpu 57: > skb_dequeue+0x70/0xf0 > kauditd_send_queue+0x71/0x220 > kauditd_thread+0x1cb/0x430 > kthread+0x1c2/0x210 > ret_from_fork+0x162/0x1a0 > ret_from_fork_asm+0x1a/0x30 > > read to 0xffffffff8512ee20 of 4 bytes by task 36586 on cpu 1: > audit_log_start+0x2a0/0x6b0 > audit_core_dumps+0x64/0xa0 > do_coredump+0x14b/0x1260 > get_signal+0xeb2/0xf70 > arch_do_signal_or_restart+0x41/0x170 > exit_to_user_mode_loop+0xa2/0x1c0 > do_syscall_64+0x1a3/0x1c0 > entry_SYSCALL_64_after_hwframe+0x76/0xe0 > > value changed: 0x00000001 -> 0x00000000 > ================================================================== > > Resolve the race by switching to lockless helper skb_queue_len_lockless(), > which internally uses READ_ONCE() and properly pairs with the WRITE_ONCE() > write accesses already present on the writer side. > > Fixes: 3197542482df ("audit: rework audit_log_start()") > Signed-off-by: Chi Wang > Cc: stable@vger.kernel.org > Reviewed-by: Ricardo Robaina > --- > kernel/audit.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) Merged into stable-7.2, thanks. -- paul-moore.com