From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796001740; b=4PCRUGPcH/Oo/la3cr0uSiRD3Yl15fIHOVq3KxLBy8BIQK1qGw6s1nPKvAFWuw7oILDN wu/A1rXX5BHPvGJCZqdSfq9V/y5NnYtbfJRi+2v7RMBoYDo6jeQvdovmfz+E9+DuziCeD OK5aqlNGRRYmdPJ6DDT1Cm9X9jwm0jPXsd5Equ8bAK3xOHXfpvmSncBy/yZS5kZD95z6G 5gbBLoewSBUtccAhqTBCMmOCejJhcpj/ReuAy1umdf8oXx9W5EaoVgsYGBv2FHMc9gGXY lDd/gtyWvp0ZG1vDQ2HA6C433HOMxiSLbVeIURSURadss1yIcGKNaSRIVXEp0SA6uiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796001740; 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=8usuiBkBLQuX2QaU3sJw/rxdpxVrTo1BEcmdqUbYzsE=; b=aQmSQTKHCnTKHJB1/SViIaFlk/Lp2AUXK2coVCUqkZXlrnvQwJI5Oy/2tcN1bOatypyq PgWGUWFAm4DB251Qam0CJ5Rd1c/VgZDstjIuFiDPbZ9rvLAh296WbG93mSYsaOuPM+7kJ inHLzg7w8rJz5emNMVMjxiQGbNPV6UMwSH1z8ZDL47crP6VAfrGEK0d9uJ/tOol9UhPmt 5WiUvMCfhDlVUo9GZosaLCLrXbE0u5qOQM9O8XiSi5EbsuO7qMoywdJVk8lITd5lkVW7w yI+map/zUVBBXQKPeHmYreHaq+o3eQI2gUcHwAWuGNVNVyoah+Ljp+R4lbQ2sZzHYGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=iiitd.ac.in; spf=pass smtp.mailfrom=iiitd.ac.in; dkim=pass header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=DjDCtfqu; arc=none smtp.remote-ip=209.85.214.173 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 C522C606A333 for ; Mon, 30 Nov 2026 01:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C522C606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iiitd.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iiitd.ac.in Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=DjDCtfqu Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2f048476ab9so68365955ad.0 for ; Sun, 29 Nov 2026 17:22:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iiitd.ac.in; s=google; t=1796001739; x=1796606539; 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=8usuiBkBLQuX2QaU3sJw/rxdpxVrTo1BEcmdqUbYzsE=; b=DjDCtfquBA8ONelgOKdsfazKAOsr1ThIRDzJ4JS9H+03FUmBABMrg+FTqv/ZNzUaB2 klHrLzjzraEkUWNmYQmBWvQGzU/7ot1WWjmZlegj2Xk0amk9vxQoLIvp8oflp5iRhjH+ 3SogWLYJIw38aJSRWvR2upGASiYefcZf5ipcY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796001739; x=1796606539; 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=8usuiBkBLQuX2QaU3sJw/rxdpxVrTo1BEcmdqUbYzsE=; b=EzYXHjO9m1zxvD73PA5OYuX9OdqxNhUTj9UDSuF5BN/WilWGgotB9+hyOy2ebOecGU 88zbs7LVh6xoMEB4oNhkOqXpH7zC1pYNfAGYMCJs1rKWwT1kwDtzfn8jfPweicJPCfhF doI0Ncj+7b3i017507JBF5lzCKyrzSoqV3DG+WyJueoye79VPbMNHQyKMWodVjFrQY4k r99KyMWQ+svYDKHRUkWco0Gc4+/+frg6hJKljYC+AhFPHcBw1XBivC8wJ6ScANAkpodI MYITLULkWQ+9wUdYWbv64iKB/+ItB+WfQihUZ60aNAOPZ8AqEL3b8uA1lCxMgPT7Ob8s 6f4w== X-Forwarded-Encrypted: i=1; AL+hErELjbLhv2v0iBwrSs0jb2M+PIXTrOVnKy82HvPSgqcOZEx9hLlXO9P2SKfT3xTM/8a2fNmT6jid7nPL8A0=@vger.kernel.org X-Gm-Message-State: APuU4Z++R94AL+YYc2eX3QVLipgpWP1pGhGOgTq3v+iv8DYdxZmBaJk7 T2dMwDdtuDs+7X/3Q4+CMf+Kbl3QkzB9MRpmtf70yFNywLadqkkU4k4Ud8/t/JWWTQc= X-Gm-Gg: AZFdTZeYbOtMZOWozCfeB8A5AQOBQf6O9qu5G6l6RYWSQJHuD5BI4HwTGVNyjmK3ind 7smnqTGIGow097DYKhw7+phxeEsCSNL2uX1y325Sx30xIylnDKPmiGhm6FtKEXAMyS4ZmRua8+y yIkD0OAJMt05tSrLYfs0oNN0MFSo/DNHu7mkB4tkyNobg1QKCKLuga8qc7JfRi6BB9843ncwyG0 zvuvO3xujoXUm+iXbjS6ZQ2OYVftcwiEbcovhPKHlfeoEwjouU+mvgDDHJJM3Nxt+/e7RSJwTh5 c0Wodi5KyAgsoxf0ihuzchypY/eVrguYWyHuThLG8jwKdsS26kgSK4WS8HNe9yMS0uXRoYJ6wTw eHnAAmKv5AHLNtM6RFyLa+7YxaVWaJVJNIGB5S8zN1oZw53UcZrTByQe56dExkdMw9Z5Q4PSRRb HB7hsPFXE3p6Q/jZWl48gKoDsP/4F9qCZvgEgyyL9OtZMJzj2AC8lN626enYo7JSsP24SYyAXnp sZX9dnR+Qge1M0fxQjbKhBrH8GGPBNJTAUJoN/uBZHeyi47GT4E+LLEaVKfBZC96mY0vXWsOjZx PPoQ4OZH+H4zAnvQarUczBbg21OZGg1ls9BVBim0MJ/FJ71W00O1YRscQ5cPopNaJMAFpa+j2ow JkrHQx56LfJbRCCDHnq9BKGPIkbgX4v7sv3JmT+TxJFZfbW1NKOYPe/z4ZPgGb3cro4QGolncRf 4E1R7KxJ8FT+g= X-Received: by 2002:a17:902:da81:b0:2ed:cab:e973 with SMTP id d9443c01a7336-2f03f0fbd8dmr340472885ad.13.1796001738844; Sun, 29 Nov 2026 17:22:18 -0800 (PST) Received: from iiitd-S2600STB.iiitd.edu.in ([103.25.231.160]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f0bc695f31sm98858205ad.49.2026.11.29.17.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 17:22:18 -0800 (PST) From: Piyus Kedia To: David Heidelberg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman Cc: oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kapil Vaswani Subject: [PATCH net v2 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb Date: Mon, 30 Nov 2026 06:52:06 +0530 Message-Id: <20261130012208.1962491-2-piyus@iiitd.ac.in> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261130012208.1962491-1-piyus@iiitd.ac.in> References: <20261130012208.1962491-1-piyus@iiitd.ac.in> X-Mailing-List: linux-kernel@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_llcp_allocate_snl() accumulates the allocation size in a u16 while the length it is given is a size_t: u16 size = 0; ... size += tlv_length; skb = alloc_skb(size, GFP_KERNEL); nfc_llcp_recv_snl() builds one SDRES TLV for every SDREQ TLV of a received SNL PDU and passes the total as tlv_length. Each inbound SDREQ costs three bytes - type, length, tid - and each SDRES it produces is four, so the total is four thirds of the PDU and about 48 KiB of SDREQs drives it past 65535. The sum then wraps, alloc_skb() reserves a fraction of what is needed, and nfc_llcp_send_snl_sdres() puts every entry of the list into it anyway: hlist_for_each_entry_safe(sdp, n, tlv_list, node) { skb_put_data(skb, sdp->tlv, sdp->tlv_len); skb_put() runs out of tailroom and trips skb_over_panic(). With 16400 SDREQs the accumulated length is 65600, which truncates to 64: skbuff: skb_over_panic: text:... len:382 put:4 head:... data:... tail:0 kernel BUG at net/core/skbuff.c:215! RIP: 0010:skb_over_panic+0xcd/0xd0 skb_put skb_put_data nfc_llcp_send_snl_sdres nfc_llcp_recv_snl nfc_llcp_rx_skb nfc_llcp_rx_work process_scheduled_works Hold the size in a size_t so the value that reaches alloc_skb() is the one the caller computed. A request that large may now fail the allocation instead, which the existing IS_ERR() path in both callers already handles. How this was found: by AI-driven fuzzing built on top of syzkaller. Its analysis was then checked by hand against the code, the fault was reproduced on net.git main under KASAN, and the patched kernel is clean on the same reproducer with ordinary NFC LLCP traffic unaffected. Fixes: e0ae7bac06cc ("NFC: llcp: Service Name Lookup SDRES aggregation") Link: https://lore.kernel.org/netdev/20261123023548.3351531-1-piyus@iiitd.ac.in/ Signed-off-by: Kapil Vaswani Signed-off-by: Piyus Kedia --- net/nfc/llcp_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c index 80a00938c869..0a3d66e6cd59 100644 --- a/net/nfc/llcp_commands.c +++ b/net/nfc/llcp_commands.c @@ -542,7 +542,7 @@ static struct sk_buff *nfc_llcp_allocate_snl(struct nfc_llcp_local *local, { struct sk_buff *skb; struct nfc_dev *dev; - u16 size = 0; + size_t size = 0; if (local == NULL) return ERR_PTR(-ENODEV); -- 2.34.1