Page MenuHomeFreeBSD

if_stf: KASAN fix
ClosedPublic

Authored by kp on Nov 30 2021, 4:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 13, 1:44 PM
Unknown Object (File)
Feb 13 2024, 8:31 AM
Unknown Object (File)
Jan 26 2024, 8:54 PM
Unknown Object (File)
Dec 23 2023, 11:05 AM
Unknown Object (File)
Nov 27 2023, 8:21 PM
Unknown Object (File)
Sep 11 2023, 5:09 AM
Unknown Object (File)
Jul 5 2023, 3:27 AM
Unknown Object (File)
Jul 5 2023, 3:26 AM

Details

Reviewers
markj
Group Reviewers
network
pfsense
Commits
rG439da7f06dce: if_stf: KASAN fix
Summary

In in_stf_input() we grabbed a pointer to the IPv4 header and later did
an m_pullup() before we look at the IPv6 header. However, m_pullup()
could rearrange the mbuf chain and potentially invalidate the pointer to
the IPv4 header.

Avoid this issue by copying the IP header rather than getting a pointer
to it.

While here also ensure we've done an m_pullup() for the IPv4 header.

Reported by: markj, Jenkins (KASAN job)
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kp requested review of this revision.Nov 30 2021, 4:46 PM
markj added inline comments.
sys/net/if_stf.c
755

This could be m_copydata(m, 0, sizeof(*ip), &ip).

Also the check below implies that we could have sc == NULL, so it's not safe to dereference ifp yet. Using m_copydata() would fix that problem too.

sys/net/if_stf.c
755

... that assumes though that the packet is at least 20 bytes long. I'm not sure if there's something guaranteeing that.

The stf tests pass for me with KASAN+this change. Thanks!

This revision is now accepted and ready to land.Nov 30 2021, 5:21 PM
This revision was automatically updated to reflect the committed changes.