system/net-tools: device memory range may be truncated to 32-bits
Compare the kernel output:
root@aarch64-1:~# cat /sys/module/igb/drivers/pci\:igb/0002\:01\:00.0/resource
0x0000001030000000 0x00000010300fffff 0x0000000000040200
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000001030200000 0x0000001030203fff 0x0000000000040200
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000001030100000 0x00000010301fffff 0x0000000000046200
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
to our current net-tools
package:
root@aarch64-1:~# setarch linux32 chroot x ifconfig enP2p1s0
enP2p1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 140.211.9.227 netmask 255.255.255.0 broadcast 140.211.9.255
inet6 2605:bc80:3010:104::8cd3:9e3 prefixlen 64 scopeid 0x0<global>
inet6 fe80::21b:21ff:fedc:4eb3 prefixlen 64 scopeid 0x20<link>
ether 00:1b:21:dc:4e:b3 txqueuelen 1000 (Ethernet)
RX packets 12089330 bytes 7057828892 (6.5 GiB)
RX errors 0 dropped 534 overruns 532 frame 0
TX packets 958695 bytes 84581028 (80.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0x30000000-300fffff
to the Toybox output:
root@aarch64-1:~# ./toybox-aarch64 ifconfig enP2p1s0
enP2p1s0 Link encap:Ethernet HWaddr 00:1b:21:dc:4e:b3 Driver igb
inet addr:140.211.9.227 Bcast:140.211.9.255 Mask:255.255.255.0
inet6 addr: 2605:bc80:3010:104::8cd3:9e3/64 Scope: Global
inet6 addr: fe80::21b:21ff:fedc:4eb3/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12089535 errors:0 dropped:534 overruns:532 frame:0
TX packets:958733 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7057846040 TX bytes:84587448
Memory:1030000000-10300fffff
It seems the net-tools
version prints only 8 characters, or 32 bits.
Relevant snippet:
if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
ptr->map.base_addr >= 0x100)) {
printf(" device ");
if (ptr->map.irq)
printf(_("interrupt %d "), ptr->map.irq);
if (ptr->map.base_addr >= 0x100) /* Only print devices using it for
I/O maps */
printf(_("base 0x%x "), ptr->map.base_addr);
if (ptr->map.mem_start) {
printf(_("memory 0x%lx-%lx "), ptr->map.mem_start, ptr->map.mem_end);
}
if (ptr->map.dma)
printf(_(" dma 0x%x"), ptr->map.dma);
printf("\n");
}
printf("\n");
This happens inside if_fetch()
:
safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0)
memset(&ife->map, 0, sizeof(struct ifmap));
else
memcpy(&ife->map, &ifr.ifr_map, sizeof(struct ifmap));
and the value is already truncated by this point.
Further reading: