Page MenuHomeFreeBSD

aio: Improve UMA usage
ClosedPublic

Authored by markj on Jun 15 2022, 1:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 11, 12:05 AM
Unknown Object (File)
Fri, May 10, 11:53 PM
Unknown Object (File)
Fri, May 10, 4:50 AM
Unknown Object (File)
Thu, May 9, 10:02 PM
Unknown Object (File)
Mar 17 2024, 7:22 PM
Unknown Object (File)
Feb 8 2024, 8:47 PM
Unknown Object (File)
Dec 20 2023, 4:09 AM
Unknown Object (File)
Oct 16 2023, 3:38 PM
Subscribers

Details

Summary

Remove the AIO proc zone. This zone gets one allocation per AIO daemon
process, which isn't enough to warrant a dedicated zone. Plus, unlike
other AIO structures, aiops are small (32 bytes with LP64), so UMA
doesn't provide better space efficiency than malloc(9). Change one of
the malloc types in vfs_aio.c to make it more general.

Don't set the NOFREE flag on the other AIO zones. This flag means that
memory allocated to the AIO subsystem is never freed back to the VM, so
it's always preferable to avoid using it when possible. NOFREE was set
without explanation when AIO was converted to use UMA 20 years ago, but
it does not appear to be required; all of the structures allocated from
UMA (per-process kaioinfo, kaiocb, and aioliojob) keep track of
references and get freed only when none exist. Plus, these structures
will contain dangling pointer after they're freed (e.g., the "cred",
"fd_file" and "uiop" fields of struct kaiocb), so use-after-frees are
dangerous even when the structures themselves are type-stable.

Test Plan

AIO regression tests, syzkaller. I've been fuzzing a KASAN kernel with this
patch for several months without seeing any reports of a use-after-free.

Diff Detail

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