From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795401358; b=xYXqcT7Z5vKkBQ+67E5/yuOV1H4kgG3LeSp4ZPu0IIAwVOFndw+5DcsPheHHrUEk5vp8 7+jvBWVDh6vHBxEY+gyjP3KEuntL+6KpJHhWA/n79NljKKwQnZ8keWCvwpUvbp9iBUo9n FO9O8WC83D00GOEySMpidnzWIxsajB2WKErNV140W48G2pZg8I0dYumqqAwElZsIlUeKy 5mWHFMSwd3NgOn450eUAfPGj+jms4grqzYW8yS5hVgA+hnqpH4GGncES8fJH4I3yPeu/P 76C0D+t0nvqwQWix85YF31WjaZnUWMXjsGNCgg4LdejhFLVQAtMCWwy+AHJWLyMH0aA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795401358; 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=st5pGIMSSsdG331Dh3ZbAxiLCbZswNCMENZiPvwdzYI=; b=L5TCLmegKPV1GTGCEbkSVYm2uBiEnuSzREZNGDqPb9HqXHK4qdZj0dB3aZBYZ4HD3jyZ jJf5fjoFgA/Xask517V/8gWkyWoR/8t0ql20a8Au7gfVRHnatL1qcIqWdUIZ2w/sYnIcR HZUQTWLWOwrBb95BUdY4WrCOXI4Ow99ExQxXAGnlECg7uDourmEz3FYo/WOl/3zDfxeCB gHyUpuDuc6Qq2jO8zkZxf2tylrdbKTDs2WwafSWHZ48OSR0nA7/78LtY3u3kpP5OIZIL1 k5ei+l8jESspVmcUiAn0NWV52cn6fX8z8IOtnFxbU1PtqUajiVqEstCjJApXLUQQnyA== 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=Pw8PEnm0; arc=none smtp.remote-ip=209.85.214.180 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 B109F606A320 for ; Mon, 23 Nov 2026 02:35:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B109F606A320 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=Pw8PEnm0 Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2f02ee04378so22143785ad.1 for ; Sun, 22 Nov 2026 18:35:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iiitd.ac.in; s=google; t=1795401357; x=1796006157; 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=st5pGIMSSsdG331Dh3ZbAxiLCbZswNCMENZiPvwdzYI=; b=Pw8PEnm0wUjRCQLP0HEtvFtvQLfUyDMiAdPXJOvN6sHBNf5HMrHgvDqJGIlYs1mVJF vfSgeNVWvHXvrK6UjZ9r4ydWowzg5zlqLVEjrom9370KYwmJgRnrBLNEV2mRuM0ReQik q4qrr9yQboX1xPDqycGtlMWXD8bqR1ej2xzXQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795401357; x=1796006157; 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=st5pGIMSSsdG331Dh3ZbAxiLCbZswNCMENZiPvwdzYI=; b=bGYg7DTMCl2aSCi4apR0o7LxYYUi514qu6Lp6dB2wfaEVt0hVkDdQaLH1xM7vdbcA/ WXFtPEbAk5Ul2n/gpihe97mu1NoVJBKgJfGCeS9dsmcMlBnOGkyUdWzqiQYHsj8tXYwc RNYrroqKiQlHVAWoqSWy/W28s9lOjPhMzTug7JQf+tOL5DZLqNGamLhFaZHCUWoEl72i HLDQki9ErHijzrCkkzKhud4P6d45dU81TnWprisJjXoDufd4J66zLBJpVUQGdq7vp9Qi 33kG3kFqYNvROiZOjNh/GAPYwp8Tj32MyXOJI6RANL02EyG+ZcEXmTdHG+O8DpfYyAFz s++Q== X-Forwarded-Encrypted: i=1; AL+hErGmr05lYVtLbBt8KFAYx4l1t3NPrtvfGlhL1lp/WFDWjyk3+f3oSGC7dzTyJ4u5LlAfGGn7srheHGev0V0=@vger.kernel.org X-Gm-Message-State: APuU4Z90WF8Dl8IrDRDV0iWV2/dOkIZaT8oKmigSm+Zuf4i+YLt5iqGq iyUZqYU1Hh2wMDmwsBwwGC72oMt3oeo9wy684wK/HrOHk/q9vhobCeYhxUHUC5kwl0s= X-Gm-Gg: AZFdTZdPQFgpNs5GGAlOwL8bBu1Dyrum8coynm/prCKZL/p1RXu2gPaMKhvsoSE8HX+ +m2/e/QbC2rhZPm2+lEaQAh+O6f1FT8cHud7vFO1VKIKWin4jCj7qs5v+1X5r0ILOwng4tmydhA Fg2DzKeqTkD4jAQaSAoBYx7YwTAk0LvizwQ85urcw/dXyr5xNF5RqqlMDx2hIfqW7UFIZcg5gR1 yAC9YmY/ejUouxC6ijNReO/pIaazH7zI6DD+szAa2OoH3zMp1LLCDzc0ctJg+x8uRwZtabM47mi WZywl5khGPilp1Tje9x7OcwwaSchZfPczwwqb5b4N17JpdOO7W5kzUyVj1UrD9JRz1uGsi/NKvW 6t8WrNYfFEtjDBdnly9OTiiWJqYtYrnoCTbUkg9mqsgxTwLtooRGaEuRuwvIlKQQXC6QKzHmKPo 4S6+S3FRlkLwq6cLXPmabYXqKebjynGZK8ifOwTPK6lBeH5sUaChuip3evKM2HNuS1fbtaDEfW+ IClhLMY+VphV+E42Dz9gC+H7p1HdPeqeggWmNqCUp2NeqsJGDr98sVSu68wv9H170uWHZEQXLB0 VOlkUvQx4uYQzC1PvBJY3Z06CMEt/7lDB5MSlqHE7PwQNFLqUnK3u6mEXRCnve4Acs6MJP2IYTo SRe7r2G0gjzlKzJQ6uVMbFcSnqJBTMIq1H1UDwuv7wc9LTN+sv/2YeutBFaSqkdPv X-Received: by 2002:a17:903:32cc:b0:2e9:4175:3079 with SMTP id d9443c01a7336-2f03f1cf4b6mr119824125ad.21.1795401357008; Sun, 22 Nov 2026 18:35:57 -0800 (PST) Received: from iiitd-S2600STB.iiitd.edu.in ([103.25.231.160]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f120282sm43609925ad.59.2026.11.22.18.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 18:35:56 -0800 (PST) From: Piyus Kedia To: David Heidelberg , netdev@vger.kernel.org Cc: oe-linux-nfc@lists.linux.dev, linux-kernel@vger.kernel.org, Kapil Vaswani , Piyus Kedia Subject: [PATCH net 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb Date: Mon, 23 Nov 2026 08:05:48 +0530 Message-Id: <20261123023548.3351531-2-piyus@iiitd.ac.in> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261123023548.3351531-1-piyus@iiitd.ac.in> References: <20261123023548.3351531-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. 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 80a00938c..0a3d66e6c 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