Bug 245102 - jail(8) fails to parse ipv6 addr correctly
Summary: jail(8) fails to parse ipv6 addr correctly
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Some People
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-27 15:15 UTC by Sean Bruno
Modified: 2020-04-01 09:52 UTC (History)
2 users (show)

See Also:


Attachments
Jail configuration that manifests the error. (939 bytes, text/plain)
2020-03-27 15:15 UTC, Sean Bruno
no flags Details
Remove comments and command line faff. (867 bytes, text/plain)
2020-03-27 15:17 UTC, Sean Bruno
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Bruno freebsd_committer 2020-03-27 15:15:45 UTC
Created attachment 212755 [details]
Jail configuration that manifests the error.

Using the following jail.conf on a jail in the freebsd cluster, jail(8) fails to parse the ipv6 addr and refuses to start the jail.  This is a correct configuration and doesn't appear to fail anywhere else.  I'm unsure if this is some strange ARCH specific bug or jail(8) itself.


error in question:
root@thunderx2.nyi:/home/sbruno # /usr/sbin/jail -i -f /var/run/jail.ref13-aarch64.conf -c ref13-aarch64
jail: ref13-aarch64: ip6.addr: not an IPv6 address: 2610:1c1:1:16:96
Comment 1 Sean Bruno freebsd_committer 2020-03-27 15:17:00 UTC
Created attachment 212756 [details]
Remove comments and command line faff.
Comment 2 Sean Bruno freebsd_committer 2020-03-28 17:31:07 UTC
Andy created a patch that fixes this issue.  I have tested and verified it on thunderx2 in the freebsd cluster.

It was also tested/verifed on several other ARM devices in #bsdmips.

https://people.freebsd.org/~andrew/0001-Use-memmove-to-copy-within-a-buffer.patch
Comment 3 commit-hook freebsd_committer 2020-04-01 09:52:18 UTC
A commit references this bug:

Author: andrew
Date: Wed Apr  1 09:51:30 UTC 2020
New revision: 359505
URL: https://svnweb.freebsd.org/changeset/base/359505

Log:
  Use memmove to copy within a buffer

  jail(8) would try to use strcpy to remove the interface from the start of
  an IP address. This is undefined, and on arm64 will result in unexpected
  IPv6 addresses.

  Fix this by using memmove top move the string.

  PR:		245102
  Reported by:	sbruno
  MFC after:	2 weeks
  Sponsored by:	Innovate UK

Changes:
  head/usr.sbin/jail/config.c