-
-
Notifications
You must be signed in to change notification settings - Fork 236
NTP ipv6 crash fix - ntp reply & logging #2569
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
Conversation
|
Built and tested on x86-64 and arm-v6 (on a pi 2b - an ordeal I don't care to repeat). No crashes observed on IPv6 ntp packets, and responses generated as expected. I don't have access to any other platforms for testing. I wouldn't class this as WIP, but it would be reassuring if someone is able to (real world) test this on especially 386, but also risc. |
|
I do have a RISCV board I can use for testing I could try to boot and see if it still runs. Do you have some CLI command or demo script that generates such packages you'd like to see it being tested against? Edit: nvm, I should have read the issue you referenced, before replying here.
|
|
There is a one-liner from https://seriot.ch/projects/tiny_ntp_client.html that doesn't rely on any ntp package being installed. [ EDITED to quote as block code instead of plain text : These were originally broken by github's formatting as there are backticks in the commands ] If it gets a response it prints the time and date reported by the ntp server. I was thinking something like this may be possible to add to the tests, a quick sanity check that the returned time is within 2 seconds either way of the sent time (it should be the same on localhost, but this allows for second rollover and a little extra padding. Is Pi-hole able to sync its own time within the test environment to even be able to send a response? |
does not return anything for me on neither my v86_64 nor the riscv64 Pi-hole so the one-liner doesn't seem to work. The Pi-hole's internal NTP checking tool seems to work just fine: Note that RISCV is also 64-bit but I nonetheless fired up my StarFive VisionFive 2 running RISCV Ubuntu Wow, I forgot how slow this thing is. Comparable to a Raspberry Pi 2... Anyway, I'd be ready to run any test you have for me. |
|
Thank you. With I don't see any crashes, also not on RISCV, but, as said, this is a 64 bit system so the crash may not actually be expected. |
use pointer casting to avoid potential buffer overflow copying socket addresses into socket structures use sockaddr_storage to ensure adress size and alignment across achitectures add additional and ntp debug logging check for address type rather than specified protocol Signed-off-by: Rob Gill <[email protected]>
What does this PR aim to accomplish?:
Avoid the buffer overflow when repying to ipv6 ntp packets.
This was observed to cause crashes on 32 bit systems #2567.
How does this PR accomplish the above?:
Use SOCKADDR_STORAGE struct to hold address (guaranteed sufficient for ipv4 or ipv6 address)
Uses pointer casting to avoid potential buffer overflow copying socket addresses into socket structures.
Together this should be safer against buffer overflows and alignment issues on 32 bit systems
Adds more detailed ntp debug logging.
Link documentation PRs if any are needed to support this PR:
N/A
By submitting this pull request, I confirm the following:
git rebase)