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, Apr 16, 1:28 PM
Unknown Object (File)
Wed, Apr 15, 12:08 PM
Unknown Object (File)
Tue, Apr 14, 11:24 PM
Unknown Object (File)
Mon, Apr 13, 8:47 PM
Unknown Object (File)
Sat, Apr 11, 8:15 AM
Unknown Object (File)
Sun, Apr 5, 3:07 AM
Unknown Object (File)
Sat, Apr 4, 5:45 PM
Unknown Object (File)
Sat, Apr 4, 1:11 PM
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.