Fixes: eb8dcdeac22d jail: network epoch protection for IP address lists
Details
Run the following script:
#!/bin/sh ifconfig lo0 inet 172.16.0.1/32 alias ifconfig lo0 inet 172.16.0.2/32 alias ifconfig lo0 inet 172.16.0.3/32 alias ifconfig lo0 inet6 2001:db8::1/128 alias ifconfig lo0 inet6 2001:db8::2/128 alias ifconfig lo0 inet6 2001:db8::3/128 alias jail -c name=parent host.hostname=parent path=/ persist children.max=1 ip4.addr=172.16.0.1 ip4.addr=172.16.0.2 ip6.addr=2001:db8::1 ip6.addr=2001:db8::2 jexec parent /bin/sh -s stdin << EOF jail -c name=c1 host.hostname=c1 path=/ persist ip4=inherit ip6=inherit sleep 1 jls -j c1 jexec c1 ifconfig lo0 EOF sleep 1 jail -m name=parent ip4.addr=172.16.0.3 ip4.addr=172.16.0.1 ip6.addr=2001:db8::3 ip6.addr=2001:db8::1 sleep 1 echo "After modifying parent jail..." jls -j parent.c1 jexec parent.c1 ifconfig lo0
Then verify the output:
JID IP Address Hostname Path 8 172.16.0.1 c1 / lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6> inet6 2001:db8::1 prefixlen 128 inet6 2001:db8::2 prefixlen 128 inet 172.16.0.1 netmask 0xffffffff inet 172.16.0.2 netmask 0xffffffff groups: lo nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> After modifying parent jail... JID IP Address Hostname Path 8 172.16.0.3 c1 / lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6> inet6 2001:db8::1 prefixlen 128 inet6 2001:db8::3 prefixlen 128 inet 172.16.0.1 netmask 0xffffffff inet 172.16.0.3 netmask 0xffffffff groups: lo nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
Can also verify via DDB show prison
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
It would be nice to have the test script similar to the one in the testing section in our auto tests/.
Jails are complex beasts, so increasing the covered code scope would help detect regressions faster
sys/kern/kern_jail.c | ||
---|---|---|
817 | Would be good to have a comment on why the first address is skipped. |
sys/kern/kern_jail.c | ||
---|---|---|
817 |
I think that is the same with my explains in D37871 .
I'll dig into this. |
sys/kern/kern_jail.c | ||
---|---|---|
803 | While test jail -m to modify parent jail, kernel panics when child jail does not have either IPv4 or IPv6 addresses. So there're two bugs.
@melifaro Shall I fix the second bug separately ? | |
817 |
It works as intended. Well if there's no user settings, i.e. ip4=inherit or ip6=inherit, then it is safe to copy all addresses from parent to child. ips is set previously ips = (pr->pr_flags & pr_families[af].ip_flag) ? pip->ips : ppip->ips; . If new != NULL, then it is always allocated outside with the size of parent jail's ip adresses. |
sys/kern/kern_jail.c | ||
---|---|---|
803 |
On second thought, I think it deserves. |
sys/kern/kern_jail.c | ||
---|---|---|
803 |
It is introduced by eb8dcdeac22d . |
sys/kern/kern_jail.c | ||
---|---|---|
803 |
See D37906 . |
That's probably the best way, yes. I doubt that the server-side hooks will do the right thing though, so you may end up having to close one or both reviews manually.