Page MenuHomeFreeBSD

inet6: protect address manipulation with a lock

Authored by mjg on Mar 29 2023, 1:07 PM.
Referenced Files
Unknown Object (File)
Thu, Sep 21, 9:15 PM
Unknown Object (File)
Wed, Sep 20, 11:28 PM
Unknown Object (File)
Sun, Aug 27, 6:04 AM
Unknown Object (File)
Jul 6 2023, 11:39 PM
Unknown Object (File)
Jul 4 2023, 7:09 AM
Unknown Object (File)
Jun 3 2023, 5:08 PM
Unknown Object (File)
May 15 2023, 5:40 AM
Unknown Object (File)
May 11 2023, 5:04 PM


inet6: protect address manipulation with a lock

This is a total hack/bare minimum which follows inet4.

Otherwise 2 threads removing the same address can easily crash.
Test Plan


while true; do
    ifconfig $IFNAME inet6 $INET6ADDR &                      
    ifconfig $IFNAME inet6 $INET6ADDR delete &                   

crashes stock kernel with:

--- trap 0xc, rip = 0xffffffff80fd9293, rsp = 0xfffffe00cd68c9d0, rbp = 0xfffffe00cd68ca20 ---
in6_unlink_ifa() at in6_unlink_ifa+0x63/frame 0xfffffe00cd68ca20
in6_purgeaddr() at in6_purgeaddr+0x367/frame 0xfffffe00cd68cb40
in6_purgeifaddr() at in6_purgeifaddr+0x13/frame 0xfffffe00cd68cb60
in6_control() at in6_control+0x532/frame 0xfffffe00cd68cbc0
ifioctl() at ifioctl+0x7bc/frame 0xfffffe00cd68ccc0
kern_ioctl() at kern_ioctl+0x26d/frame 0xfffffe00cd68cd30
sys_ioctl() at sys_ioctl+0x101/frame 0xfffffe00cd68ce00
amd64_syscall() at amd64_syscall+0x10c/frame 0xfffffe00cd68cf30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe00cd68cf30

Diff Detail

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

mjg requested review of this revision.Mar 29 2023, 1:07 PM
kp added a subscriber: kp.

fwiw, Gleb added the IPv4 lock in

It's a bit of a big hammer, but it's going to be more effective than finding and handling individual races, and it's probably not very important to be able to add/remove millions of addresses per second.

Nit: it should be a per-vnet lock, but the IPv4 one isn't either. Perhaps that's something we should fix in a separate commit.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 30 2023, 8:47 AM
This revision was automatically updated to reflect the committed changes.