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)
Thu, Dec 4, 9:00 PM
Unknown Object (File)
Tue, Nov 25, 9:21 PM
Unknown Object (File)
Tue, Nov 25, 9:15 AM
Unknown Object (File)
Mon, Nov 24, 4:48 AM
Unknown Object (File)
Sat, Nov 22, 9:25 PM
Unknown Object (File)
Mon, Nov 17, 7:21 PM
Unknown Object (File)
Sun, Nov 16, 8:35 PM
Unknown Object (File)
Nov 10 2025, 3:37 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.