From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795962269; b=Si0Pq2A/99D3+zYEI6L7hcREFFj+N9YyI6wFopoVAUtVrzkzAaFa9engeuc8jwr6zr9o WUIfBbkc46dBd+vQ/fjXekJuPyZ7e6rOrQO6ypFM9ESlUABhjiS8a0W6eP1Jy8PJNf+9X NLMJkBg8dg9KOAhyGQDjjDrGnZS4dfnUyWb+7upQeuVrHY6xwT7hpdMyhGaqrVJitx8re eru22zJsU2d7QCR6OA9vkvGYz4NIKlGPgDXzfM3aIgJ174esbodc+uU9iYIVYp1HWpps7 1pqC0OrSes2KqW3AbqJ6/4PRbXu9yUbcAxUymz6/5waB9zAEQNdn4KkAkgt1IOQPwew== 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=lTeBwAFz2VX3cBIXZ6OfondLHryTmi9mAyXBoZelnGApiZPVMe5Wl3SFCFuZSpPvZCJD kzxf3mfXQkAI/Rz9D/NI0G03g/NofvZEuSQx3+I5RUUR2qsA8FCH1jZTjCN6H5vA9neAX 6PPVVYp0uAno6hAyeWHdQOTnlrg+2fCcVS15w3zbnr5jQi6INlFsSnYUSR8sFoxBrVEes uRKEFKb12/Q7YMrpnjRU4QcNkFY6aA8Yq8hzYtLAiiZSVJphmFz25DUONCzfqGwlKpTxn zXVvv9BOSHKU+62gVDLFyq5ORvqdGEY2MOYTW0P/l5FveOd17h3rDz/cYItAEvjn+dw== 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.70 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (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 0233E606A323 for ; Sun, 29 Nov 2026 14:24:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0233E606A323 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-f70.google.com with SMTP id 6a1803df08f44-9210357af78so147691296d6.1 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=oNBn5tHM176uMlUkfMb/MbwNOixvcRXW9sQpz6jd0DlqJd5XuCluyaHinCY+Tcr4s/ MiXyWB+VmizEnFyWz2AdMa4jPbdLTiEXxySqsh+fjVvtgKW0rugky2n/jymxXf2bNcQi S7En7eqt88Ox2Lx3OFWVvPVcaMo7nqG4qjdIN3runkhJABWLtg9/TURYixllHCilWDr1 CCWzMjfhqoN+g97B8qV6YndnfcaZ0orNSWedCQm8wsuXz2s0zMk61Uo6gLZ67qiuOJ4k B54RtlA+zZKtaSnRVznxLI3UxBrkz2XHd40jpz74gjnLbHh5BK/LG79iMgBGfHXtxCu6 XcRA== X-Forwarded-Encrypted: i=1; AL+hErF3/yJ3ircKEYK/KZiYutgjj/hZu5MZmXT9g6JTELEA0nvW9MU6fnVGrLuStCsUr3qQlN+bWnNHepywVuY=@vger.kernel.org X-Gm-Message-State: APuU4Z/wHOsmIvogFeez0/EupRjZdt5sBTe1+91Crank5jXMEQ4Bx/iC FvLuxNcjDJTWwEv1OoYuWiPPWsx5/gXL92lqWQnmjkO2QKBrC08CPkpkQ1e9Tv3y+p0tyz/s6Ik +FoRbHJ9+Vg== 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: linux-kernel@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.