From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796477407; b=pbsWIFJ1IElG7eotAKkSzh59idiQ2VM4P/ebjks60cxt/POQ7orWYAWNZWGrDIA6V7Lw etUbHZ4NFen/1U5ffyP6ndMSXsYya/afSjQMCpPl8RTacdRyU2sN5JzjUkZK8RLTgbx8p l/hdmpklNJQVtaq4s2AxqxG66nmfYCgdop8ccu3Sgdouks32AtQNyw6aei+i0iipp68yI arJqNG4IcoGpOmdLwYa9fOQOnQPpj1rUFW1GBgIWZTT1RKSGgMlGnYOrN8X8gEJcJuQIh 4TN3YCKFXbMQT+BQZ2R50/WPLE4DE66zA4OPWdS7p/LJipTCCKPjIYk6oNcL3Ing2kA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796477407; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=QL9e5EbZhH69s/m0cjF09Lzf79YJvXfl/WO+fCed2IQ=; b=uGQC825JbPw1uTeeIuRTNBob+Cj/fxdERWNeKsv+IW/Bi2vAZ2tbCwDS8WW1LhAinISr aKmosCvpe1fpYtwdd/ikWaGlmAQiuZkCLCI1NniJRUhRNrpzllRIvWq5yz64rc16S2drW uP6hDej5U8foHLQ/6C8bVyF0YPm5uBmsHBhDwuJVxwztoKfROOe+xUNlXfGynlEdA4Fjh 3VJSpiSB/iuTNAvsJCcBAiFPbSWfXt3tLeMIFwMZ+gcwF+M3OD8C7scR/CftBGllfkNuw ffo7VVevek6pdOysAJquko0o2Kre3+RGR5CAiJsKkeaXasw8QAR7yfBXfPbX8I5lA2g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iBnlkssb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F16E606A322 for ; Sat, 5 Dec 2026 13:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iBnlkssb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 495A41F0092B; Sat, 5 Dec 2026 13:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796477407; bh=QL9e5EbZhH69s/m0cjF09Lzf79YJvXfl/WO+fCed2IQ=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=iBnlkssbMenwbp//7JkUhYyxSc45wEnlkrflAVCYTzz5qBKN2n7QqvndFTEE4pbOO n+0e4ZM4HcFnbMSDOyVr5dqJoBk2Shf7Z3UMOuZq8Nt7rBH6T3xeP7P137CjEv3hVi HveLsBB8qdV+sXFUKt0tzy1BVg+sS3gL4o4IDSOYOwmUCrwVxfZ7jZQlXcXmU1ibVD FRaotfrSSut8950dkzBlNxa5FXDV/lk5W58iZzuL8hn+uMLl21GwsSyP0BYuY1DyFm 5dZ+8J4qRoWVotVpdMJalRAaRejRiLYIigLF9Xy9FUly6BDMavq5goEIKVB/hxGrFk 7vmUkOeKry1bg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf 1/2] bpf: Don't use an unset inner transport header Reply-To: sashiko-reviews@lists.linux.dev To: "Chris Mason" , bpf@vger.kernel.org In-Reply-To: <20261205012513.15379-2-mason@kernel.org> References: <20261205012513.15379-1-mason@kernel.org> <20261205012513.15379-2-mason@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 13:30:06 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] bpf: s16 cast in bpf_skb_net_hdr_pop() truncates inner transport offset - [Medium] bpf: bpf_skb_net_hdr_pop() misplaces inner_transport_header and masks GRO bug -- commit 1a1076a6002794e99517c8507268d7aa9c97eab5 Author: Chris Mason bpf: Don't use an unset inner transport header This commit casts skb_inner_transport_offset(skb) to s16 in bpf_skb_net_hdr_pop() so that an unset inner_transport_header whose u16 offset wrapped after a headroom reduction is still reset to off. > diff --git a/net/core/filter.c b/net/core/filter.c > index ea20fd2be65c0..892e20291283d 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -3456,9 +3456,12 @@ static int bpf_skb_net_hdr_pop(struct sk_buff *skb= , u32 off, u32 len) > /* It was in the removed bytes or before skb->data. */ > skb_set_transport_header(skb, off); > } > - /* Do not leave the inner transport header in front of @off. */ > + /* > + * Do not leave the inner transport header in front of @off. If > + * nobody has set it, its offset can have wrapped. > + */ > if (skb->encapsulation && > - skb_inner_transport_offset(skb) < (int)off) > + (s16)skb_inner_transport_offset(skb) < (int)off) > skb_set_inner_transport_header(skb, off); > } [Severity: Medium] Can casting skb_inner_transport_offset(skb) to s16 clobber valid offsets >=3D 32768 and fail to reset offsets < -32768? virtio_net_hdr_tnl_to_skb() can set inner_transport_header from csum_start up to U16_MAX - 1 via skb_partial_csum_set(). Under the s16 cast, offsets >=3D 32768 sign-extend negative and are overwritten with off. If skb->encapsulation stays set (for example in bpf_skb_proto_6_to_4()), that places inner_transport_header behind the outer transport_header, underflowing thlen in skb_gso_transport_seglen(). In the other direction, RX allows headroom up to SKB_MAX_RX_HEADROOM (32767) and bpf_skb_generic_pop() pulls up to 4095 bytes before this check. An unset inner_transport_header at 0 then has an offset below -32768, which wraps positive under s16 and skips the reset. [Severity: Medium] Does resetting a wrapped inner_transport_header to off misplace it when skb->encapsulation stays set, while leaving the GRO bug unfixed? When bpf_skb_net_hdr_pop() is not followed by bpf_skb_clear_encap() (for instance in bpf_skb_adjust_room() without decap flags, or when decapping only the outer layer of a nested tunnel), off points to the network header in BPF_ADJ_ROOM_MAC mode. qdisc_pkt_len_segs_init() then reads the IP header as a TCP header at skb_inner_transport_offset(skb), dropping packets with SKB_DROP_REASON_SKB_BAD_GSO or miscomputing gso_segs and pkt_len. This also leaves the root cause in place: the fraglist early return in tcp{4,6}_gro_complete() and udp{4,6}_gro_complete() omits setting inner_transport_header, so non-BPF forwarded encapsulated fraglist-GRO packets are still dropped in qdisc_pkt_len_segs_init(). Fixing fraglist GRO completion to set inner_transport_header and avoiding u16 underflow of unset inner headers in skb_headers_offset_update() would handle both BPF and non-BPF paths without the s16 heuristic. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205012513.1537= 9-1-mason@kernel.org?part=3D1