From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796026018; b=L2WC70KwS9xFklYhEnf6/Ayr8bPvTkTgckT0eAEDtoJrTYGhOYnCvVrKGhnu0CndssAD OtTJolT/mCeA1fMlSUE0OFcw1mspTVZv08R2VJjoOWXWwqoETKPAABrUJ1pxsWpBcL0ld ON5bBC1AtBpV+bwbxlGnwZdSKe+180fAF+9J471vIGY/kLEo0iSwoPjRjMSeE/nggx76j 7jra6BFqdE2c6NPpnYVl+7xUorExRt5Bmtf1JqF+vqUQCD9H4kZJwah0ZGVHaW8uPjUdH 7cmJs+JmqzRWLX9RvsUCAYpOWa136u5Unbvs5Bva30VKP6p+IRJyxDDqWwRD7yJPmYw== 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-Forwarded-Encrypted: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=1BDiVBpznmNPeHEtWlLWxFs2aYV0xVXIqsocHt9LyBjQU8WMJ6EwyznjCEjVKJ3p/Yoh PRas0nobaiu5Vc2KODIwX+q1JPoi2+fCnRpnYwsLvAIhSWMQra1EI5SalHyipkQTFGMfM QtJLphYvXBhAG5mUBIFvUqC+gfwJkUvZG6U6XN5iieFONKfDbH4JnbYQLM0aORh5pCMEd V9R1jl3RY9W3nUHG7kNiRl+MU//AjU3cY6ubkQVRihsIeUKqp8I9q/hb4j+c0B/YixYnv 60mYCCpw9mWQQFfNRaGb/o0YAPITa1xdBfR4qDuKkTHucnQipYe22kXlyIKOrMqr2KQ== 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.47 Received: from mail-dl1-f47.google.com (mail-dl1-f47.google.com [74.125.82.47]) (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 6BE0A606A327 for ; Mon, 30 Nov 2026 08:06:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6BE0A606A327 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-f47.google.com with SMTP id a92af1059eb24-14394530ec6so4887016c88.1 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=ZSL8GYuny8kG+KxGQ+Hw8MvbLERZrAAR+PzDO3lM75MFgk3UEgXOkliIAIW/Js1yHW sNjW27l4FWfJZRSHI8b73eCJbIbTa82sQ7uao1T76um9kDrS9Ar8LCD16xwCY9NTawBv Zv9mp1O0RiKNsxX3aMG23rwxInWKDDgRYOG0O7XKTuWopZlF7iVuHN7ehP5jX086WlTn kOXS2xIJUK/O6u0XcuI3aBKaswngYohoEpohfTqPJHqflXLeG8GnLIElT8wxaTDGugMx FqHHqGa8uoe+rDJnY2633UVexAs4jUtO4XUE51yJmyOe0sShymyyOg+JbnHIcDwjMeSb rL5Q== X-Forwarded-Encrypted: i=1; AL+hErFyzfgDQU85GBzqEDPyDNyqhX34lVJGvR61c4eqt1f6ybd/roTBDkEfeF+auIyfOHEZKwc/VzA=@vger.kernel.org X-Gm-Message-State: APuU4Z8vyzg/gOm6iL8B++iYbnstdf3fbrW+y6OAPnw9mauVsFZ3NweF BpkOwMeyOzuzeeDJnd97TzMK7sz3SoMQKFFspgNuQdQE+8NOLtGrfv2pqHPMwn8bq0M= X-Gm-Gg: AZFdTZfWeafBnLpF76bfUoApDR7R/tL0Cqa6F12p48C7bMis+1NlC2I8b6W8VzX640P uwHG5KHep+KzcY2Eb0uV41Bt7Algrt3pTeq5sYZYyRQBtpyirs6SLZhzMUeZgu53/sVBh6RVHeo 0vnBhF4xBIwerRoTWGLqM0Za4+3KxwMjpwiVOW0qoincuAPvg6A6z1pfHlsktPWO/SyXycicT+t lxyRczJKJVwkdBquBaek+YYOn0AF3YLJ+4Qnphsfuyo7+Uy6mmDl8QRLy+nrzcM+KG+Z7GNX77+ 3rc6C70N8tTc3le4jJLQNfYnSCJoReRfupzZpHYTHHhlGuzaizOXfTqaznDQhWYMrcyuabWQ7WW zSIz6EGDQ4k65qvG6Yj4XO7aTYG++WVtR3JyQzCteXa1I8yIFMtZ5giVgH456Ta57rexaoP6XHy 71ejz2owIYjUxcAR0fqNmmkZdotzvafLHZS0/m3rr9XXf1g9r8BMwjEV1AOd7GGHjb5mMxrWyvV aMErUJS+ayoRK8J8sxoVaCxKTOD4uek1ThCKf8MsSIR040Tks1Edmue3oPTtq0CJc+puqKhqGRo 9drwoLIwbgzFGXxsN9HEDzTCqMqtQPv9wX2IYpwrlnEmCp98NJkm4NMDZdWcU7IjH3GuN27yB7w U1gFCSrnjVPFa8bSGhMjTYtqSbpn6tLAcClm2oZOTCM6GLOn9g8672/UtY3hzJtT8CzzdaNs= 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: stable@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