Page MenuHomeFreeBSD

jail: Avoid multipurpose return value of function prison_ip_restrict()
ClosedPublic

Authored by zlei on Dec 31 2022, 7:58 AM.
Tags
None
Referenced Files
F146277557: D37918.diff
Sun, Mar 1, 8:26 AM
Unknown Object (File)
Sat, Feb 28, 2:25 PM
Unknown Object (File)
Sat, Feb 28, 10:24 AM
Unknown Object (File)
Sat, Feb 28, 3:03 AM
Unknown Object (File)
Fri, Feb 27, 11:26 PM
Unknown Object (File)
Fri, Feb 27, 4:37 PM
Unknown Object (File)
Jan 16 2026, 5:55 AM
Unknown Object (File)
Jan 15 2026, 2:56 PM
Subscribers

Details

Summary

Currently function prison_ip_restrict() returns true if the replacement buffer was used, or no buffer provided and allocation fails and should redo. The logic is confusion and cause possibly infinite loop from eb8dcdeac22d .

No functional change intended.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

It took me longer to remember what I had done in the first place than it did to understand the new logic. I like this.

This revision is now accepted and ready to land.Dec 31 2022, 8:04 PM
zlei retitled this revision from jail: Avoid multiple purpose return value of function prison_ip_restrict() to jail: Avoid multipurpose return value of function prison_ip_restrict().Jan 9 2023, 7:15 AM
zlei edited the summary of this revision. (Show Details)
sys/kern/kern_jail.c
2050–2051

Type of redo_ip4 can be changed to bool and this expression reduced to:

redo_ip4 = !prison_ip_restrict(tpr, PR_INET, &ip4);

Same applies to redo_ip6.

I'm planning to do this on stable branches.

@glebius
Do you have any plans to MFC eb8dcdeac22d (and related fixes)?
If no I'd prefer commit this separately (from D37906) so it is easy to track and review.

sys/kern/kern_jail.c
2050–2051

Good catch!