Bug 268377 - jail -cr <jail> fails to set ipv6-address alias with ifconfig under certain conditions
Summary: jail -cr <jail> fails to set ipv6-address alias with ifconfig under certain c...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.1-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Jamie Gritton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-14 17:01 UTC by ahkithaama
Modified: 2022-12-18 00:41 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ahkithaama 2022-12-14 17:01:08 UTC
I have a jail-Configuration in /etc/jail.conf:

testjail {
    exec.start = "/bin/sh /etc/rc";
    exec.stop = "/bin/sh /etc/rc.shutdown";
    exec.clean;
    host.hostname = "testjail";
    path = "/VMs/jails/$name";
    interface = "msk0";
    ip6.addr = "fd9e:21a7:a92c:2323::1/40";
    mount = "/tmp  $path/tmp  nullfs  rw 0 0";
}


If I start the jail with
  jail -c testjail
-> No problem

If I stop the jail with
  jail -r testjail
-> No problem

If I restart a running jail with
  jail -cr testjail
-> I get following error:
testjail: run command: /sbin/ifconfig msk0 inet6 fd9e:21a7:a92c:2323::1/40 > alias
ifconfig: >: bad value
jail: testjail: /sbin/ifconfig msk0 inet6 fd9e:21a7:a92c:2323::1/40 > alias: failed

There's a invalid character ('>') in the ifconfig line.
Where it come from? I don't know.

The failure will not occur if I delete the "mount"-Line from the Configuration
(It doesn't matter have a 'mount'-Line or 'mount.fstab').

The failure will also not occur if I append the ifconfig-Parameter 'description' at the end of 'ip6-addr' like:
ip6.addr = "fd9e:21a7:a92c:2323::1/40 description a";

And the failure will only happen with ip6.addr
The same with ip4.addr is not a problem.

It seems to me there is a problem with string handling in the jail command.
Comment 1 Jamie Gritton freebsd_committer freebsd_triage 2022-12-15 00:47:51 UTC
There's a null pointer dereference in there.  It has actually been fixed for IP4 but missed IP6.
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-12-15 00:50:35 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e8d7ae918a105f252cf06249787d82f43e023ba8

commit e8d7ae918a105f252cf06249787d82f43e023ba8
Author:     Jamie Gritton <jamie@FreeBSD.org>
AuthorDate: 2022-12-15 00:47:55 +0000
Commit:     Jamie Gritton <jamie@FreeBSD.org>
CommitDate: 2022-12-15 00:47:55 +0000

    jail: fix a NULL pointer derefence in parsing ip6.addr settings.

    This is the counterpart to bd24e861b4ef, which did the same for ip4.
    PR:             268377
    Reported by:    ahkithaama at proton.me

 usr.sbin/jail/command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-12-18 00:32:47 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=47f21d91808c687e88f7f63930b73a893ce6d2a1

commit 47f21d91808c687e88f7f63930b73a893ce6d2a1
Author:     Jamie Gritton <jamie@FreeBSD.org>
AuthorDate: 2022-12-15 00:47:55 +0000
Commit:     Jamie Gritton <jamie@FreeBSD.org>
CommitDate: 2022-12-18 00:31:31 +0000

    jail: fix a NULL pointer derefence in parsing ip6.addr settings.

    This is the counterpart to bd24e861b4ef, which did the same for ip4.

    PR:             268377
    Reported by:    ahkithaama at proton.me

    (cherry picked from commit e8d7ae918a105f252cf06249787d82f43e023ba8)

 usr.sbin/jail/command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-12-18 00:33:48 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=561dcc7f3722315c55176be5611a010155724a89

commit 561dcc7f3722315c55176be5611a010155724a89
Author:     Jamie Gritton <jamie@FreeBSD.org>
AuthorDate: 2022-12-15 00:47:55 +0000
Commit:     Jamie Gritton <jamie@FreeBSD.org>
CommitDate: 2022-12-18 00:33:04 +0000

    jail: fix a NULL pointer derefence in parsing ip6.addr settings.

    This is the counterpart to bd24e861b4ef, which did the same for ip4.
    PR:             268377
    Reported by:    ahkithaama at proton.me

    (cherry picked from commit e8d7ae918a105f252cf06249787d82f43e023ba8)

 usr.sbin/jail/command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)