You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
net: dns: Forward all DNS packets if callback is installed still not functional #107589
Issue is already described in #106783, an attempt to fix this was done in #106810, but this was incomplete.
While debugging, I have found out that when dns_header_rcode(dns_msg->msg) == DNS_HEADER_REFUSED or dns_header_ancount(dns_msg->msg) < 1 and *dns_id > 0 (DNS packet), function will jump to quit, and dns_id and query_hash are not even computed.
Regression
This is a regression.
Steps to reproduce
No response
Relevant log output
Impact
Annoyance – Minor irritation; no significant impact on usability or functionality.
For sure additional check for query_idx is needed before passing the packet to pkt_fw_cb.
Perhaps some reordering could be applied to dns_validate_msg() (like checking the record count after calculating the hash/query index) to mitigate the issue, however I don't think this can be fully avoided - the hash/index cannot be calculated for malformed packets.
It seems it could work that way, one caveat though. When dns_validate_msg() fails we don't know whether message size has been validated yet (happens in dns_unpack_response_header()), and dns_unpack_response_query() relies on that, so additional check for msg->msg_size > DNS_MSG_HEADER_SIZE before calling that would be needed I think.
Activity
rlubos commentedon Apr 20, 2026
For sure additional check for
query_idxis needed before passing the packet topkt_fw_cb.Perhaps some reordering could be applied to
dns_validate_msg()(like checking the record count after calculating the hash/query index) to mitigate the issue, however I don't think this can be fully avoided - the hash/index cannot be calculated for malformed packets.Cristib05 commentedon Apr 21, 2026
I was thinking to do those operations if packet forwarding is enabled, a DNS packet is received (dns_id > 0), outside of
dns_validate_msg()function.Cristib05 commentedon Apr 21, 2026
something like this, in
dns_read()function:rlubos commentedon Apr 21, 2026
It seems it could work that way, one caveat though. When
dns_validate_msg()fails we don't know whether message size has been validated yet (happens indns_unpack_response_header()), anddns_unpack_response_query()relies on that, so additional check formsg->msg_size > DNS_MSG_HEADER_SIZEbefore calling that would be needed I think.