HomeFreeBSD

Fix a panic on boot introduced by 555a861d6826

Description

Fix a panic on boot introduced by 555a861d6826

First, an sbuf_new() in device_get_path() shadows the sb
passed in by dev_wired_cache_add(), leaving its sb in an
unfinished state, leading to a failed KASSERT(). Fixing this
is as simple as removing the sbuf_new() from device_get_path()

Second, we cannot simply take a pointer to the sbuf memory and
store it in the device location cache, because that sbuf
is freed immediately after we add data to the cache, leading
to a use-after-free and eventually a double-free. Fixing this
requires allocating memory for the path.

After a discussion with jhb, we decided that one malloc was
better than two in dev_wired_cache_add, which is why it changed
so much.

Reviewed by: jhb
Sponsored by: Netflix
MFC after: 14 days

Details

Provenance
gallatinAuthored on Nov 1 2022, 5:44 PM
Parents
rG7366c0a49c9a: netlink: add netlink user documentation.
Branches
Unknown
Tags
Unknown