🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8717

[PATCH net 0/5] nfc: fix HCI over NCI and NFCC loopback response handling

#8717
From: Joas Antonio dos Santos
Date: Thu, 29 Oct 2026 23:17
60 lines
13780 bytes
Patch 1 fixes a regression: since commit 8265a626cc14 ("nfc: nci: fix
double completion race in nci_data_exchange_complete") every data packet
received on an NCI logical connection other than the static RF one is
dropped, because only nci_transceive() sets NCI_DATA_EXCHANGE.  That
breaks HCI over NCI (st-nci) and nci_nfcc_loopback() entirely: every
command times out.  The commit is in mainline and in the 5.10+ stable
trees.

Patches 2 and 3 fix the handling of the stored response in those two
paths.  conn_info->rx_skb is never cleared after the response has been
handed to the caller and freed, and a request can be completed without
a new response (an HCP event or command received on the pipe, or an
unrelated NCI response).  The next command then reads, modifies and
returns the freed skb, or dereferences NULL.

Patches 4 and 5 bound the controller supplied pipe ids used as an index
into the pipes[] array in the st21nfca and st-nci load_session
handlers, as pointed out by sashiko.

Testing:

- Patches 1-3 were tested on arm64 QEMU with KASAN, using virtual_ncidev
  and a userspace NFCC emulator, plus a test-only ioctl in
  virtual_ncidev (not part of this series) that drives
  nci_core_conn_create(), nci_hci_dev_session_init(),
  nci_hci_get_param() and nci_nfcc_loopback() the way st-nci does.
  - Without patch 1, the response to the first ANY_OPEN_PIPE is dropped
    and nci_hci_dev_session_init() returns -ETIMEDOUT; with it, session
    init and HCP commands complete.
  - Without patches 2/3: slab-use-after-free in nci_hci_get_param()
    (HCP event instead of a response), null-ptr-deref in
    nci_hci_get_param() (no response stored yet), and a
    slab-use-after-free on the skb returned by the second
    nci_nfcc_loopback().  With them all three return -EPROTO, normal
    responses are still returned, and KASAN is quiet.
  - tools/testing/selftests/nci passes (8/8) with the series applied.
- Patches 4 and 5 are compile tested only (W=1); I have no ST hardware.

Sanghyun Park's pending "nfc: nci: Fix conn_info use-after-free" v5
touches the same functions in hci.c (it adds a NULL check for rx_skb,
but does not clear it); whichever goes in second will need a rebase.


Joas Antonio dos Santos (5):
  nfc: nci: don't drop data received on HCI and loopback connections
  nfc: nci: hci: consume the HCP response exactly once
  nfc: nci: consume the loopback response exactly once
  nfc: st21nfca: validate pipe ids in st21nfca_hci_load_session()
  nfc: st-nci: validate pipe ids in st_nci_hci_load_session()

 drivers/nfc/st-nci/se.c     |  8 ++++
 drivers/nfc/st21nfca/core.c |  8 ++++
 net/nfc/nci/core.c          | 18 ++++++--
 net/nfc/nci/data.c          |  9 +++-
 net/nfc/nci/hci.c           | 83 ++++++++++++++++++++++---------------
 5 files changed, 87 insertions(+), 39 deletions(-)

-- 
2.43.0
Technical Details
Message-ID: <179331585573.30322.4049957541187612575@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353508-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353508-linux-kernel-netdev=dewy.ru
From: joasantonio108@gmail.com (Joas Antonio dos Santos)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 0/5] nfc: fix HCI over NCI and NFCC loopback response handling
Date: Thu, 29 Oct 2026 20:17:35 -0300
Organization: Usenet Network
Message-ID: <179331585573.30322.4049957541187612575@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2119550"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VH+qVgoXz+Kp1X0kC8fae+BynOM= sha256:vtSoDzC5jvQmFpN+VBZr1zjD47DnIzbtxmiuwtD0wj8=
	sha1:Tvs4Kx2ShHcptxLJGjAhQ6foeXY= sha256:K7S+7rfC2PWD9ZPn+oBJqHUR3zQuj2IjsaW62hjcq2o=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 0D6A1125C7D; Fri, 30 Oct 2026 02:18:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id btjpb6T-9EqN;
	Fri, 30 Oct 2026 02:18:10 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353508-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8127C125C77; Fri, 30 Oct 2026 02:18:02 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 2CAEF279BB; Thu, 29 Oct 2026 23:17:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793315869;
	b=JQIBvvkMhZcsu9kCAOXmMsmrC+sVAn8IcAHSO009O0ldmW+H+6TJU7iqthAIUp2qYO8W
	 rzFXiHlRVAGxFw7sWyG1CeC8EOqLxmLjRYQg2DsqAMchWMisyev5v8tdb9wRaDAayAIgB
	 8X8he6v+h/NXzIHirJ9Yx1PATbuGkvklrDyuQRaT1bnZaGSVnhu7knWxX+nADfN1+9TKK
	 1Bqlu5Wdbn7zOlOh2Q04nERtHL0tX8wNwxajePGHzCJWV98+UtHO3ojeN+PZYDiLeU4Qz
	 AdIJoyV3gCKx3o3iy3wa3tWpAoO8SPtquLGc1zAid/FuzU+VXFeJkehkMcpPdW9Yymg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793315869;
	h=X-Original-To:Received: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:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=SPEnqdGMpTzdZwWJhFlJuppIlSs2KDhs9MBrZg5NKrM=;
	b=X0SvkAv5m0X1ccZfdm5Z5aEOY3X/WkmnDlz9SFifPszeW2B26bIt0XaoisOTuluJDyI/
	 WofhQTUtDgbRJ14S1xhZ61EKKm7b5fwLJqRHX/HQh1IfyIIzM/+PkcZR9mBfzk68X/HCw
	 KY+tMtPRYTdlmHQvmX2to+0AYAicBSjopkizMRjeJEtHQ63N+RQ/8TQD2e0RMa3SgLiZs
	 fEfSrazDwj7nuoBdhMCVz0YiAmJv2CywUnpyy1x358yAT2LUYmC40Se2i4kmfCG/W5dSL
	 lL+JjBPTTlJvb2YDzRA7l6RPYX8gZcz0k/w5fDl30dCnAvhLNfgpSGYOKLuHvkQEdYw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=JgtgeSBl;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 31F18606A329;
	Thu, 29 Oct 2026 23:17:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=JgtgeSBl
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.217.48
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793315868;
	b=FmuwhZEylFeeH+7x/GINMUamtJjTpZeJoo8zYSj8MvVttS4ptbiS/ij+ynLVq5Tf8LGr
	 OFt2WNuowXImMOaD7zjDv8gXfwuam3DefQSxQ+0rfAndwETE1PJ6mw2QY7hdOkTssCNbm
	 V/xDzcKJV5Xwom73KsoPg9EOa4Dqn/wZmUZhOM7XYSH6VVO9bh3PThzjZEfpLgOaiilW4
	 7Ix4g5TKrm2WmuThZ07WQQW3jAPPLT255FM1aAFdV9LuXXuL9x0JhuF/dFJCaYSEBrx5/
	 bmZ4lCY2mCMdHKBys8EHUeMMRlGciiLCNSPC0ce7emhP+skK06yPir3EF+DTa3mGFrg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793315868;
	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:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=SPEnqdGMpTzdZwWJhFlJuppIlSs2KDhs9MBrZg5NKrM=;
	b=Tn11CQTI0UhFthxtyd2afl5z197FzMPJf/doFp26+ZwR9j5YyGc5+kdjJ59krv1s09am
	 GjYfqrsrs6hMvd/M1FmbULrTrUaPqH8KjKdqATcBPO+mMFITY+36IoSV9LKBJab2Q/imw
	 NRmU83B17/hW1YubtUlB8d5OTp8mmrAETymD6YMkhXFvAIfseaWLIHEEUVBYTikPWyN/3
	 OacGxNCUfcZxocfYwCggQWyPfpzHGZHiQFCg5f+WEvoZni7ZmCiBFuPk03hbRKJsUU+/8
	 yNNJpGWddRy/HhwI50RTkOLQnprDs/YiBXzPmDjqI0zOR7ttflQarixBO4hKIBZU7Og==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=JgtgeSBl;
	arc=none smtp.remote-ip=209.85.217.48
X-Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48])
	(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 EBA20606A31A
	for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 23:17:47 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EBA20606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-vs1-f48.google.com with SMTP id ada2fe7eead31-7cc7938c5e9so554353137.0
        for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 16:17:47 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793315867; x=1793920667; darn=vger.kernel.org;
        h=mime-version:content-transfer-encoding:content-type:message-id:date
         :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=SPEnqdGMpTzdZwWJhFlJuppIlSs2KDhs9MBrZg5NKrM=;
        b=JgtgeSBl1A7EroYa9zlcO4q0XImL4eeq0uiOQ2b1D+m1V0uKjVyJcBYS5048FZ1L5T
         k1aWaHOiNeL63eNOHDtyvvSLIE+b/NWquOve2n9Mbm4aMUSjP/RFZtj3k66C5xfxrvdC
         gz3Dq5w3PNbWZTsQF3k3OLcoWKUvMMK0zc8/woQF2wgrx/r4XwZVEraLlejkW8QqUzKe
         SKBI+WVYxptAPkhMlXaCq/r8fswAkcDbVmfPIRmlFqb5Xbad0Y7ObPEv9OSkvoQASpF2
         ZPNe9b7e6BtDI/3Q5S74dtF9vqaaRimjVbb8xYcC3ARaHnPGk8IJB3n/QXsL4st5jnD9
         JETg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793315867; x=1793920667;
        h=mime-version:content-transfer-encoding:content-type: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=SPEnqdGMpTzdZwWJhFlJuppIlSs2KDhs9MBrZg5NKrM=;
        b=Ms3Iw07eSkSPNe39d9wCbMlJ+aiog6CER00RLzxgkc1N7DOtYDQxEdnrJOoVfrGLML
         PvgnjeORtlwqFUm8RSkkq7li9Smyt5RfPDP6SrTIVTmCCpnqsf9R2uKk0bgdQMeuQ9iB
         5jO+OGR2E8p8pyTbwGRVCKsIG3owqe4uUFrlY00q8Wi5T94jIX+E6VpiWBwtjs4DI0PD
         OIug6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b
	OwdVS/AJCUIQa
X-Received: by 2002:a05:6102:950:b0:7c2:b741:2391 with SMTP id ada2fe7eead31-7d0542f8019mr1629209137.30.1793315866785;
        Thu, 29 Oct 2026 16:17:46 -0700 (PDT)
X-Received: from [192.168.15.16] ([2804:1b3:a2c1:77a1:5cd:8fee:f3c:4da7])
        by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-992ee4e7453sm319509241.11.2026.10.29.16.17.43
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 29 Oct 2026 16:17:46 -0700 (PDT)
X-Cc: David S. Miller <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>,
 Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
 Simon Horman <horms@kernel.org>, Zhenghang Xiao <kipreyyy@gmail.com>,
 Sanghyun Park <sanghyun.park.cnu@gmail.com>, oe-linux-nfc@lists.linux.dev,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list