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
F157398785: D53612.id165980.diff
Wed, May 20, 11:58 PM
F157392895: D53612.id165943.diff
Wed, May 20, 10:46 PM
Unknown Object (File)
Tue, May 19, 10:41 PM
Unknown Object (File)
Tue, May 19, 10:41 PM
Unknown Object (File)
Thu, May 14, 6:46 AM
Unknown Object (File)
Thu, May 14, 1:39 AM
Unknown Object (File)
Thu, May 14, 1:26 AM
Unknown Object (File)
Mon, May 11, 12:20 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 Not Applicable
Unit
Tests Not Applicable

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–2337

...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.