SynoCommunity / spksrc

Cross compilation framework to create native packages for the Synology's NAS
https://synocommunity.com
Other
3.04k stars 1.23k forks source link

nmap FAILED: Kernel doesn't support memory-mapped capture #6256

Closed mariopaumann closed 1 month ago

mariopaumann commented 1 month ago

Is this a new Bug?

Package Name

nmap

Package Version

SynoCli Network Tools 2.4-18

Device Model

DS111

Device Architecture

ARMv5

Firmware Version

DSM 6.2.4-25556 Update 7

What happened?

Since a few days nmap shows

/usr/local/bin/nmap -n -sn 192.168.0.*
Starting Nmap 7.94 ( https://nmap.org ) at 2024-10-05 22:21 CEST
pcap_activate(eth0) FAILED: Kernel doesn't support memory-mapped capture; a 2.6.27 or later 2.x kernel is required, with CONFIG_PACKET_MMAP specified for 2.x kernels.
Call to pcap_open_live() failed three times. There are several possible reasons for this, depending on your operating system:
LINUX: If you are getting Socket type not supported, try modprobe af_packet or recompile your kernel with PACKET enabled.
 *BSD:  If you are getting device not configured, you need to recompile your kernel with Berkeley Packet Filter support.  If you are getting No such file or directory, try creating the device (eg cd /dev; MAKEDEV <device>; or use mknod).
*WINDOWS:  Nmap only supports ethernet interfaces on Windows for most operations because Microsoft disabled raw sockets as of Windows XP SP2.  Depending on the reason for this error, it is possible that the --unprivileged command-line argument will help.
SOLARIS:  If you are trying to scan localhost or the address of an interface and are getting '/dev/lo0: No such file or directory' or 'lo0: No DLPI device found', complain to Sun.  I don't think Solaris can support advanced localhost scans.  You can probably use "-Pn -sT localhost" though.

i think it is because SynoCli Network Tools may have been updated automatically. For DSM there is no update anymore so the kernel is the same and the command worked for years since last tuesday.

Reproduction steps

  1. /usr/local/bin/nmap -n -sn
  2. ...

Install Log

...

2024/07/20 09:23:49 (system) trigger synocli-net 2.3-17 Begin start-stop-status start
2024/07/20 09:23:49 (system) trigger synocli-net 2.3-17 End start-stop-status start ret=[0]
2024/10/05 10:58:10 upgrade synocli-net 2.3-17 Begin start-stop-status stop
2024/10/05 10:58:10 upgrade synocli-net 2.3-17 End start-stop-status stop ret=[0]
2024/10/05 10:58:12 upgrade synocli-net 2.3-17 Begin preupgrade
2024/10/05 10:58:12 Begin initialize_variables
2024/10/05 10:58:12 End initialize_variables
2024/10/05 10:58:12 ===> Step preupgrade. STATUS=UPGRADE USER= GROUP= SHARE_PATH=
2024/10/05 10:58:12 upgrade synocli-net 2.3-17 End preupgrade ret=[0]
2024/10/05 10:58:12 upgrade synocli-net 2.3-17 Begin preuninst
2024/10/05 10:58:13 Begin load_variables_from_file
2024/10/05 10:58:13 End load_variables_from_file
2024/10/05 10:58:13 Begin initialize_variables
2024/10/05 10:58:13 End initialize_variables
2024/10/05 10:58:13 ===> Step preuninst. STATUS=UPGRADE USER= GROUP= SHARE_PATH=
2024/10/05 10:58:13 upgrade synocli-net 2.3-17 End preuninst ret=[0]
2024/10/05 10:58:13 upgrade synocli-net 2.3-17 Begin /bin/rm -rf /volume1/@appstore/synocli-net
2024/10/05 10:58:16 upgrade synocli-net 2.3-17 End /bin/rm -rf /volume1/@appstore/synocli-net ret=[0]
2024/10/05 10:58:17 upgrade synocli-net 2.3-17 Begin postuninst
2024/10/05 10:58:17 Begin load_variables_from_file
2024/10/05 10:58:17 End load_variables_from_file
2024/10/05 10:58:17 Begin initialize_variables
2024/10/05 10:58:17 End initialize_variables
2024/10/05 10:58:18 ===> Step postuninst. STATUS=UPGRADE USER= GROUP= SHARE_PATH=
2024/10/05 10:58:18 upgrade synocli-net 2.3-17 End postuninst ret=[0]
2024/10/05 10:58:19 upgrade synocli-net 2.4-18 Begin preinst
2024/10/05 10:58:19 Begin initialize_variables
2024/10/05 10:58:19 End initialize_variables
2024/10/05 10:58:19 ===> Step preinst. STATUS=UPGRADE USER= GROUP= SHARE_PATH=
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 End preinst ret=[0]
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 Begin /bin/rm -rf /volume1/@appstore/synocli-net
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 End /bin/rm -rf /volume1/@appstore/synocli-net ret=[0]
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/package /volume1/@appstore/synocli-net
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 End /bin/mv -f /volume1/@tmp/pkginstall/package /volume1/@appstore/synocli-net ret=[0]
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 Begin /bin/mkdir -p /var/packages/synocli-net
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 End /bin/mkdir -p /var/packages/synocli-net ret=[0]
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/INFO /var/packages/synocli-net/INFO
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 End /bin/mv -f /volume1/@tmp/pkginstall/INFO /var/packages/synocli-net/INFO ret=[0]
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 Begin /bin/rm -rf /var/packages/synocli-net/scripts
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 End /bin/rm -rf /var/packages/synocli-net/scripts ret=[0]
2024/10/05 10:58:20 upgrade synocli-net 2.4-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/scripts /var/packages/synocli-net/scripts
2024/10/05 10:58:21 upgrade synocli-net 2.4-18 End /bin/mv -f /volume1/@tmp/pkginstall/scripts /var/packages/synocli-net/scripts ret=[0]
2024/10/05 10:58:21 upgrade synocli-net 2.4-18 Begin /bin/rm -rf /var/packages/synocli-net/conf
2024/10/05 10:58:21 upgrade synocli-net 2.4-18 End /bin/rm -rf /var/packages/synocli-net/conf ret=[0]
2024/10/05 10:58:21 upgrade synocli-net 2.4-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/conf /var/packages/synocli-net/conf
2024/10/05 10:58:21 upgrade synocli-net 2.4-18 End /bin/mv -f /volume1/@tmp/pkginstall/conf /var/packages/synocli-net/conf ret=[0]
2024/10/05 10:58:21 upgrade synocli-net 2.4-18 Begin postinst
2024/10/05 10:58:22 Begin initialize_variables
2024/10/05 10:58:22 End initialize_variables
2024/10/05 10:58:22 ===> Step postinst. STATUS=UPGRADE USER= GROUP= SHARE_PATH=
2024/10/05 10:58:22 Begin save_wizard_variables
2024/10/05 10:58:22 End save_wizard_variables
2024/10/05 10:58:22 upgrade synocli-net 2.4-18 End postinst ret=[0]
2024/10/05 10:58:22 upgrade synocli-net 2.4-18 Begin postupgrade
2024/10/05 10:58:22 Begin initialize_variables
2024/10/05 10:58:22 End initialize_variables
2024/10/05 10:58:22 ===> Step postupgrade. STATUS=UPGRADE USER= GROUP= SHARE_PATH=
2024/10/05 10:58:23 upgrade synocli-net 2.4-18 End postupgrade ret=[0]
2024/10/05 10:58:30 upgrade synocli-net 2.4-18 Begin start-stop-status start
2024/10/05 10:58:30 upgrade synocli-net 2.4-18 End start-stop-status start ret=[0]
2024/10/05 10:58:35 upgrade synocli-net 2.4-18 Begin /bin/rm -rf /volume1/@tmp/pkginstall
2024/10/05 10:58:35 upgrade synocli-net 2.4-18 End /bin/rm -rf /volume1/@tmp/pkginstall ret=[0]
2024/10/05 10:59:52 (system) trigger synocli-net 2.4-18 Begin start-stop-status stop
2024/10/05 10:59:52 (system) trigger synocli-net 2.4-18 End start-stop-status stop ret=[0]
2024/10/05 11:02:57 (system) trigger synocli-net 2.4-18 Begin start-stop-status start
2024/10/05 11:02:58 (system) trigger synocli-net 2.4-18 End start-stop-status start ret=[0]

Service Log

...

Wed Apr  7 06:49:05 CEST 2021
===> Step postinst. USER= GROUP= SHARE_PATH=
Invoke service_create_links
create link: /usr/local/bin/screen -> /volume1/@appstore/synocli-net/bin/screen
create link: /usr/local/bin/tmux -> /volume1/@appstore/synocli-net/bin/tmux
create link: /usr/local/bin/nmap -> /volume1/@appstore/synocli-net/bin/nmap
create link: /usr/local/bin/nping -> /volume1/@appstore/synocli-net/bin/nping
create link: /usr/local/bin/ndiff -> /volume1/@appstore/synocli-net/bin/ndiff
create link: /usr/local/bin/arp-scan -> /volume1/@appstore/synocli-net/bin/arp-scan
create link: /usr/local/bin/arp-fingerprint -> /volume1/@appstore/synocli-net/bin/arp-fingerprint
create link: /usr/local/bin/get-iab -> /volume1/@appstore/synocli-net/bin/get-iab
create link: /usr/local/bin/get-oui -> /volume1/@appstore/synocli-net/bin/get-oui
create link: /usr/local/bin/links -> /volume1/@appstore/synocli-net/bin/links
create link: /usr/local/bin/sshfs -> /volume1/@appstore/synocli-net/bin/sshfs
create link: /usr/local/bin/fusermount -> /volume1/@appstore/synocli-net/bin/fusermount
create link: /usr/local/bin/socat -> /volume1/@appstore/synocli-net/bin/socat
create link: /usr/local/bin/procan -> /volume1/@appstore/synocli-net/bin/procan
create link: /usr/local/bin/filan -> /volume1/@appstore/synocli-net/bin/filan
create link: /usr/local/bin/fritzctl -> /volume1/@appstore/synocli-net/bin/fritzctl
create link: /usr/local/bin/rsync -> /volume1/@appstore/synocli-net/bin/rsync
create link: /usr/local/bin/autossh -> /volume1/@appstore/synocli-net/bin/autossh
create link: /usr/local/bin/scp -> /volume1/@appstore/synocli-net/bin/scp
create link: /usr/local/bin/sftp -> /volume1/@appstore/synocli-net/bin/sftp
create link: /usr/local/bin/slogin -> /volume1/@appstore/synocli-net/bin/slogin
create link: /usr/local/bin/ssh -> /volume1/@appstore/synocli-net/bin/ssh
create link: /usr/local/bin/ssh-add -> /volume1/@appstore/synocli-net/bin/ssh-add
create link: /usr/local/bin/ssh-agent -> /volume1/@appstore/synocli-net/bin/ssh-agent
create link: /usr/local/bin/ssh-keygen -> /volume1/@appstore/synocli-net/bin/ssh-keygen
create link: /usr/local/bin/ssh-keyscan -> /volume1/@appstore/synocli-net/bin/ssh-keyscan
create link: /usr/local/libexec/sftp-server -> /volume1/@appstore/synocli-net/libexec/sftp-server
create link: /usr/local/libexec/ssh-keysign -> /volume1/@appstore/synocli-net/libexec/ssh-keysign
create link: /usr/local/libexec/ssh-pkcs11-helper -> /volume1/@appstore/synocli-net/libexec/ssh-pkcs11-helper
create link: /usr/local/libexec/ssh-sk-helper -> /volume1/@appstore/synocli-net/libexec/ssh-sk-helper
create link: /usr/local/sbin/sshd -> /volume1/@appstore/synocli-net/sbin/sshd
create link: /usr/local/sbin/ser2net -> /volume1/@appstore/synocli-net/sbin/ser2net
Wed Apr  7 06:49:09 CEST 2021

Other Logs

No response

hgy59 commented 1 month ago

@mariopaumann we didn't change nmap since synocli-net v2.3-17

Can you downgrade to synocli-net v2.3-17?

If it still works with synocli-net v2.3-17, then we need some further investigation.

Since we have changed the development environment from debian 11 to debian 12 it might be related to the build environment. Alas I have a DSM-210+ with DSM 5.2 that works with synocli-net v2.3-17 and v2.4-18 It has kernel version 2.6.32.12 But this is a system with ppc853x CPU and is limitted to nmap v7.92 (instead of current 7.94)

Another difference is, that all pulblished synocli-net packages until rev -17 are built on local build environment, only rev -18 was built by github build actions (and deployed by @mreid-tt)

summary:

BTW: DSM does not support automatic update of thirdparty packages, you must have manually started the update of synocli-net from 2.3-17 to 2.4-18

mreid-tt commented 1 month ago

Hey @hgy59, looking back, I published the synocli-net package on behalf of @th0ma7 as part of PR #6239. However, upon reviewing the actual PR, I noticed that there were no changes made to synocli-net. It seems a dependency update triggered the build, and I mistakenly assumed it was an intentional update. Apologies for the confusion.

I also checked the previous PR #5985, which proposed synocli-net v2.4-18, but it doesn't appear to have been published. Was the release held back deliberately? If that's the case, I can go ahead and disable it in the repo.

th0ma7 commented 1 month ago

Hey @hgy59, looking back, I published the synocli-net package on behalf of @th0ma7 as part of PR #6239. However, upon reviewing the actual PR, I noticed that there were no changes made to synocli-net. It seems a dependency update triggered the build, and I mistakenly assumed it was an intentional update. Apologies for the confusion.

I also checked the previous PR #5985, which proposed synocli-net v2.4-18, but it doesn't appear to have been published. Was the release held back deliberately? If that's the case, I can go ahead and disable it in the repo.

I confirm, synocli-net was not planned for release part of my pr. But i recall fixing libudev build for dsm-7.2 which must have triggered it.

hgy59 commented 1 month ago

I confirm, synocli-net was not planned for release part of my pr. But i recall fixing libudev build for dsm-7.2 which must have triggered it.

I think I just forgot to publish it (half a year ago)...

I did not my regular synocli package tests, but at least nmap does not have the kernel issue reported here, tested on three different systems with kernel versions 2.6,32.12, 3.2.110 and 4.4.59+.

mariopaumann commented 1 month ago

@hgy59 i tested it again. it works with 2.3-17 and stops working with 2.4-18.

you're right i manually updated the package after it gave me a update notification.

mreid-tt commented 1 month ago

@hgy59, @th0ma7, one of the last changes I noted in #5820 (Aug 12, 2023) for nmap was the move from:

https://github.com/SynoCommunity/spksrc/blob/82f26f31f4cdf142dfdffdaf9cebdb222cec0ad0/cross/nmap/Makefile#L8

to

https://github.com/SynoCommunity/spksrc/blob/7366599d654fe14f8c942a30b36b469dc4e2281f/cross/nmap/Makefile#L8

Would the change to openssl3 be possibly contributing to this? I know there is at least one patch for that package which treats with the special needs of 88f628x CPU archs:

https://github.com/SynoCommunity/spksrc/blob/7366599d654fe14f8c942a30b36b469dc4e2281f/cross/openssl3/patches/88f6281/001-avoid-the-use-of-libatomic.patch#L1

EDIT: Alternatively, this could be due to a change in the libpcap requirements, as it was associated with #5985:

https://github.com/SynoCommunity/spksrc/blob/82f26f31f4cdf142dfdffdaf9cebdb222cec0ad0/cross/libpcap/Makefile#L2

to

https://github.com/SynoCommunity/spksrc/blob/7366599d654fe14f8c942a30b36b469dc4e2281f/cross/libpcap/Makefile#L2

hgy59 commented 1 month ago

@mariopaumann for futher analysis I have created various packages downloadable under releases in my fork https://github.com/hgy59/spksrc/releases/tag/synocli-net-dev

The packages with nmap only can be installed side by side to synocli-net. So far I created nmap 7.92 and 7.94 in the current (debian 12) and in debian 11 environment.

can you please validate all of them?

After final uninstall of the nmap packages, you have to install synocli-net again to restore the symlinks to the nmap binaries (nmap package overwrites the links and removes those on uninstall).

hgy59 commented 1 month ago

@mariopaumann based on the latest recognition, I built a nmap package built with older libpcap for armv5 (libpcap 1.10.1). This is expected to work. (latest package in link above).

mariopaumann commented 1 month ago

@hgy59

7.92 packages are working. 7.94 are not working. regardless of which debian build release.

the last one with pcap 1.10.1 crashes with coredump

root@ds111:~# /volume1/@appstore/nmap/bin/nmap -n -sn 192.168.0.* Starting Nmap 7.94 ( https://nmap.org ) at 2024-10-09 19:49 CEST glibc detected /volume1/@appstore/nmap/bin/nmap: double free or corruption (out): 0x003c3598 *** ======= Backtrace: ========= /lib/libc.so.6(+0x6f5b4)[0x407ec5b4] /var/packages/nmap/target/lib/libpcap.so.1(+0x490c)[0x4003590c] /var/packages/nmap/target/lib/libpcap.so.1(+0x5bec)[0x40036bec] /var/packages/nmap/target/lib/libpcap.so.1(pcap_activate+0x24)[0x4003a108] ... 40906000-40907000 rwxp 0000d000 08:01 17744 /usr/lib/libnss_files-2.15.so befd1000-befe6000 rw-p 00000000 00:00 0 [stack] Aborted (core dumped)

hgy59 commented 1 month ago

@mariopaumann thanks for testing. So I will try to create another package with nmap 7.94 and libpcap 1.9.1 (this version of libpcap is used in combination with nmap 7.92) If this does not work either, we will have to fallback to nmap 7.92 for ARMv5 packages.

hgy59 commented 1 month ago

@mariopaumann nmap 7.94 with libpcap 1.9.1 is ready for testing...

mariopaumann commented 1 month ago

@hgy59 nmap 7.94 with libpcap 1.9.1 is working

th0ma7 commented 1 month ago

There is a libpcap 1.10.5 btw, maybe this got fixed?

hgy59 commented 1 month ago

There is a libpcap 1.10.5 btw, maybe this got fixed?

no, not for ARMv5. This is by design that libpcap >= 1.10.2 does not work for 2.x kernels when kernel does not include the MMAP package. So I limitted libpcap for ARMv5 to version 1.9.1 and nmap 7.94 works. This is the current state in #6269

th0ma7 commented 1 month ago

Ah, that explains!

mariopaumann commented 3 weeks ago

@hgy59 thank you. i updated to latest synocli network tools and it's fine for me now. 👍