iproute2 >= 4.19.0 batch mode broken
Hi there, I'm having a problem with alpine 3.9 and 3.10 with iproute2, specifically with tc command.
When I run tc -b
(batch mode) I'm receiving Segmentation fault, but if I run the file line by line, without batch mode, everything works great... Until 3.8 tc worked fine so, the problem is with the new versions.
I tried 5.2.0 (from edge) too with the same problem.
Here the error trace:
$ strace tc -b /usr/src/app/scripts/tc_ifb0
execve("/sbin/tc", ["tc", "-b", "/usr/src/app/scripts/tc_ifb0"], 0x7ffc03196890 /* 17 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7f56202d0d48) = 0
set_tid_address(0x7f56202d131c) = 8034
open("/etc/ld-musl-x86_64.path", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib/libxtables.so.12", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libxtables.so.12", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libxtables.so.12", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=50840, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\2306\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 57344, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5620232000
mmap(0x7f5620235000, 24576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0x3000) = 0x7f5620235000
mmap(0x7f562023b000, 12288, PROT_READ, MAP_PRIVATE|MAP_FIXED, 3, 0x9000) = 0x7f562023b000
mmap(0x7f562023e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xb000) = 0x7f562023e000
close(3) = 0
mprotect(0x7f562023e000, 4096, PROT_READ) = 0
mprotect(0x7f56202cd000, 4096, PROT_READ) = 0
mprotect(0x563306fdd000, 8192, PROT_READ) = 0
open("/usr/src/app/scripts/tc_ifb0", O_RDONLY) = 3
dup2(3, 0) = 0
close(3) = 0
open("/proc/net/psched", O_RDONLY) = 3
read(3, "000003e8 00000040 000f4240 3b9ac"..., 1024) = 36
lseek(3, -10, SEEK_CUR) = 26
close(3) = 0
socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) = 3
setsockopt(3, SOL_SOCKET, SO_SNDBUF, [32768], 4) = 0
setsockopt(3, SOL_SOCKET, SO_RCVBUF, [1048576], 4) = 0
setsockopt(3, SOL_NETLINK, NETLINK_EXT_ACK, [1], 4) = 0
bind(3, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, nl_pid=8034, nl_groups=00000000}, [12]) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x5cf81bc4} ---
+++ killed by SIGSEGV +++
Segmentation fault
In dmesg:
[Mon Sep 30 16:15:48 2019] tc[16372]: segfault at 60 ip 00007f36bb86e244 sp 00007ffd7446e870 error 4 in ld-musl-x86_64.so.1[7f36bb860000+46000]
[Mon Sep 30 16:15:48 2019] Code: 75 10 48 89 f7 e8 ec 1d ff ff 48 89 c3 e9 4a 01 00 00 48 89 fb 48 8d 7c 24 08 e8 b8 f5 ff ff 85 c0 79 07 31 db e9 32 01 00 00 <48> 8b 43 f8 4
c 8d 6b f0 48 89 c5 48 83 e5 fe a8 01 0f 85 8f 00 00
If I clone the iproute2 repo and compile it, everything works again.
Tested with Kernel 4.19.75-0-vanilla.
Steps To reproduce
$ apk add iproute2 (in alpine 3.9, 3.10 or edge)
$ touch empty_file
$ tc -b empty_file # => will raise segmentation fault
If you need anything else let me know
Cheers Néstor