atsign-foundation / noports

Connect to any device with no external listening ports open
https://noports.com
BSD 3-Clause "New" or "Revised" License
270 stars 15 forks source link

C daemon creates a general protection fault when client disconnects #1456

Open cpswan opened 2 weeks ago

cpswan commented 2 weeks ago

Describe the bug

When a client disconnects from the C daemon (running on OpenWRT) a message like this shows in the system log:

[  344.115795] traps: sshnpd[2540] general protection fault ip:7f9a6e754edf sp:7ffecf34cf58 error:0 in libc.so[7f9a6e744000+4c000]

We also get this in the general logs:

Wed Oct 16 16:15:20 2024 authpriv.info dropbear[2541]: Exit (root) from <::1:40072>: Disconnect received
Wed Oct 16 16:15:20 2024 daemon.info sshnpd[1682]: [WARN] 2024-10-16 16:15:20.786001 | child_exit_handler | Received signal: 1853387673
Wed Oct 16 16:15:20 2024 kern.info kernel: [  344.115795] traps: sshnpd[2540] general protection fault ip:7f9a6e754edf sp:7ffecf34cf58 error:0 in libc.so[7f9a6e744000+4c000]

Steps to reproduce

  1. First I install the csshnpd package on an OpenWRT test VM
  2. Then I configure the daemon and copy a key in place
  3. And then I start the daemon
  4. Connect with sshnp from my WSL2
  5. Disconnect (cleanly) with ^d

Expected behavior

Normal operation of C daemon does not cause kernel traps.

Additional context

The daemon seems to survive this without being restarted by the init process.

XavierChanth commented 2 weeks ago

Which version of the code is this running? We currently have signal traps in place to try and exit cleanly in sshnpd when a ^C is sent, but maybe we should just ditch that idea altogether.

cpswan commented 2 weeks ago

This is with c0.2.0