From nobody Tue Dec 2 02:05:48 2025 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 29A2A330D47 for ; Thu, 20 Nov 2025 12:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763640431; cv=none; b=MFrnwlW5Y+MLnz0dvlOUFNAKkWmv24mhKUeTC+V35rPeSV5JBnqtzbXrigkMF4C34ESevI6XijRtqUj/SkEzqqak0YVY30qeuc7yUQShb7q5MKzumS5OXKeGzry7N+eo1Y4vfjRTwZMard5Qvotb4BZotxmGnk+0K4b1CE/kh7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763640431; c=relaxed/simple; bh=kHIRw9JtarZwa773c9rrA7Sh/ynBxdlTXwbJEgMPosU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Vkv2QFu6zmxF0rJs0Fo1nCtVyjkv/TiXuVxcq367sMUp+VC9Ha6wRSxXmR8hc4UqjRsoFyHNS22GMWYpR9+XSO5HClFQcdyOTxfBGz2Wc+fn0Tfl6Ez/INsaGe+NYKvF97OImY2gnLjnEcTn7Kyc/mYz7ye7o3yfHkPw3xfj2JQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mRK3WJ/S; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mRK3WJ/S" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-297d4a56f97so11930425ad.1 for ; Thu, 20 Nov 2025 04:07:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763640428; x=1764245228; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=X5oFycNEQQvwxiwtacy6vIh6YX/aGmQRlWzpW1R7bkA=; b=mRK3WJ/S1MRudwFG8AUgCShC7G+2EkFT6tkbhy8rYSMggoLpq6lAJGKpIKH/V7ya2v BHZlDwqcJyjMpTE4LVkQJd/Yq/uYXLRoo/h27kTWvhZDnnRUu6X6+f4LbllkzobmNCtm 0lB8VUhuWMCuWl4YAL79sJhJ2FObxY37YiEgnQ5GP5doYDoaCF063/9ugRnqUsN9ivxo L5//TnIWZ4iZ19OF6HTq/vCiK4d4yem3V0EVAf/qk8XSiFR7nXwVdg71Be54ISKuecl2 iHZFSE36jTIXvm8zGnlpK6TRuKT1MjDLLRYdzekNJsOKEukxFe4CVK81ntBmjqADcxVV yF9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763640428; x=1764245228; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X5oFycNEQQvwxiwtacy6vIh6YX/aGmQRlWzpW1R7bkA=; b=U87XfBM0lzLYwJ1Dei3Z8P949b8dG3Oi8rv3IMCNi6oQxBPkpgnRa2AnRLJWXE6hUq h72gYKn4wpHBIJ9t+I0MWQgU2E5U4Vo9bMpeoF4kXKDpE/jJptGzR0lpTcTZgWLS+wna rr+tTDvBbOOn+ucpmVyEO542fZpIglJwWvKvd19GTkztDYUwx/XUhsODAzAszPyS/qVS Hh5CR3AARJGwDuQZ+VIViST3q+hLJsTeGzMzlUPZULwiXSUU6u77DpchBBKGGYinDCMJ GF2EJQOleyKpOkF+YFL0dyugzLT7FA0CqTSZdJWQbistjF6pID6gUK4NthcVdw2vnkw1 M8GA== X-Forwarded-Encrypted: i=1; AJvYcCWOG6/gWOclcAukOcxOUEHIXW61T6VXJoM3VVXJ+H+UqKf0dNs+Shlm+sPz2/otjlCt/StXgeVEx/YZW9k=@vger.kernel.org X-Gm-Message-State: AOJu0YydLYXwYWXKP3WhztH1lX/x0l0Fc3mc/rIXTqI/03Kz1nSvBPMt iJFh3mkIs9U8xeZgjGolXAtPwGKQ+/11pMXTC8GKl1m1fN7tEplCejcp X-Gm-Gg: ASbGncsVEpGj1VXR8AEm7K4Wblf72+UHLwW31jBNCN4D9ZhfPcXGYY+f6/Iwx0XZlOW MTRiQiBcdrFy6mIOe15OZB+F0Tw2SdnkCxMgXL+GDAJQMjMtHjpg/VGiYHo6i+wSHmvqp6gS9X4 51imrrIWHkHPLZFEhRU3Z42DV4frIKEbqSC0iCbn1S1LI5thE8wtvvjwL3N/A2E/4Z0wus1imyn QoU+pM4yZJInevBT0MOmRy8rRJ0amipxVuIU2Er2LQjCrGXpTtpK8v7UmlcA72NoTPec3HF73QC fqtuG7gfzFhzxT+LK+Ec56g4v497j0CvAaIHhKTEINVmZI4e7sbvZbIDfsL0toq8fYu5gbXwi7t bzEYVFgspLH9UscxB9uUG5oMU2i15rQOEgwM6eZfdgnKCPbADeY2cy7P9RCgU+vp/vjEu2hxmv6 GAEEpYyhLxc7baRImdJLOpUUWvqCK8rnT8umqG X-Google-Smtp-Source: AGHT+IHFRDK28WOgfhLwyxo9fNDEJUyqOd57Tzt8s5kHu8siVkpXQv00/V1u5HV+EbRwk50S2r5gnA== X-Received: by 2002:a17:903:183:b0:298:45b1:6c30 with SMTP id d9443c01a7336-29b5b163032mr35372985ad.57.1763640428097; Thu, 20 Nov 2025 04:07:08 -0800 (PST) Received: from localhost.localdomain ([1.203.169.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29b5b111650sm24894815ad.8.2025.11.20.04.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 04:07:07 -0800 (PST) From: Gui-Dong Han To: 3chas3@gmail.com, pabeni@redhat.com, horms@kernel.org, kuba@kernel.org Cc: linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, Gui-Dong Han , stable@vger.kernel.org Subject: [PATCH net v3] atm/fore200e: Fix possible data race in fore200e_open() Date: Thu, 20 Nov 2025 20:06:57 +0800 Message-Id: <20251120120657.2462194-1-hanguidong02@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Protect access to fore200e->available_cell_rate with rate_mtx lock in the error handling path of fore200e_open() to prevent a data race. The field fore200e->available_cell_rate is a shared resource used to track available bandwidth. It is concurrently accessed by fore200e_open(), fore200e_close(), and fore200e_change_qos(). In fore200e_open(), the lock rate_mtx is correctly held when subtracting vcc->qos.txtp.max_pcr from available_cell_rate to reserve bandwidth. However, if the subsequent call to fore200e_activate_vcin() fails, the function restores the reserved bandwidth by adding back to available_cell_rate without holding the lock. This introduces a race condition because available_cell_rate is a global device resource shared across all VCCs. If the error path in fore200e_open() executes concurrently with operations like fore200e_close() or fore200e_change_qos() on other VCCs, a read-modify-write race occurs. Specifically, the error path reads the rate without the lock. If another CPU acquires the lock and modifies the rate (e.g., releasing bandwidth in fore200e_close()) between this read and the subsequent write, the error path will overwrite the concurrent update with a stale value. This results in incorrect bandwidth accounting. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Gui-Dong Han Reviewed-by: Simon Horman --- v3: * Expanded the commit message to describe the specific call paths causing the race, as suggested by Jakub Kicinski and Paolo Abeni. v2: * Added a description of the data race hazard in fore200e_open(), as suggested by Jakub Kicinski and Simon Horman. --- drivers/atm/fore200e.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index 4fea1149e003..f62e38571440 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c @@ -1374,7 +1374,9 @@ fore200e_open(struct atm_vcc *vcc) =20 vcc->dev_data =3D NULL; =20 + mutex_lock(&fore200e->rate_mtx); fore200e->available_cell_rate +=3D vcc->qos.txtp.max_pcr; + mutex_unlock(&fore200e->rate_mtx); =20 kfree(fore200e_vcc); return -EINVAL; --=20 2.34.1