From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795962269; b=3rAvcGBQNROluU4wnsISPEk4s4NbS74voe9Xjb8zNITWtV9Rps5ohkDWFznCsGrqHvRc pITNTrKfk23j90Gx4Yo5gnNJ0zIhZ2zm3O55pLn3+K3bg6TqzLAouw0MBxdBwlIejS6Wu cBwiR5d09oQ2PEZefIerO0BJ1W701/iIsVRCqBmhTiCDp4vy7bxIpamV5Y7ShntKAmAS6 QTJTDlnH3IRdGTLnClpPZOeDCihiT7+J9zYxnu/Gywc+1rQ5Lpm4UU1CLZaDpgui08Gpz glPYp14G1RiVM1/7KsV9S4Wbj5kDR3ZCbjb49kxHZj9MySNlyH5IoF9h7dPk5566Omg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795962269; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=eqLg2H4/Tf/Vbltle5aE9vABgi3SNh7y9jE7w2tnPqA=; b=XIEyN36i0k4cKtUlf5LXvBDlWh2JG2OD5rVH+eLLBm/bIQumGeeftaS1lXeTXlazU3EX xrWCmyC+LIhHr1KOJOCbw3NkN3Ak48RLoDeCTH5gvgFLvcXpDZNeC07+M/Ws7T9P3jiFA v1X2c9jx5BHhZpW5NHszfxxESBhP8AKYTs6ol+spEVhBoASLj6M23QipiHRqeD7jWEMqL Z0K1P11v1j80droQb0Pf/tRrO+4jl1WdNHQDbXHvgQLhENSLNy+aNnSmW9Mhqpiy9bYBG gkuElJ1/O35KSrqwRatDjdlq6PX4m1pD97p4l68uDBlp4UW6H2M+HK9I7QY9sjUwlDw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=N58CuRzF; arc=none smtp.remote-ip=209.85.219.71 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (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 0C4D3606A325 for ; Sun, 29 Nov 2026 14:24:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0C4D3606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=N58CuRzF Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-921161ab1a2so134363806d6.0 for ; Sun, 29 Nov 2026 06:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795962268; x=1796567068; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eqLg2H4/Tf/Vbltle5aE9vABgi3SNh7y9jE7w2tnPqA=; b=N58CuRzFPN1SoHKTbAiKbYp6Y9VA3/TiCvZrqVGx8+KvKXWmqWL4WrgAKzIOG4DnLy +2PP6TuTZlFHvhWclzHpQwnWBAPcHIo5S7OpzKZuMn80KO+0yI9+PpQMccnGycA+Qwej EIYd/vsYhd/gtX5ntAslLhEXyqnOmKakLmDHDNwLIYR/btl3/c4YMfoDuvPJAsJOrAY+ rvG1zncTwbp4oCIdLiVO/iTn7S2cb8fWkMe/8SyiwzT6a4b5zoGl5GjGcnW/HVAYB6xD irxS9ChbTkxvBPRDgzVC/EGAbtYZkAUXUALEIHS1Msn3m1ll9AgMtVXI2y01yTe/NaWU 1NEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795962268; x=1796567068; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eqLg2H4/Tf/Vbltle5aE9vABgi3SNh7y9jE7w2tnPqA=; b=vv0ALmVqi8RPxqB6QcZvHqsP01AtOzy7H9XKoJYFs1RqS5nlsQzsW8KT4c/NASBoDA qxoqniLhG9a6xLL0FIUYFla8Yd5T6FcyBiUeRHawLxqz5C5uMLz4HtIcbNXLXtCS7i3i pPg6bsTqdo9FW2HGQZw7XUhlXGk5V4o4qnf/XacJYEWYkgZ74XyVx+I42Ma++QEc8vDj 0wv/YHUkI77Juf7ZqzVuhps/8tuQntxlgIs4VUJctstOEcv4tWNVzMkF/bfSzMrOiR03 IxfYYhw2J0/clUCbZHeGBuNMHl+PBWKVDR9qivjb1TvNbs2Q+kT2gGayyTooDtkV7JJz pI4g== X-Forwarded-Encrypted: i=1; AL+hErEG2ObuOLr3wsWV16eJ9JMaCbAAHkEigRSYOiHcx17ybLGNA651jurOqets+JsESYrrDl88PBc=@vger.kernel.org X-Gm-Message-State: APuU4Z/W+k8I6/8iOBPvsfpv8/nucpYgbHwZmhbh/gcuSqfnj53SgMVd /LxAstxvUjFU/vqgxBSdZgUhMlPABg+oZCBFVYfsyp9YLu/t7Lf18fk8bWix4YAuYEmpHxUqheQ nM+FNI+u3aw== X-Received: from qvbne1.prod.google.com ([2002:a05:6214:4241:b0:921:1d17:172e]) (user=willemb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:3d01:b0:921:6588:53ef with SMTP id 6a1803df08f44-92165885458mr361090096d6.27.1795962267776; Sun, 29 Nov 2026 06:24:27 -0800 (PST) Date: Sun, 29 Nov 2026 09:24:26 -0500 In-Reply-To: <20261123023548.3351531-2-piyus@iiitd.ac.in> 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 References: <20261123023548.3351531-1-piyus@iiitd.ac.in> <20261123023548.3351531-2-piyus@iiitd.ac.in> Message-ID: Subject: Re: [PATCH net 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb From: willemb@google.com To: Piyus Kedia , David Heidelberg , netdev@vger.kernel.org Cc: oe-linux-nfc@lists.linux.dev, linux-kernel@vger.kernel.org, Kapil Vaswani , Piyus Kedia Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Piyus Kedia wrote: > 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 For all three patches in this series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1219102 Patches targeting net must include valid Fixes tags; please add Fixes tags to all three patches, include a cover letter for the series, and CC the maintainers listed by get_maintainer.pl before respinning. Also do not play games with the In-Reply-To. Use a Closes: (or Link:) tag to point back to bug reports.