Skip to content

Commit cc91202

Browse files
CN-Scarsgregkh
authored andcommitted
net: use skb_header_pointer() for TCPv4 GSO frag_off check
[ Upstream commit ddc748a391dd8642ba6b2e4fe22e7f2ddf84b7f0 ] Syzbot reported a KMSAN uninit-value warning in gso_features_check() called from netif_skb_features() [1]. gso_features_check() reads iph->frag_off to decide whether to clear mangleid_features. Accessing the IPv4 header via ip_hdr()/inner_ip_hdr() can rely on skb header offsets that are not always safe for direct dereference on packets injected from PF_PACKET paths. Use skb_header_pointer() for the TCPv4 frag_off check so the header read is robust whether data is already linear or needs copying. [1] https://syzkaller.appspot.com/bug?extid=1543a7d954d9c6d00407 Link: https://lore.kernel.org/netdev/willemdebruijn.kernel.1a9f35039caab@gmail.com/ Fixes: cbc53e0 ("GSO: Add GSO type for fixed IPv4 ID") Reported-by: syzbot+1543a7d954d9c6d00407@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=1543a7d954d9c6d00407 Tested-by: syzbot+1543a7d954d9c6d00407@syzkaller.appspotmail.com Signed-off-by: Guoyu Su <yss2813483011xxl@gmail.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/20260327153507.39742-1-yss2813483011xxl@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 846cd4a commit cc91202

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

net/core/dev.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3791,10 +3791,15 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb,
37913791
* segmentation-offloads.rst).
37923792
*/
37933793
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) {
3794-
struct iphdr *iph = skb->encapsulation ?
3795-
inner_ip_hdr(skb) : ip_hdr(skb);
3794+
const struct iphdr *iph;
3795+
struct iphdr _iph;
3796+
int nhoff = skb->encapsulation ?
3797+
skb_inner_network_offset(skb) :
3798+
skb_network_offset(skb);
37963799

3797-
if (!(iph->frag_off & htons(IP_DF)))
3800+
iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
3801+
3802+
if (!iph || !(iph->frag_off & htons(IP_DF)))
37983803
features &= ~dev->mangleid_features;
37993804
}
38003805

0 commit comments

Comments
 (0)