Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flood of recvfrom(udp): Bad address #655

Open
enihcam opened this issue May 7, 2023 · 17 comments
Open

flood of recvfrom(udp): Bad address #655

enihcam opened this issue May 7, 2023 · 17 comments
Assignees

Comments

@enihcam
Copy link

enihcam commented May 7, 2023

I often get flood recvfrom(udp): Bad address.

May 03 19:56:09 miniupnpd[390]: HTTP listening on port 7971
May 03 22:05:28 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:05:28 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:05:55 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:05:58 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:07 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:10 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:10 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:16 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:16 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:25 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:37 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:52 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:58 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:06:58 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:07 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:28 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:34 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:37 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:37 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:40 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:43 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:46 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:52 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:07:58 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:08:04 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:08:04 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:08:16 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:08:28 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:08:28 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:08:37 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:08:37 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:08:49 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:08:58 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:04 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:04 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:13 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:16 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:22 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:28 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:37 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:37 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:40 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:40 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:43 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:46 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:46 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:55 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:09:58 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:10:01 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:10:07 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:10:10 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:10:13 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:10:13 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:10:13 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:10:16 miniupnpd[390]: recvfrom(udp): Bad address
May 03 22:10:19 miniupnpd[390]: recvfrom(udp): Bad address

then i turned on the debug flag and got this:

May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: level=0 type=8
May 05 22:36:26 miniupnpd[1715]: ifindex = 8  192.168.0.1
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: recvfrom(udp): Bad address
May 05 22:36:26 miniupnpd[1715]: miniupnpd[1715]: recvfrom(udp): Bad address
May 05 22:36:26 miniupnpd[1715]: recvfrom(udp): Bad address
May 05 22:36:26 miniupnpd[1715]: recvfrom(udp): Bad address

any suggestions? thanks.

@miniupnp miniupnp self-assigned this May 8, 2023
@miniupnp
Copy link
Owner

miniupnp commented May 8, 2023

@enihcam it is difficult to know which argument of the recvmsg()/recvfrom() call is a bad address :(

https://github.com/miniupnp/miniupnp/blob/master/miniupnpd/minissdp.c#L902

@miniupnp
Copy link
Owner

miniupnp commented May 8, 2023

they all are stack buffers 🤔

@enihcam
Copy link
Author

enihcam commented May 8, 2023

@enihcam it is difficult to know which argument of the recvmsg()/recvfrom() call is a bad address :(

https://github.com/miniupnp/miniupnp/blob/master/miniupnpd/minissdp.c#L902

I'm using archlinux, so the compile flags can be found here:
https://github.com/archlinux/svntogit-community/blob/packages/miniupnpd/trunk/PKGBUILD

@enihcam
Copy link
Author

enihcam commented May 9, 2023

the issue can be reproduced without using mimalloc or any memory allocators, so i guess it's probably not a memory management issue.

miniupnp added a commit that referenced this issue May 10, 2023
@miniupnp
Copy link
Owner

the issue can be reproduced without using mimalloc or any memory allocators, so i guess it's probably not a memory management issue.

As I said, all buffers passed to recvmsg() are on the stack, not on the heap.

So that's really strange that it makes the error "Bad address" randomly :(

@enihcam
Copy link
Author

enihcam commented May 11, 2023

looks like it was my newly installed DLNA server listening on the same UDP port as miniupnpd.

~ $ sudo ss -alnp | grep 1900
udp   UNCONN 1855488 0                                         0.0.0.0:1900             0.0.0.0:*    users:(("dms",pid=1165,fd=4))                                                          
udp   UNCONN 0       0                                     0.0.0.0%br0:1900             0.0.0.0:*    users:(("miniupnpd",pid=381,fd=5))

@miniupnp so what's the best practice (or your suggestion) for miniupnpd co-existing with local DLNA server?

btw i also asked similar question at anacrolix/dms#122

@miniupnp
Copy link
Owner

my suggestion is using minissdpd.

@enihcam
Copy link
Author

enihcam commented May 11, 2023

my suggestion is using minissdpd.

can i just use minissdpd without patching dms?

@miniupnp
Copy link
Owner

my suggestion is using minissdpd.

can i just use minissdpd without patching dms?

I don't think so ;)

But patching should not be so difficult ;)

@miniupnp
Copy link
Owner

@enihcam is that dms ? https://github.com/anacrolix/dms

@miniupnp
Copy link
Owner

@enihcam here is the patch : miniupnp/dms@b4b27b7

@miniupnp
Copy link
Owner

@enihcam can you test it ?

If it is working, I will finish it (add configuration option for minissdpd socket path) and submit a Pull Request upstream.

@enihcam
Copy link
Author

enihcam commented May 13, 2023

@enihcam can you test it ?

If it is working, I will finish it (add configuration option for minissdpd socket path) and submit a Pull Request upstream.

I'm out of town for few days. will update you asap.

@enihcam
Copy link
Author

enihcam commented May 20, 2023

@enihcam can you test it ?

If it is working, I will finish it (add configuration option for minissdpd socket path) and submit a Pull Request upstream.

test result:

auser@ahost /etc/systemd/system $ sudo systemctl status dms.service
● dms.service - DMS UPnP Media Server
     Loaded: loaded (/etc/systemd/system/dms.service; disabled; preset: disabled)
     Active: active (running) since Sat 2023-05-20 13:03:15 UTC; 1min 20s ago
   Main PID: 3213 (dms)
     CGroup: /system.slice/dms.service
             └─3213 /usr/bin/dms -allowedIps 192.168.0.0/24 -fFprobeCachePath /tmp/dms-ffprobe-cache -friendlyName Movies -ifname lo -noProbe -noTranscode -path /home/auser/Share/

May 20 13:03:15 ahost dms[3213]: 2023/05/20 13:03:15 ffprobe and avprobe not found in $PATH
May 20 13:03:15 ahost dms[3213]: 2023-05-20T13:03:15+0000 NIL [main main.mainErr:170]: allowed ip nets are ["192.168.0.0/24"]
May 20 13:03:15 ahost dms[3213]: 2023-05-20T13:03:15+0000 NIL [main main.mainErr:171]: serving folder "/home/auser/Share"
May 20 13:03:15 ahost dms[3213]: 2023-05-20T13:03:15+0000 NIL [main.(*fFprobeCache).load:284]: added 0 items from cache
May 20 13:03:16 ahost dms[3213]: 2023-05-20T13:03:16+0000 NIL [main dms server github.com/anacrolix/dms/dlna/dms.(*Server).Init:1017]: HTTP srv on 0.0.0.0:1338
May 20 13:03:16 ahost dms[3213]: 2023-05-20T13:03:16+0000 NIL [main dms server ssdp lo github.com/anacrolix/dms/ssdp.(*Server).Init:196]: /var/run/minissdpd.sock
auser@ahost /etc/systemd/system $ sudo ss -alnp | grep 1900
udp   UNCONN 0      0                                         0.0.0.0:1900             0.0.0.0:*    users:(("dms",pid=3213,fd=7))                                                            
udp   UNCONN 0      0                                     0.0.0.0%br0:1900             0.0.0.0:*    users:(("miniupnpd",pid=386,fd=5))

and after few hours

May 20 13:14:40 ahost miniupnpd[386]: upnp_event_process_notify: connect(192.168.0.117:286>
May 20 13:14:48 ahost miniupnpd[386]: upnp_event_process_notify: connect(192.168.0.117:286>
May 20 13:14:48 ahost miniupnpd[386]: upnpevents_processfds: 0x544f40b0480, remove subscri>
May 20 20:06:36 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:08:48 ahost miniupnpd[386]: remove port mapping 32135 UDP because it has expired
May 20 23:46:35 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:46:41 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:46:41 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:46:56 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:02 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:08 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:14 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:14 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:17 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:20 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:20 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:23 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:29 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:35 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:44 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:44 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:47:59 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:02 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:02 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:05 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:08 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:14 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:17 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:29 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:32 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:35 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:38 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:38 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:56 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:48:59 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:49:17 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:49:20 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:49:35 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:49:44 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:49:50 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:49:53 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:49:56 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:49:59 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:49:59 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:50:11 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:50:11 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:50:23 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:50:23 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:50:26 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:50:26 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:50:26 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:50:35 ahost miniupnpd[386]: recvfrom(udp): Bad address
May 20 23:50:38 ahost miniupnpd[386]: recvfrom(udp): Bad address
...

@miniupnp
Copy link
Owner

@enihcam have you launched minissdpd BEFORE dms and miniupnpd ?
minissdpd should be the only process listening on port 1900

@enihcam
Copy link
Author

enihcam commented May 21, 2023

@enihcam have you launched minissdpd BEFORE dms and miniupnpd ? minissdpd should be the only process listening on port 1900

ok, I'll start minissdpd at very beginning, take an observation again.

@enihcam
Copy link
Author

enihcam commented May 21, 2023

@enihcam have you launched minissdpd BEFORE dms and miniupnpd ? minissdpd should be the only process listening on port 1900

ok, I'll start minissdpd at very beginning, take an observation again.

seems good to me now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants