[Bug 268378] parsing error in network.subr can result in infinite loop on bootup

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 14 Dec 2022 18:15:52 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268378

            Bug ID: 268378
           Summary: parsing error in network.subr can result in infinite
                    loop on bootup
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: conf
          Assignee: bugs@FreeBSD.org
          Reporter: jyoung15@gmail.com

Created attachment 238789
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=238789&action=edit
network.subr ifalias_af_common_handler patch

While testing CARP as described in the handbook
(https://docs.freebsd.org/en/books/handbook/advanced-networking/#carp), I
discovered the system hangs on bootup if the passphrase contains only hex
characters and a hyphen (-).

Example from the handbook:

ifconfig_em0="inet 192.168.1.3 netmask 255.255.255.0"
ifconfig_em0_alias0="inet vhid 1 pass testpass alias 192.168.1.50/32"

If instead of "testpass" something like "abc-def" is used, it will trigger this
issue.

The issue was traced to ifalias_af_common_handler in network.subr.

Line 1050 seems to have a typo with a miscellaneous closing brace
("$_tmpargs}"), however the issue is with the shell pattern matching at line
1052:

${_af}\ *[0-9a-fA-F]-*)

This is intended to match the address range specification as described in
rc.conf(5) (see man page starting at "It also possible to configure multiple IP
addresses").

However, it also matches other scenarios such as the CARP example above.

Due to the limitations of shell pattern matching, it may be better to use
regular expression matching using expr(1).  Attached is a proposed patch file
with more strict matching based on the examples in the rc.conf(5) description.

-- 
You are receiving this mail because:
You are the assignee for the bug.