Page MenuHomeFreeBSD

vlan_output(): use parents context when calling if_output()
Needs RevisionPublic

Authored by rew on Aug 21 2022, 7:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 6:55 AM
Unknown Object (File)
Dec 15 2023, 4:36 AM
Unknown Object (File)
Jun 24 2023, 3:14 AM
Unknown Object (File)
Jun 11 2023, 8:20 PM
Unknown Object (File)
Apr 23 2023, 12:57 AM
Unknown Object (File)
Mar 19 2023, 5:02 PM
Unknown Object (File)
Mar 5 2023, 5:55 PM
Unknown Object (File)
Feb 23 2023, 10:55 PM

Details

Reviewers
kp
melifaro
Summary

A panic can occur when configuring a vlan on wlan interface - reported here: https://lists.freebsd.org/archives/freebsd-hackers/2022-April/001043.html

It seems the vlan driver is calling ieee80211_output() with the wrong
ifnet context and dereferencing a bad pointer. ieee80211_output() is
getting a struct ifvlan when its expecting a struct ieee80211_vap from
the passed in if_softc.

Looking at vlan_output() in sys/net/if_vlan.c, I wonder if the parents
ifnet context should be used when calling if_output().

The backtrace:

KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00a7c4f760
vpanic() at vpanic+0x17f/frame 0xfffffe00a7c4f7b0
panic() at panic+0x43/frame 0xfffffe00a7c4f810
trap_fatal() at trap_fatal+0x385/frame 0xfffffe00a7c4f870
calltrap() at calltrap+0x8/frame 0xfffffe00a7c4f870
--- trap 0x9, rip = 0xffffffff80daeed8, rsp = 0xfffffe00a7c4f948, rbp = 0xfffffe00a7c4fa50 ---
ieee80211_output() at ieee80211_output+0xf8/frame 0xfffffe00a7c4fa50
arp_ifinit() at arp_ifinit+0x6d/frame 0xfffffe00a7c4fab0
vlan_ioctl() at vlan_ioctl+0x1e2/frame 0xfffffe00a7c4fb10
in_control() at in_control+0x9a8/frame 0xfffffe00a7c4fbb0
ifioctl() at ifioctl+0x7f4/frame 0xfffffe00a7c4fca0
kern_ioctl() at kern_ioctl+0x202/frame 0xfffffe00a7c4fd10
sys_ioctl() at sys_ioctl+0x126/frame 0xfffffe00a7c4fde0
amd64_syscall() at amd64_syscall+0x1a8/frame 0xfffffe00a7c4ff30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe00a7c4ff30
--- syscall (54, FreeBSD ELF64, sys_ioctl), rip = 0x80125ebfa, rsp = 0x7fffffffe388, rbp = 0x7fffffffe3d0 ---
KDB: enter: panic
[ thread pid 277 tid 100089 ]
Stopped at      kdb_enter+0x32: movq    $0,0x13e7e23(%rip)
db>

PR: 263505

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 47041
Build 43930: arc lint + arc unit

Event Timeline

rew requested review of this revision.Aug 21 2022, 7:18 PM
rew added a reviewer: kp.
This revision is now accepted and ready to land.Aug 22 2022, 7:35 AM
kp requested changes to this revision.Aug 22 2022, 3:15 PM

Hmm. This *looks* sane to me, but this patch breaks the if_vlan tests, so clearly I'm missing something. A ping over a vlan interface (on top of epair, in a vnet jail) results in ping: sendto: Invalid argument, and I'm not seeing why at the moment.

This revision now requires changes to proceed.Aug 22 2022, 3:15 PM
In D36279#824072, @kp wrote:

Hmm. This *looks* sane to me, but this patch breaks the if_vlan tests, so clearly I'm missing something. A ping over a vlan interface (on top of epair, in a vnet jail) results in ping: sendto: Invalid argument, and I'm not seeing why at the moment.

It looks like what's happening here is that we fail the arp lookup because we're trying to do a lookup on the underlying interface, not the vlan interface.

In D36279#824118, @kp wrote:
In D36279#824072, @kp wrote:

Hmm. This *looks* sane to me, but this patch breaks the if_vlan tests, so clearly I'm missing something. A ping over a vlan interface (on top of epair, in a vnet jail) results in ping: sendto: Invalid argument, and I'm not seeing why at the moment.

It looks like what's happening here is that we fail the arp lookup because we're trying to do a lookup on the underlying interface, not the vlan interface.

Thanks, I'll look into it and see if I can figure something out.

This is yet another problem that calls into some kind of generic way of inheriting/overlaying methods from parent interface to a child.