Article View: linux.kernel.netdev
Article #24306[PATCH net v2 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb
From: Piyus Kedia
Date: Mon, 30 Nov 2026 01:22
Date: Mon, 30 Nov 2026 01:22
67 lines
12815 bytes
12815 bytes
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 <kapil@presceralabs.ai>
Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>
---
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
Technical Details
Message-ID:
<20261130012208.1962491-2-piyus@iiitd.ac.in>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373755-linux-kernel-netdev=dewy.ruReferences:
<20261130012208.1962491-1-piyus@iiitd.ac.in>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373755-linux-kernel-netdev=dewy.ru From: piyus@iiitd.ac.in (Piyus Kedia) Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <20261130012208.1962491-2-piyus@iiitd.ac.in> References: <20261130012208.1962491-1-piyus@iiitd.ac.in> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1301870"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:FhRcCcZ266bZTLfH5FeftW51yOc= sha256:f6oRx+TVJASC6tA/82fSw3cmQNUhJdRImhqVzjVjqqg= sha1:h0ieKNV1O4oHoOxYsAeYO+/Dcwk= sha256:FIg3KLHMI4UbWC8lTqe6QZGqM4t31ssfdfrt1i2YWyE= 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 BA4D6125FB9; Mon, 30 Nov 2026 04:22:41 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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 (1024-bit key) header.d=iiitd.ac.in 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 KrkPjZL2vV2w; Mon, 30 Nov 2026 04:22:38 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373755-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=iiitd.ac.in X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 17B6F125FB8; Mon, 30 Nov 2026 04:22:29 +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 BB652277DC; Mon, 30 Nov 2026 01:22:21 +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=1796001741; b=oJnrGnXJGlDyk8FWS5tyFSqPK5K5kMenFDtCHAa63lxWtMdKvLu2vRxCcR+bTcquK+Cr 5aXiDT9JXkweo+b+CQpU1MQloXnfYjvMVSSTYrJf4LXVi13NrzaLh73SvLde0Xukbvmh4 0WMOpJDaXLcbcD1yKR5t6Y+FNFRworBvfHDesfvgc/uzD/gaKurAFwhWsOSMt3Kde6hr/ LRzws+Shmqk2Vsi1XTaPtiI3IG8BcdudM+PagVPzqMT/C+lRaDs2JvZQafHto0sDK56Q5 g0mwKzaBiK46QCISz16dwvex5iZabMWR4uxgCs9me6VcSJOqS2/hT9eZAcYPjlXQQOg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796001741; 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: X-Mailer:In-Reply-To:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding; bh=8usuiBkBLQuX2QaU3sJw/rxdpxVrTo1BEcmdqUbYzsE=; b=neuzuZA0NPYgO96XY0msEumt7HuDt7ra7E9BjwL/gKtTQXTPqL3Vc35q7IyldRLzPZWV kVkU8ouH6x+Zp66jcprrECSZWsF76zGwpeltIdGPQB96XgUM/JBd1J5hHK6sABQyBe/VB iE+64FAL26gfQqK+kBqsUixDj8GhPbmJvd+xRsFvS4ZJD6YjGIcvQXSWqSGYd/tHZa47I 1YGt/7i4KnUFbmK1iaW9liPwMAe/egVh1L2XJu0qys+PoJWa524pWULRu6zUjFG6hot4i fjCpbRxM/W3bUF1N9GLbr9JDtAIAiGTNGlkI3/dHVfe+JjuxwTdI3IViW/etx12w1Nw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=DjDCtfqu; dmarc=none header.from=iiitd.ac.in; spf=pass smtp.mailfrom=iiitd.ac.in; 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 E5CBB606A339; Mon, 30 Nov 2026 01:22:20 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.177 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796001740; b=u9eLJurzKcU0025mRW4F4YCrhgZ9Q/c38q08lW1MBImw789RJwXY/cq9LJjdSREugtIv zN473vIMWhBwhGxzI0q5rKecs37AFrzRDS/djRXSV32/RrA2aAlWwwNXQFA8whRsSAroD rzEZE/o1cdb0Iycb138GabA9XLD+pI3DVhg+9mifkTK826ZnM+Qc7Sg7PSPtVGl8GqnOj LM+r/u9UKHhvgYBPQ/5BmeSstbziWp5CZiVF9TDZDHIoEK1RCblT70uqgfaxTMEZEnXGb 0o1YKf5Vjaz4fw9MSDddtTpz60vAWZtjl/Gy0Zt3GGfnstX25DSJOmZ+YS1Q/d/wpQw== X-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=M1flP+uCnq9bvhWOk3Hi056rYnnTwQdueV1rV19uNqOnjC5F5u+IWDG6P7ywsCRjZQxG HzF4OVuEQ1xU076WMDhSzUGxHakeiqX+biLcikSEbSeyoJmWUgSMVMcOPZZ2cfGSK5jO+ NlkIPTQROZDAQSJqZip9je+Y6EPIuXiEigGVZseVmO809tf8FCzXwqAlailMmczuSdA+t hG/JfggcMmpoNZlVlusXEXWu2nAkiQVHyQNrbR0eel0aGp3zioemI/gCpYXeE2fhewn3G kzJaqChx/H0+j5JqG19BdttEEW8HpKm2FG6bA/7PIYueRLTm+54QkohyS29uwNo7upw== X-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.177 X-Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 BF4EA606A332 for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 01:22:19 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BF4EA606A332 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iiitd.ac.in X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iiitd.ac.in X-Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2f07a960666so75404235ad.1 for <netdev@vger.kernel.org>; Sun, 29 Nov 2026 17:22:19 -0800 (PST) X-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=Mm8B0LsMQUd4aCpo1bWVO5uQvk8A7HkCzLA4GYDHPz38iYL6Tgxx/7nO5cc2puuOQB yAcKDLzazh6//O3kPYo9MuUhFpmqY1Dmgq7to5VVel4RNzxq5Q9QImESu+ODz2snOv88 nacY5bBDOHJKv7o7UDxQ/SGyRicXhla9JRdAKTidvnv75oBJKPzWVYVx2n3kdSDmwFyo 86jjM9t4GUV/NgDcI2vO5Gfkj6GQvTcng67tk1P/9qT5gBdfRvCQJuE30iO0nJkLcHfJ pcHuhKgkveCOpjARJQS0zXUuyI4r1+FiGlBK8FqicG4r/ZCy1xe5ALX73VqhELws20bi Yt+g== X-Forwarded-Encrypted: i=1; AL+hErGbDZT/fPQjehyNkFoUgGoZ6DfiLy7xwwT2S405YZi+83FZ2KbgMJ2QvT9gnUScjBzWBympi1w=@vger.kernel.org X-Gm-Message-State: APuU4Z9bVFU6pVfaNE3npyk7Tx11fcCvqYM8WWABxWMkOG5EA1vaIaru HDDy/AohcbVHwnfYWgjZdcY8/eb5tm1n5iXgjF8WwppFQFNPOgeASWxFSneddFQ5kDA= X-Gm-Gg: AZFdTZdH1RmoXW6Le7H2WgUdATxFi57x82tZBgDwoqnLGTu/DoAoDnXSfB339n9w5Sw +Rwa59g4GuIhDOLlPYYPAt5LZqJzoKE/pzpmfj9MaiYlezB2BkLWukFjj3UZQ0QMJ74X+VCyDcT PsYvZgfDNTaaAuU6BeMiv1DONCYzutdaMPoLqIsLZAqR1so2clK49ZQIKs4dglotA/CmTJnYzCE hSsuo0T4sPQPDMpXoba7D8TeGztMChDaSueyL2lCFwQYUtvhg5QqaRhF/iGj6MYu3qAMV/36yYN eIZaBQiT8kpXFhuWZkHuYPLomCk4ZbjMFWun22P0m98Jp7EMZdOeOYCd6j25cqcaMOLC0ub1OWu UcMB7N40/AAvWWj8ANk/OaccsJAE+kedCe9nHgTuvu7dJ9SAje9AZWaAISJ50kZDtTkMiNqLwVh 0JQEwLgwkqY0WJMfRBlZqHq7tVllvoM5Gtm+s3Vnyp0eab1UfCUhcf1bGvI5yPmzh2v0ipK0d+y 566Wtp3gAirj7HuVOqidIOEYyftNsZSi+LFCIAHV6e+vKiwZQ38+jgb3iEgLAcQd1HrczNjpe0y 9PkcaVp9RCL+ZmKkuv0Ej0AA0FItf+rGoHk0ShgDH/uY49WIZw8G4JTYuHEkS0B1AIvJwIWn7jK I2M0DoLGSwKNS0/SuqbuYiTw81wPo/m7OBShzKHhZI4t8qqu+dbzrQFwkuZxBimLF97AsW+e8Nz t5F42/ve5d758= 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) X-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) X-Cc: oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kapil Vaswani <kapil@presceralabs.ai> X-Mailer: git-send-email 2.34.1 X-In-Reply-To: <20261130012208.1962491-1-piyus@iiitd.ac.in> 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