From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796026018; b=vRqV8SfviCEFUe9w5H4Cj6AXpJt0RoXZ0nFIHoRGPTUkzdwRFyH6tagQwcnViAF0sHa2 0xRBSUA+r4OZHKL+NKNL9JO5mDXGiWW4rJKbOcIjMc+D2iTYo6RJNZwngCew7cXEiidyV WPX8/3pK2KqGSjvpGH2Y5VvzwL+6Af+N+6SkV5SYcTttlSdz0frdZ2rnz9fmT8BJKx4zu EqPanDgEPF5VELUDApkigzxZ/PKPSD6HvACB5XRtTdFSYMXWI1tou1X+ygYcX9/fuw4J2 gG1w/a9iHmiTnxjwao2lSVb1RF34l8/6AF7kxT7NnvMc1VizpLFUIuQvXqGbrLz5Saw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796026018; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=00ZnVXtvJdbQ6EFCvIdd+vEU62B4FcKLVFM1WP60avk=; b=Mw/bW8QyW/fuFXMqnAREEXLFUX+UkuVBNwJciOsKNwir+2+KGAf+nMI4F8bQTaIYykbh cHhYiT5FaugYQQcuGk3NDOG4vji7M5k24KvSay4G8E6b2DS440ldBKnaUKzH0yDwuE6D5 HG43eUQozJuXco8g3LZQPpFdVqlaoT8t9L+NjfMxQVtv6IxUFAbYME6g6mxh6iv55JKzH bXKfQmO688nNd9wTjfL21tx5j1pUWVmr237nfjZLQJSNsI0eMrUHf7hW4OM2SQzcGN+Eq 0Rnt3/xC4x92mzgCKPutp3K52HrKSXqV54yI/9IUc/0PfxZHEFTeaJeMzhn5buy/zLg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=octane.security; spf=pass smtp.mailfrom=octane.security; dkim=pass header.d=octane.security header.i=@octane.security header.a=rsa-sha256 header.s=google header.b=atEWNSbP; arc=none smtp.remote-ip=74.125.82.51 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D042606A335 for ; Mon, 30 Nov 2026 08:06:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9D042606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=octane.security Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=octane.security Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=octane.security header.i=@octane.security header.a=rsa-sha256 header.s=google header.b=atEWNSbP Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-1b3b4944a0eso7277753c88.0 for ; Mon, 30 Nov 2026 00:06:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=octane.security; s=google; t=1796026017; x=1796630817; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=00ZnVXtvJdbQ6EFCvIdd+vEU62B4FcKLVFM1WP60avk=; b=atEWNSbPXoclVXU1EcArvS7Z8DM9YOk/oQrZYc2S9zExPekIpycIMbfU67EPJSN9P1 hfHYq8tHoLJanhItw5d5B35OukolR7Z3Mv9zVVzGz/dbSP/yWe2QGJd11hfG5C7X3814 qJxlYX58xob4Hp6h5ixTU4BwnFsv6BD6hQk3x7qjYTyKarYxPVcaYMgXmTrZEwpzJsRj aZ8y64EITI7G7gmaQ2TZT0wN8hUKkZChopyPwPZwgKjylLyXFyVcIilqnZ+R6r7FXXji jUh5AOj1/T6Qr9uRqUwl4m8jifU8WQF2/XS/NER/hPevXDVDe+CLUpDz2R/seZfQEEEg utrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796026017; x=1796630817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=00ZnVXtvJdbQ6EFCvIdd+vEU62B4FcKLVFM1WP60avk=; b=KtQs+09G4nnlY+6WxwulP9y51IO5dRAJlfk0nAsBgw0OUjD6Rxi8d40bqDAXGH+5I7 1NSuGblTylqz8SS5p04kxPE7k2ctMI+/2OC2sljBu1ul9Od45bNwYztY7rz9rWMQTLcD uR953s3ajCT0O9P9AQAKewcXFA8cDtmCG9LqkWrUTIgcNNmG/xFqdbQiqgRvl4dd9tGP P3gmVQRgh+8H8kLult/UGtkAq8QQymdkejNlj4uyFXZNb9f9r7r1IeC/zelLZlYaQVSQ /8wbXMnM2IZbKu65S/DNTV2Ok9RNz9UoRzvKU+Ijp6HIDZlvdjwaIphtqWUuEZeJpE52 N/eg== X-Gm-Message-State: APuU4Z/o6zrO636+NRFalYZD7O46YJoSsEl7W2FjbBSSHbSdUEj8pMNS VKDDciPDkLhx0pExS2a//wXIHq1+VG2Eyc1YiI8tVwOZJvopCv/Nij7msDRyF9cjuiJo596S7/C 0TAeG X-Gm-Gg: AZFdTZflMVPBh+b64ikXqWBt91iB+3RfnHFaMqCbBo7Kqd6YxxfG2KiwzX/fdOTU+R0 adO3Nyuzh2ei6DgZJ/8gdGbe/ms/7JFzp+heef3FO1/R5Rf5wXVafgKM7LyozA5mr8grelVk/RS edjG0z71dBxSKGsmmlbxveXxPD1eIWJfVyZM1+nuw0B3KhBGRZoHA7YZvNCGQCJ35utF2vRZyAl VubZCEfea9Lnr9EcQiczR03XVVV/+TxkM6fdDgz99lhNwAgkIj8D6R7HHKrPu135Vdv8lt5ocVx HwXfIPxBh1ELzdwJUpF6rVxF5EtgNFF5mpLd53BGvbhX37U+UED93AWbyp8GfZwb1tQ+OUgANPX epbHItMiMllavmvKdeQcZbR4Or4zlvMLO8Fi4+aUjVwICd6qNoBrekmUSt9RXESe/lzVRZRm4M+ jaMYIRhBq7F2k0veuHSaCYc81/b0ueOwOUzYzuYLxIo3KytxpnyG5PvJXBS+FpkraiSj/hIYyzh RfHTyFKJZMJzMN0wKEIs5L7h8SLFNNLqAxQXnv80Gj002ut3iH4PeOBls6pNLMJ1of4IH8dcl5p Mdg4byB+kdZJvoZUHLFL3A2wSveScA5xqLa0RDmtFLYFAEi1YswipkwGQKw+FySsV4lcSZ9oBgy yujRBKWrr1TdQCbOGVgIL1yXzxDneMn2bncAG60ql8WB3AOO3f4aBMBySS+hByPOOOfZ+FSI= X-Received: by 2002:a05:7022:23aa:b0:144:fdf0:9d91 with SMTP id a92af1059eb24-1b5568d73acmr38205682c88.24.1796026016503; Mon, 30 Nov 2026 00:06:56 -0800 (PST) Received: from localhost.localdomain ([103.47.169.47]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b556829d31sm123533184c88.9.2026.11.30.00.06.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 00:06:56 -0800 (PST) From: Shubham Antil To: netdev@vger.kernel.org Cc: Simon Horman , gio@octane.security, David Heidelberg , oe-linux-nfc@lists.linux.dev, stable@vger.kernel.org Subject: [PATCH net v9 2/2] nfc: reject overlapping firmware downloads Date: Mon, 30 Nov 2026 13:36:45 +0530 Message-ID: <20261130080645.60464-3-shubham@octane.security> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261130080645.60464-1-shubham@octane.security> References: <20261130080645.60464-1-shubham@octane.security> X-Mailing-List: netdev@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 nfc_fw_download() marks an asynchronous download active before calling the driver, but it does not reject a second request while that download is running. If the driver rejects the second request, the core clears fw_download_in_progress and makes the first operation appear complete. Check the state while holding the NFC device lock and return -EBUSY without modifying it. Asynchronous completion remains lockless because a driver may report completion while holding a driver-private lock and the start path invokes the driver while holding the device lock. Discovered during an AI-assisted source audit using OpenAI Codex, gpt-5.6-sol. The overlapping-download condition was reproduced at runtime by issuing two NFC_CMD_FW_DOWNLOAD requests to a pty-backed controller. After this change the second request returned -EBUSY without disturbing the first. No production incident or pre-fix kernel warning was observed. Patch development and test planning used the same assistant. No physical NFC controller was available. Fixes: 9674da8759df ("NFC: Add firmware upload netlink command") Cc: stable@vger.kernel.org Assisted-by: LLM (OpenAI Codex, gpt-5.6-sol) Signed-off-by: Shubham Antil --- net/nfc/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/nfc/core.c b/net/nfc/core.c index 91b3274da..b03b34b40 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -48,6 +48,11 @@ int nfc_fw_download(struct nfc_dev *dev, const char *firmware_name) goto error; } + if (READ_ONCE(dev->fw_download_in_progress)) { + rc = -EBUSY; + goto error; + } + if (!dev->ops->fw_download) { rc = -EOPNOTSUPP; goto error; -- 2.54.0