dma
dma copied to clipboard
Stack overflow on FreeBSD
Hi,
I'm using dma on a FreeBSD 13 machine with a smarthost (smtp.migadu.com), but dma crashes with a stack overflow after consuming 100% cpu for a few minutes. I've seen this on two machines, on older releases of FreeBSD as well.
I've tried both with the dma in the base system, and installing the latest dma from pkg. I'm not too familiar with how this is really used, but I can reproduce the issue like this (or by just trying to use mail):
echo "test!" |/usr/local/libexec/dma -D -r '[email protected]' '[email protected]'
If I try to press ctrl-t in FreeBSD when running the above, I get some minor useful data:
# Removed a bunch of these: load: 1.82 cmd: dma 91917 [running] 230.39r 58.55u 111.70s 100% 5884k
mac_socket_check_receive+0x7a soo_read+0x19 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8
amd64_syscall+0x10c fast_syscall_common+0xf8
soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8
soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8
soo_read+0x19 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8
soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8
soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8
sys_read+0x99 amd64_syscall+0x10c fast_syscall_common+0xf8
soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8
dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8
Any ideas?
This is a typical case, from /var/log/maillog:
Jun 30 13:13:50 hilda dma[181e2][60585]: new mail from user=root uid=26 envelope_from=<root@hilda>
Jun 30 13:13:50 hilda dma[181e2][60585]: mail to=<[email protected]> queued as 181e2.800e48050
Jun 30 13:13:50 hilda dma[181e2.800e48050][61054]: <[email protected]> trying delivery
Jun 30 13:13:50 hilda dma[181e2.800e48050][61054]: using smarthost (smtp.migadu.com:465)
Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: trying remote delivery to smtp.migadu.com [2001:41d0:2:863f::] pref 0
Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: connect to smtp.migadu.com [2001:41d0:2:863f::] failed: No route to host
Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: trying remote delivery to smtp.migadu.com [2001:41d0:2:aacc::] pref 0
Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: connect to smtp.migadu.com [2001:41d0:2:aacc::] failed: No route to host
Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: trying remote delivery to smtp.migadu.com [2001:41d0:2:267::] pref 0
Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: connect to smtp.migadu.com [2001:41d0:2:267::] failed: No route to host
Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: trying remote delivery to smtp.migadu.com [94.23.1.103] pref 0
# snip
Jun 30 13:18:51 hilda dma[181e2.800e48050][61054]: stack overflow detected; terminated
Here's my /etc/dma/dma.conf:
SMARTHOST smtp.migadu.com
PORT 465
AUTHPATH /etc/dma/auth.conf
SECURETRANSFER
STARTTLS
My /etc/dma/auth.conf looks valid, [email protected]|smtp.migadu.com:password.
My /usr/local/etc/mail/mailer.conf looks like this, currently configured for the dma from pkg:
sendmail /usr/local/libexec/dma
mailq /usr/local/libexec/dma
newaliases /usr/local/libexec/dma
rmail /usr/local/libexec/dma
I've tried removing STARTTLS from my configuration (as recommended by others) but it doesn't fix the issue. It's still crashing from a stack overflow.
~~Could it be something as silly as permission denied?~~ Nope.
# ls -la
total 14
drwxr-xr-x 2 root wheel 4 Jun 30 15:02 .
drwxr-xr-x 27 root wheel 111 Jun 24 23:16 ..
-rw-r----- 1 root wheel 85 Jun 24 22:48 auth.conf
-r--r----- 1 root wheel 96 Jun 30 15:02 dma.conf
could you show more of the snipped lines from maillog?
On 30/06/2021 06:37, Oscar Carlsson wrote:
Hi,
I'm using dma on a FreeBSD 13 machine with a smarthost (smtp.migadu.com), but dma crashes with a stack overflow after consuming 100% cpu for a few minutes. I've seen this on two machines, on older releases of FreeBSD as well.
I've tried both with the dma in the base system, and installing the latest dma from pkg. I'm not too familiar with how this is really used, but I can reproduce the issue like this (or by just trying to use |mail|):
|echo "test!" |/usr/local/libexec/dma -D -r @.' @.' |
If I try to press ctrl-t in FreeBSD when running the above, I get some minor useful data:
|# Removed a bunch of these: load: 1.82 cmd: dma 91917 [running] 230.39r 58.55u 111.70s 100% 5884k mac_socket_check_receive+0x7a soo_read+0x19 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8 amd64_syscall+0x10c fast_syscall_common+0xf8 soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8 soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8 soo_read+0x19 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8 soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8 soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8 sys_read+0x99 amd64_syscall+0x10c fast_syscall_common+0xf8 soreceive_generic+0xe7 soreceive+0x44 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8 dofileread+0x81 sys_read+0xbc amd64_syscall+0x10c fast_syscall_common+0xf8 |
Any ideas?
This is a typical case, from |/var/log/maillog|:
|Jun 30 13:13:50 hilda dma[181e2][60585]: new mail from user=root uid=26 @.> Jun 30 13:13:50 hilda dma[181e2][60585]: mail @.> queued as 181e2.800e48050 Jun 30 13:13:50 hilda dma[181e2.800e48050][61054]: @.***> trying delivery Jun 30 13:13:50 hilda dma[181e2.800e48050][61054]: using smarthost (smtp.migadu.com:465) Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: trying remote delivery to smtp.migadu.com [2001:41d0:2:863f::] pref 0 Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: connect to smtp.migadu.com [2001:41d0:2:863f::] failed: No route to host Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: trying remote delivery to smtp.migadu.com [2001:41d0:2:aacc::] pref 0 Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: connect to smtp.migadu.com [2001:41d0:2:aacc::] failed: No route to host Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: trying remote delivery to smtp.migadu.com [2001:41d0:2:267::] pref 0 Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: connect to smtp.migadu.com [2001:41d0:2:267::] failed: No route to host Jun 30 13:13:51 hilda dma[181e2.800e48050][61054]: trying remote delivery to smtp.migadu.com [94.23.1.103] pref 0 # snip Jun 30 13:18:51 hilda dma[181e2.800e48050][61054]: stack overflow detected; terminated |
Here's my |/etc/dma/dma.conf|:
|SMARTHOST smtp.migadu.com PORT 465 AUTHPATH /etc/dma/auth.conf SECURETRANSFER STARTTLS |
My |/etc/dma/auth.conf| looks valid, @.***|smtp.migadu.com:password|.
My |/usr/local/etc/mail/mailer.conf| looks like this, currently configured for the dma from pkg:
|sendmail /usr/local/libexec/dma mailq /usr/local/libexec/dma newaliases /usr/local/libexec/dma rmail /usr/local/libexec/dma |
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/corecode/dma/issues/100, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABLOOYIHRHJ5TVOHBRPWUDTVL6XDANCNFSM47SEVNCQ.
I got it working after some help - I changed port (to 587/tcp, from the provider recommended port 465/tcp) and added masquerade. But I guess that the stack overflow should still be looked into.
SMARTHOST smtp.migadu.com
PORT 587
AUTHPATH /etc/dma/auth.conf
MASQUERADE [email protected]
SECURETRANSFER
STARTTLS
This is a full crash from my /var/log/maillog:
Jun 30 17:20:32 hilda dma[180ec][48243]: new mail from user=root uid=26 envelope_from=<root@hilda>
Jun 30 17:20:32 hilda dma[180ec][48243]: mail to=<[email protected]> queued as 180ec.800e48050
Jun 30 17:20:32 hilda dma[180ec.800e48050][48399]: <[email protected]> trying delivery
Jun 30 17:20:32 hilda dma[180ec.800e48050][48399]: using smarthost (smtp.migadu.com:465)
Jun 30 17:20:32 hilda dma[180ec.800e48050][48399]: trying remote delivery to smtp.migadu.com [2001:41d0:2:267::] pref 0
Jun 30 17:20:32 hilda dma[180ec.800e48050][48399]: connect to smtp.migadu.com [2001:41d0:2:267::] failed: No route to host
Jun 30 17:20:32 hilda dma[180ec.800e48050][48399]: trying remote delivery to smtp.migadu.com [2001:41d0:2:aacc::] pref 0
Jun 30 17:20:32 hilda dma[180ec.800e48050][48399]: connect to smtp.migadu.com [2001:41d0:2:aacc::] failed: No route to host
Jun 30 17:20:32 hilda dma[180ec.800e48050][48399]: trying remote delivery to smtp.migadu.com [2001:41d0:2:863f::] pref 0
Jun 30 17:20:32 hilda dma[180ec.800e48050][48399]: connect to smtp.migadu.com [2001:41d0:2:863f::] failed: No route to host
Jun 30 17:20:32 hilda dma[180ec.800e48050][48399]: trying remote delivery to smtp.migadu.com [188.165.223.204] pref 0
Jun 30 17:25:32 hilda dma[180ec.800e48050][48399]: stack overflow detected; terminated
That's it.
Also getting stack overflow in port 465; seemingly fixed by switching the port to 587.
you need to remove STARTTLS if you use port 465. 587 + STARTTLS should be preferred.
The stack overflow is definitely a bug though.
could you attach with gdb and show a backtrace? It's not clear what leads to the stack overflow.
You might need to set sysctl kern.sugid_coredump=1 to get a core file that you can open in gdb or lldb