Page MenuHomeFreeBSD

kern_jail_set(): do not double-free opts
ClosedPublic

Authored by kib on Nov 6 2025, 9:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jul 8, 8:10 AM
Unknown Object (File)
Wed, Jul 8, 3:07 AM
Unknown Object (File)
Sun, Jul 5, 2:59 PM
Unknown Object (File)
Sat, Jul 4, 11:09 AM
Unknown Object (File)
Sat, Jul 4, 11:06 AM
Unknown Object (File)
Sat, Jul 4, 5:00 AM
Unknown Object (File)
Sat, Jul 4, 5:00 AM
Unknown Object (File)
Sat, Jun 27, 12:42 AM
Subscribers

Details

Summary
If vfs_buildopts() failed, vfs_freeopts() must not be called.

Reported and tested by: pho

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Nov 6 2025, 9:34 AM

While I prefer the version I mentioned in the inline notes (it's a little less branchy), I'm also fine with the patch as originally given.

sys/kern/kern_jail.c
1046

This hold is the only reason that vfs_buildopts goes to done_free and doesn't just return outright...

1072

...so we could change the "goto done_free" above to "return (error)", and move "prison_hold(mypr)" here, just before the first of the remaining "goto done" lines...

2336

...and then we wouldn't need to add this test.

This revision is now accepted and ready to land.Nov 6 2025, 5:20 PM

While I prefer the version I mentioned in the inline notes (it's a little less branchy), I'm also fine with the patch as originally given.

I did not wanted to restructure the main flow. If you consider it is worth to, please do as follow-up.

This revision was automatically updated to reflect the committed changes.