#1072966 "unbound-control load_cache" hangs on loading 0 length file

Package:
unbound
Source:
unbound
Description:
validating, recursive, caching DNS resolver
Submitter:
Landon
Date:
2024-06-11 01:15:03 UTC
Severity:
normal
Tags:
#1072966#5
Date:
2024-06-11 01:10:52 UTC
From:
To:
I'm using Raspbian bookworm OS arm 64 bit. I am reporting this bug
here because the package came from the Debian archives.

Linux pi 6.6.31+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1
(2024-05-29) aarch64 GNU/Linux

I also posted this info in the Raspberry Pi forums here:
https://forums.raspberrypi.com/viewtopic.php?t=372141

Also, to the package maintainer, it would be awesome if you would
include script and Systemd service files to implement what I did. I'll
send you what I made if you ask me. Send me a direct message.

When I run the command "unbound-control load_cache < zero_length_file"
it hangs. You should be able to reproduce the bug by running that
command with a zero length file as input.

I put this command in a script that runs when I (re)start unbound, and
sometimes the saved cache file is 0 length which causes the script to
hang and eventually timeout. I found this out due to a bug in my
script that makes it sometimes create a 0 length cache file when I
stop unbound. I think this is probably an upstream bug. The program
might not check the size of the file it is trying to read to see if it
is 0 length.

$ apt policy unbound
unbound:
Installed: 1.17.1-2+deb12u2
Candidate: 1.17.1-2+deb12u2
Version table:
*** 1.17.1-2+deb12u2 500
500 http://deb.debian.org/debian-security bookworm-security/main arm64 Packages
100 /var/lib/dpkg/status
1.17.1-2+deb12u1 500
500 http://deb.debian.org/debian bookworm/main arm64 Packages

Some logs from my scripts... I had to kill the process because it hung.

Jun 09 15:35:59 pi sudo[243166]: user : TTY=pts/0 ;
PWD=/usr/local/sbin ; USER=root ; COMMAND=/usr/bin/kill 242995
Jun 09 15:35:59 pi sudo[243166]: pam_unix(sudo:session): session
opened for user root(uid=0) by user(uid=1000)
Jun 09 15:35:59 pi load_unbound_cache.sh[242989]: Terminated
Jun 09 15:35:59 pi sudo[243166]: pam_unix(sudo:session): session
closed for user root
Jun 09 15:35:59 pi unbound[242985]: [242985:0] error: could not send:
Broken pipe
Jun 09 15:35:59 pi unbound[242985]: [242985:0] error: could not send:
Broken pipe
Jun 09 15:35:59 pi unbound-cache-load[243170]: Sun Jun 9 03:35:59 PM
MDT 2024: FAILED to load cache /usr/local/sbin/load_unbound_cache.sh
Jun 09 15:35:59 pi systemd[1]: unbound-cache-load.service: Deactivated
successfully.
Jun 09 15:35:59 pi systemd[1]: Finished unbound-cache-load.service -
Unbound Cache Load Service.