From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796043783; b=4l9kSfqXAmI1+O55iEgt1PuduYwL9bmSOMk8td7eGdvox9GdMAYxD+AynG72PwUwzCLB yi1KZWdSEZo/0uqnWF7YfWNK41/o6eolBTlF66kx2wgV1xymfoqD00tSBYDk/iLHmy33k AAosQMYDh/wZNhhp1+Oap0R72e3woJ/5+7ERr0IefKFRcjTdM+jSmjdmi7vXLXeZvxRKZ eirBCgA/Rq5AJlDBsHr0WDEYt1V+nXvswsgczT81DgGB0SrXn4phOsH9YyAAcOudkBKBJ KJiL5o2dU3eQDPjoYiznidR6Fcdts6Hnpppm3hMYHmbO8Slx0Z4ly1M7wj6zq7R6fyw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796043783; 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=pKh3fDF448vXT4S1yjcEXsEAWojxWWO6ab1YoYhGUVA=; b=vtaFB4sGc7bUFtKh9vkqAB0OnZ5YfOHPDqpWw7dGHdv7S/+hYBt6LtGx1Fb3/9h03K2F 6m63heWjZ6Q6DA/kR3C1H5KQdGTNGifVpFP/8uPEa/Uow37VKlYph5wbulqI//5oWDj6+ Xcwgq+BjiBLzGEHNt/hM9XfRLSn4BSHR49R6lLU9jl6ZIt8tV9rUn/G3mmbtyeVaGIkUc teNiz5080Oux4WNJ5RLj4Go2rr08oBkSZmQ2RZfLAPM1194QVDzhJLDkBDLkl0GEk0Vey SXiWA4V7+zgsPmPmwf7kIieLbHws19GpqNo/bDFgSuxLk+Cmk/ymwfxyYY7/VRHHTlw== 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=C5yH4C67; arc=none smtp.remote-ip=74.125.82.172 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (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 3306D606A320 for ; Mon, 30 Nov 2026 13:03:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3306D606A320 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=C5yH4C67 Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-385d8a00598so18009563eec.1 for ; Mon, 30 Nov 2026 05:03:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=octane.security; s=google; t=1796043782; x=1796648582; 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=pKh3fDF448vXT4S1yjcEXsEAWojxWWO6ab1YoYhGUVA=; b=C5yH4C674zOBhsYiBO0HvnbGg13G04AFABNFEuhOsgfye/kYp2hEsixgWD2MXXPYHc lnwj++r+0yqsongkcnJ30Xr8tCnewf+YT9lKXhSYMJUtyQbxEzo4UyCKbmywnR1AvH/7 21mWxZphPMoH3BifUuU5+dA8+enD43khG1k383DhOkCKCNRX+PRULjdS+IhsL7+mbrIg YhyMoR6UL6ocxIDVgUT+dQrtwCscXMX5VzyqvyyQw68r4b4hU2AKg9xRTJsZn9e8dimV neJP6CiEg9eI6vmOIKPez5bY1SnSasK2csxwi+aCg9l/A6fKTWOOZDH+RMNZKtRd5WYX mGyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796043782; x=1796648582; 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=pKh3fDF448vXT4S1yjcEXsEAWojxWWO6ab1YoYhGUVA=; b=ReRCG8ypE4iR1vn7zqVQHIgq5WwY5BcNr45mlT0RxQR5lGAzmArCQxQwnr5BYLQwF7 zxciLeOu+4QS9QKGBH1JoU9i68IHUDJzSoSTf2wHiUU0cbVEazbdBQBhhBJThu0RRHT0 +OliWKzklyhpqIC2567SaixomePCAXlZBe/KZKZeqMfsnL2N5ntP9XPYlUuyIKPEvu9u PveYDo8UrgwaPbTR3t0IM9RrRwYNqCoExtmhtJxzkBU1GKx5TX+xVAQAbqA66NCJD2uw VICW0mPQaahQIwMwCqL8I9Bgj6XCOx4mbMFM6J9tvLDS7pZ8p9wyz6VldV05oaoqmzn0 rLoQ== X-Gm-Message-State: APuU4Z8zQzeNuAyTx8/Yc2SwmPh7eEeXlZX0Fq3RZbMkaKxlHQA/WrCR l1CGeExh9hz38O1IWOlq9P1v3LsRFsnLR23Zd5h1bWKlxdGkwUiEnbKUdhAEttea/hmHCYArzxh ovOFS X-Gm-Gg: AZFdTZcIJcuqochBzXL5hUKcNLuYgMPwlcfLdHlGBSb4qjVkI/eYK4DRmAwbCqWxwkh khm9j8HGQ+SrsP4SA/JM42Cq4q3qakelvD2Ral9RH5VVgXDqGu7Bq/nkFrCCVojeWI36FFrguwf kos1oFjH5pynnUgomJt7UB5kz6Sav0zUE9os43atQF9KQVnT7Mj6hW7t060VH4pJaI3q4+bsH1i P3bUsQaqDEd+PSe2dCSWzHI/JfCoKNjTyjM8ZnxXO4AWxrPrzM2Z8W1rTn5ipnLwSiPFLSU602b ybzvILK7Y1AI7n/kMQ86AkeaX4Oyg4hyBGFmGtasaGTBRRH39chCnMIHTEOxrg2+pWhco0IaR0m hxYSZIDZEr8k9jw/C1fpS80xzlUp3PXpWfLWQBRtIuyRxllHSkNjd3mD4gFYI8a+5dMPJuI/ieS tDZXAdOJbiepgMdDjujkNbG60JazlEF+1s6/TyhI1EJ17EA3P6gU+oSj6ltG5mXRHTcmEAiWYQ9 zD4CwLCFFBasxrclZ2z5eQ8ndGIlRP9jgV4hs1ArKGgfL5j2+OIz6K5kpzOclqMLsmkBp1MorWy YZC+tF6PNHv2SiDI2jmunzfYiRHBdnzkrpHDHmFMPLpaQR0nDCENs2+Pu9OzGB9xtHEhxuPyDOw hY+grcv4YCLuvk/ldMv48AsvDIe7Dbu5ZV7egn2uxuSODYJbSXsGlyuSrIKUD/7XXp4L5ejg= X-Received: by 2002:a05:693c:83cf:10b0:386:b526:24d1 with SMTP id 5a478bee46e88-386b52638e1mr24637183eec.9.1796043780619; Mon, 30 Nov 2026 05:03:00 -0800 (PST) Received: from localhost.localdomain ([157.119.125.90]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385677c0c1dsm111829929eec.21.2026.11.30.05.02.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 05:02:59 -0800 (PST) From: Shubham Antil To: netdev@vger.kernel.org Cc: Simon Horman , gio@octane.security, David Heidelberg , oe-linux-nfc@lists.linux.dev Subject: [PATCH net v9 3/3] nfc: nfcmrvl: abort firmware work before unregistering Date: Mon, 30 Nov 2026 18:32:40 +0530 Message-ID: <20261130130240.65411-4-shubham@octane.security> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261130130240.65411-1-shubham@octane.security> References: <20261130130240.65411-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 nfcmrvl_nci_unregister_dev() destroys the NCI workqueues before draining firmware receive work. That worker may still submit NCI commands, and the later firmware cleanup can release state the worker is using. Abort an active download from the NCI shutdown callback, after core admission has closed but before its workqueues are destroyed. Keep final firmware workqueue destruction separate so unregister does not execute the abort path twice. Discovered during an AI-assisted source audit using OpenAI Codex, gpt-5.6-sol. The active-download detach condition was reproduced at runtime by starting a firmware download and removing the N_NCI line discipline. One hundred immediate detach iterations and timed completion-boundary modes were exercised. No production incident or pre-fix sanitizer report was captured. Patch development and test planning used the same assistant. No physical NFC controller was available. Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support") Assisted-by: LLM (OpenAI Codex, gpt-5.6-sol) Signed-off-by: Shubham Antil --- drivers/nfc/nfcmrvl/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/nfc/nfcmrvl/main.c b/drivers/nfc/nfcmrvl/main.c index 6efa83219..7677bcaf5 100644 --- a/drivers/nfc/nfcmrvl/main.c +++ b/drivers/nfc/nfcmrvl/main.c @@ -67,6 +67,13 @@ static int nfcmrvl_nci_send(struct nci_dev *ndev, struct sk_buff *skb) return priv->if_ops->nci_send(priv, skb); } +static void nfcmrvl_nci_shutdown(struct nci_dev *ndev) +{ + struct nfcmrvl_private *priv = nci_get_drvdata(ndev); + + nfcmrvl_fw_dnld_abort(priv); +} + static int nfcmrvl_nci_setup(struct nci_dev *ndev) { __u8 val = 1; @@ -85,6 +92,7 @@ static const struct nci_ops nfcmrvl_nci_ops = { .open = nfcmrvl_nci_open, .close = nfcmrvl_nci_close, .send = nfcmrvl_nci_send, + .shutdown = nfcmrvl_nci_shutdown, .setup = nfcmrvl_nci_setup, .fw_download = nfcmrvl_nci_fw_download, }; @@ -181,8 +189,6 @@ void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv) struct nci_dev *ndev = priv->ndev; nci_unregister_device(ndev); - if (priv->ndev->nfc_dev->fw_download_in_progress) - nfcmrvl_fw_dnld_abort(priv); nfcmrvl_fw_dnld_deinit(priv); -- 2.54.0