dhcpcd-discuss

Re: v8 to v9.3.3 segmentation fault on linux

Roy Marples

Mon Nov 23 14:24:13 2020

On 23/11/2020 13:51, [anp/hsw] wrote:
I have just fixed this here:
https://roy.marples.name/cgit/dhcpcd.git/commit/?id=fbb4dc4280fc14847c79db8f249736ddb3cd797f

Just checked: no more crash, but it seems like stuck in the loop.
I used oneshot (-1) option so dhcpcd must exit.

-1, --oneshot
             Exit after configuring an interface.


(gdb) run
Starting program: /tmp/dhcpcd -nBpEAKLGdd14 -h system -t 0 -l 3600
-c /etc/dhcpcd/dynamic-eth0.1446 eth0.1446
read_config: /etc/dhcpcd.conf: No such file or directory
no such user dhcpcd
main: control_open: Connection refused
dhcpcd-9.3.3 starting
DUID 00:04:49:43:4d:53:02:00:90:13:25:00:13:90:25:00:c4:84
read_config: /etc/dhcpcd.conf: No such file or directory
eth0.1446: executing: /etc/dhcpcd/dynamic-eth0.1446 PREINIT
eth0.1446: delaying IPv4 for 2.0 seconds
eth0.1446: using hwaddr 00:a0:d1:cf:de:34
eth0.1446: reading lease: /var/lib/dhcpcd/eth0.1446.lease
eth0.1446: rebinding lease of 192.168.168.51
eth0.1446: sending REQUEST (xid 0xf18bbd74), next in 3.8 seconds
eth0.1446: acknowledged 192.168.168.51 from 80.89.133.227
eth0.1446: leased 192.168.168.51 for 3600 seconds
eth0.1446: renew in 1800 seconds, rebind in 3150 seconds
eth0.1446: writing lease: /var/lib/dhcpcd/eth0.1446.lease
eth0.1446: adding IP address 192.168.168.51/24 broadcast 192.168.168.255
ipv4_addaddr: if_addaddress: Invalid argument

<i waited about one minute and pressed ctrl-c>
^C
Program received signal SIGINT, Interrupt.
0xb7fdc428 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fdc428 in __kernel_vsyscall ()
#1  0xb7f0a31f in ppoll () from /lib/libc.so.6
#2  0x80012599 in eloop_start (eloop=0x8008db78, signals=0xbffffa78) at
eloop.c:739
#3  0x8001035f in main (argc=11, argv=0xbffffcd4, envp=0xbffffd04) at
dhcpcd.c:2518
(gdb)

The interface was not configured due to an error and as such dhcpcd did not exit.

I would advise fixing the error either by matching your kernel headers with the running kernel or by disabling IFA_F_NOPREFIXROUTE in if-linux.c.

You could also give -t a possitive value to force a timeout.

This patch may also help, but you would then need to test the exit code of dhcpcd to know if it was a success or failure.

Let me know if this is ok or not.

Roy

diff --git a/src/dhcp.c b/src/dhcp.c
index fdfd8b3d..ad7bd726 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -2365,8 +2365,13 @@ dhcp_bind(struct interface *ifp)
        }

        /* Add the address */
-       if (ipv4_applyaddr(ifp) == NULL)
+       if (ipv4_applyaddr(ifp) == NULL) {
+               if (ctx->options & DHCPCD_ONESHOT) {
+                       loginfox("exiting due to oneshot");
+                       eloop_exit(ctx->eloop, EXIT_FAILURE);
+               }
                return;
+       }

        /* Close the BPF filter as we can now receive DHCP messages
         * on a UDP socket. */

Follow-Ups:
Re: v8 to v9.3.3 segmentation fault on linux[anp/hsw]
References:
v8 to v9.3.3 segmentation fault on linux[anp/hsw]
Re: v8 to v9.3.3 segmentation fault on linuxRoy Marples
Re: v8 to v9.3.3 segmentation fault on linuxRoy Marples
Re: v8 to v9.3.3 segmentation fault on linux[anp/hsw]
Archive administrator: postmaster@marples.name