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
F154025724: D37918.diff
Sat, Apr 25, 1:44 PM
F153967390: D37918.diff
Sat, Apr 25, 4:09 AM
Unknown Object (File)
Wed, Apr 22, 12:54 AM
Unknown Object (File)
Tue, Apr 21, 6:29 PM
Unknown Object (File)
Mon, Apr 20, 2:01 PM
Unknown Object (File)
Mon, Apr 20, 2:14 AM
Unknown Object (File)
Tue, Apr 14, 12:43 PM
Unknown Object (File)
Sat, Apr 11, 8:19 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!