Page MenuHomeFreeBSD

ipsec: Drain async ipsec_offload work when destroying a vnet
ClosedPublic

Authored by markj on Fri, Aug 30, 12:54 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Sep 8, 8:05 AM
Unknown Object (File)
Sun, Sep 8, 7:07 AM
Unknown Object (File)
Fri, Sep 6, 10:16 AM
Unknown Object (File)
Tue, Sep 3, 4:59 PM
Unknown Object (File)
Sun, Sep 1, 11:35 PM
Unknown Object (File)
Sun, Sep 1, 1:12 PM
Unknown Object (File)
Sun, Sep 1, 5:24 AM
Unknown Object (File)
Sat, Aug 31, 3:29 PM

Details

Summary

The ipsec_offload code in some cases releases object references in an
asynchronous context where it needs to set the current VNET. Make sure
that all such work completes before the VNET is actually destroyed,
otherwise a use-after-free is possible.

Reported by: KASAN
Fixes: ef2a572bf6bd ("ipsec_offload: kernel infrastructure")

Diff Detail

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

Event Timeline

This revision is now accepted and ready to land.Fri, Aug 30, 6:35 AM

This patch can cause hangs, since it's possible for key_vnet_destroy() to execute in taskqueue_thread's context.

To fix this, I wonder if ipsec_accel can use a dedicated taskqueue thread instead of taskqueue_thread.

This patch can cause hangs, since it's possible for key_vnet_destroy() to execute in taskqueue_thread's context.

To fix this, I wonder if ipsec_accel can use a dedicated taskqueue thread instead of taskqueue_thread.

It can, the restriction is that all handling should occur in the same single-threaded context.
I did not allocated dedicated thread because the events like creation or destruction of SAs are very rare, and creation or destruction of SPs almost never happen. So I do not want to waste the whole thread for this.

Then, for me this feels more like a bug in taskqueue_drain_all(). What about D46489 instead?