Skip to content

Commit ddc748a

Browse files
CN-Scarskuba-moo
authored andcommitted
net: use skb_header_pointer() for TCPv4 GSO frag_off check
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/[email protected]/ Fixes: cbc53e0 ("GSO: Add GSO type for fixed IPv4 ID") Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=1543a7d954d9c6d00407 Tested-by: [email protected] Signed-off-by: Guoyu Su <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 514aac3 commit ddc748a

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
@@ -3821,10 +3821,15 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb,
38213821
* segmentation-offloads.rst).
38223822
*/
38233823
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) {
3824-
struct iphdr *iph = skb->encapsulation ?
3825-
inner_ip_hdr(skb) : ip_hdr(skb);
3824+
const struct iphdr *iph;
3825+
struct iphdr _iph;
3826+
int nhoff = skb->encapsulation ?
3827+
skb_inner_network_offset(skb) :
3828+
skb_network_offset(skb);
38263829

3827-
if (!(iph->frag_off & htons(IP_DF)))
3830+
iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
3831+
3832+
if (!iph || !(iph->frag_off & htons(IP_DF)))
38283833
features &= ~dev->mangleid_features;
38293834
}
38303835

0 commit comments

Comments
 (0)