Using the latest atftpd, whenever a client sends a request to get a file that is non existent, the service crashes.
No error logs are shown in the var/log file, it just stops logging
is this a know issue with the latest build?
Hi,
can you please provide a bit more information? Do you use a packaged atftpd, if 'yes', which distribution? How is atftpd started (systemd socket activation or xinetd)? What if you run the server in debug mode? Perhaps directly from the command line?
I tested here on Debian testing and anything seems to work fine:
$ atftp
tftp> connect localhost
tftp> get d-i/n-a/bootnetx64.efi
Overwrite local file [y/n]? y
tftp> get nonexistent
tftp: error received from server <file not="" found="">
tftp: aborting
tftp> quit</file>
journalctl -f -u atftpd
Aug 17 11:51:18 atftpd[2277791]: Advanced Trivial FTP server started (0.7.5)
Aug 17 11:51:18 atftpd[2277791]: started by inetd
Aug 17 11:51:18 atftpd[2277791]: logging level: 7
Aug 17 11:51:18 atftpd[2277791]: directory: /var/lib/tftpboot/
Aug 17 11:51:18 atftpd[2277791]: user: nobody.nogroup
Aug 17 11:51:18 atftpd[2277791]: log file: syslog
Aug 17 11:51:18 atftpd[2277791]: not forcing to listen on local interfaces.
Aug 17 11:51:18 atftpd[2277791]: server timeout: 20
Aug 17 11:51:18 atftpd[2277791]: tftp retry timeout: 1
Aug 17 11:51:18 atftpd[2277791]: maximum number of thread: 100
Aug 17 11:51:18 atftpd[2277791]: option timeout: enabled
Aug 17 11:51:18 atftpd[2277791]: option tzise: enabled
Aug 17 11:51:18 atftpd[2277791]: option blksize: enabled
Aug 17 11:51:18 atftpd[2277791]: option windowsize: enabled
Aug 17 11:51:18 atftpd[2277791]: option multicast: disabled
Aug 17 11:51:18 atftpd[2277791]: address range: 239.255.0.0-255
Aug 17 11:51:18 atftpd[2277791]: port range: 1758
Aug 17 11:51:18 atftpd[2277791]: socket may listen on any address, including broadcast
Aug 17 11:51:18 atftpd[2277791]: Creating new socket: :::46308
Aug 17 11:51:18 atftpd[2277791]: Serving d-i/n-a/bootnetx64.efi to ::1:41355
Aug 17 11:51:18 atftpd[2277791]: End of transfer
Aug 17 11:51:18 atftpd[2277791]: Server thread exiting
Aug 17 11:51:26 atftpd[2277791]: socket may listen on any address, including broadcast
Aug 17 11:51:26 atftpd[2277791]: Creating new socket: :::48549
Aug 17 11:51:26 atftpd[2277791]: Serving nonexistent to ::1:38747
Aug 17 11:51:26 atftpd[2277791]: File /var/lib/tftpboot/nonexistent not found
Aug 17 11:51:26 atftpd[2277791]: Server thread exiting
Aug 17 11:51:46 atftpd[2277791]: atftpd terminating after 20 seconds
Aug 17 11:51:46 atftpd[2277791]: Load measurements:
Aug 17 11:51:46 atftpd[2277791]: User: 0.000s Sys: 0.000s
Aug 17 11:51:46 atftpd[2277791]: Total: 28.057s CPU: 0.214%
Aug 17 11:51:46 atftpd[2277791]: Time between connections:
Aug 17 11:51:46 atftpd[2277791]: Min: 8.038s Max: 8.038s
Aug 17 11:51:46 atftpd[2277791]: Thread stats:
Aug 17 11:51:46 atftpd[2277791]: simultaneous threads: 1
Aug 17 11:51:46 atftpd[2277791]: number of servers: 1
Aug 17 11:51:46 atftpd[2277791]: number of aborts: 0
Aug 17 11:51:46 atftpd[2277791]: number of errors: 1
Aug 17 11:51:46 systemd[1]: atftpd.service: Deactivated successfully.
Aug 17 11:51:46 atftpd[2277791]: number of files sent: 1
Aug 17 11:51:46 atftpd[2277791]: number of files received: 0
Aug 17 11:51:46 atftpd[2277791]: Main thread exiting
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I cannot confirm the problem either. Requesting non-existent files from atftpd happens very often during pxeboot, so a serious error like this would be detected quickly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, this is exactly how I found out.
The default install on jammy uses systemd sockets and restarts atftpd daemon after each segfault.
This might hide the problem for some time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can confirm the issue on jammy. However, as far as I can tell, it's the same code. I did not investigate it in detail, but it looks like it's a matter of compiler flags applied, which causes the issue.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
By default Ubuntu compile packages with LTO enabled, which I think Debian is not yet using.
There's two course of actions, either we disable it on our Deb, or upstream can evaluate if they want to have this compile flag enabled by default and fix the issues in code (something like the mentioned fix above).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
can you please provide a bit more information? Do you use a packaged atftpd, if 'yes', which distribution? How is atftpd started (systemd socket activation or xinetd)? What if you run the server in debug mode? Perhaps directly from the command line?
I tested here on Debian testing and anything seems to work fine:
$ atftp
tftp> connect localhost
tftp> get d-i/n-a/bootnetx64.efi
Overwrite local file [y/n]? y
tftp> get nonexistent
tftp: error received from server <file not="" found="">
tftp: aborting
tftp> quit</file>
journalctl -f -u atftpd
Aug 17 11:51:18 atftpd[2277791]: Advanced Trivial FTP server started (0.7.5)
Aug 17 11:51:18 atftpd[2277791]: started by inetd
Aug 17 11:51:18 atftpd[2277791]: logging level: 7
Aug 17 11:51:18 atftpd[2277791]: directory: /var/lib/tftpboot/
Aug 17 11:51:18 atftpd[2277791]: user: nobody.nogroup
Aug 17 11:51:18 atftpd[2277791]: log file: syslog
Aug 17 11:51:18 atftpd[2277791]: not forcing to listen on local interfaces.
Aug 17 11:51:18 atftpd[2277791]: server timeout: 20
Aug 17 11:51:18 atftpd[2277791]: tftp retry timeout: 1
Aug 17 11:51:18 atftpd[2277791]: maximum number of thread: 100
Aug 17 11:51:18 atftpd[2277791]: option timeout: enabled
Aug 17 11:51:18 atftpd[2277791]: option tzise: enabled
Aug 17 11:51:18 atftpd[2277791]: option blksize: enabled
Aug 17 11:51:18 atftpd[2277791]: option windowsize: enabled
Aug 17 11:51:18 atftpd[2277791]: option multicast: disabled
Aug 17 11:51:18 atftpd[2277791]: address range: 239.255.0.0-255
Aug 17 11:51:18 atftpd[2277791]: port range: 1758
Aug 17 11:51:18 atftpd[2277791]: socket may listen on any address, including broadcast
Aug 17 11:51:18 atftpd[2277791]: Creating new socket: :::46308
Aug 17 11:51:18 atftpd[2277791]: Serving d-i/n-a/bootnetx64.efi to ::1:41355
Aug 17 11:51:18 atftpd[2277791]: End of transfer
Aug 17 11:51:18 atftpd[2277791]: Server thread exiting
Aug 17 11:51:26 atftpd[2277791]: socket may listen on any address, including broadcast
Aug 17 11:51:26 atftpd[2277791]: Creating new socket: :::48549
Aug 17 11:51:26 atftpd[2277791]: Serving nonexistent to ::1:38747
Aug 17 11:51:26 atftpd[2277791]: File /var/lib/tftpboot/nonexistent not found
Aug 17 11:51:26 atftpd[2277791]: Server thread exiting
Aug 17 11:51:46 atftpd[2277791]: atftpd terminating after 20 seconds
Aug 17 11:51:46 atftpd[2277791]: Load measurements:
Aug 17 11:51:46 atftpd[2277791]: User: 0.000s Sys: 0.000s
Aug 17 11:51:46 atftpd[2277791]: Total: 28.057s CPU: 0.214%
Aug 17 11:51:46 atftpd[2277791]: Time between connections:
Aug 17 11:51:46 atftpd[2277791]: Min: 8.038s Max: 8.038s
Aug 17 11:51:46 atftpd[2277791]: Thread stats:
Aug 17 11:51:46 atftpd[2277791]: simultaneous threads: 1
Aug 17 11:51:46 atftpd[2277791]: number of servers: 1
Aug 17 11:51:46 atftpd[2277791]: number of aborts: 0
Aug 17 11:51:46 atftpd[2277791]: number of errors: 1
Aug 17 11:51:46 systemd[1]: atftpd.service: Deactivated successfully.
Aug 17 11:51:46 atftpd[2277791]: number of files sent: 1
Aug 17 11:51:46 atftpd[2277791]: number of files received: 0
Aug 17 11:51:46 atftpd[2277791]: Main thread exiting
Hi,
I've found the same behavior on ubuntu jammy.
After some debugging I've found this:
in line 171 of tftp_io.c
The definition of tftphdr in /usr/include/arpa/tftp.h is as follows:
I suppose that:
disagrees with range checking in Strncpy.
Changing line 171 to:
fixes the issue for me.
Hi,
thanks for the report and patch. I have to investigate, as soon I find some available time slot.
Hm, seems to be Ubuntu specific, still not reproducible here on Debian. I'm going to install jammy and try to find the difference. Ubuntu bug : https://bugs.launchpad.net/ubuntu/+source/atftp/+bug/1989816
I cannot confirm the problem either. Requesting non-existent files from atftpd happens very often during pxeboot, so a serious error like this would be detected quickly.
Well, this is exactly how I found out.
The default install on jammy uses systemd sockets and restarts atftpd daemon after each segfault.
This might hide the problem for some time.
I can confirm the issue on jammy. However, as far as I can tell, it's the same code. I did not investigate it in detail, but it looks like it's a matter of compiler flags applied, which causes the issue.
On Ubuntu 22.04: 0.7.git20210915-4 crashes unable to start any client
By default Ubuntu compile packages with LTO enabled, which I think Debian is not yet using.
There's two course of actions, either we disable it on our Deb, or upstream can evaluate if they want to have this compile flag enabled by default and fix the issues in code (something like the mentioned fix above).