Compare commits

...
3 Commits
Author SHA1 Message Date
Simon Kelley f9f8d19bf5 Yet another 0x20 fix.
To complement the previous one, which fixed the retry path
when the query is retried from a different id/source address, this
fixes retries from the same id/source address.
2025-02-09 11:06:59 +00:00
Simon Kelley 535be2f5d3 Fix possible SIGSEGV in bpf.c 2025-02-08 22:58:42 +00:00
Simon Kelley bceab45dbe Fix 0x20 problem.
A retry to upstream DNS servers triggered by the following conditions

1) A query asking for the same data as a previous query which has not yet been answered.
2) The second query arrives more than two seconds after the first.
3) Either the source of the second query or the id field differs from the first.

fails to set the case of the retry to the same pattern as the first attempt.

However dnsmasq expects the reply from upstream to have the case
pattern of the first attempt.

If the answer to the retry arrives before the answer to the first
query, dnsmasq will notice the case mismatch, log an error, and
ignore the answer.

The worst case scenario would be the first upstream query or reply is
lost and there would follow a short period where all queries for that
particular domain would fail.

This is a 2.91 development issue, it doesn't apply to previous stable releases.
2025-02-07 19:56:33 +00:00
2 changed files with 16 additions and 10 deletions

No files matched your search

+1 -3
View File
@@ -125,12 +125,11 @@ int iface_enumerate(int family, void *parm, callback_t callback)
#endif #endif
for (addrs = head; addrs; addrs = addrs->ifa_next) for (addrs = head; addrs; addrs = addrs->ifa_next)
{
if (addrs->ifa_addr->sa_family == family)
{ {
int iface_index = if_nametoindex(addrs->ifa_name); int iface_index = if_nametoindex(addrs->ifa_name);
if (iface_index == 0 || !addrs->ifa_addr || if (iface_index == 0 || !addrs->ifa_addr ||
addrs->ifa_addr->sa_family != family ||
(!addrs->ifa_netmask && family != AF_LINK)) (!addrs->ifa_netmask && family != AF_LINK))
continue; continue;
@@ -228,7 +227,6 @@ int iface_enumerate(int family, void *parm, callback_t callback)
} }
#endif #endif
} }
}
ret = 1; ret = 1;
+15 -7
View File
@@ -197,12 +197,17 @@ static void forward_query(int udpfd, union mysockaddr *udpaddr,
FREC_HAS_PHEADER | FREC_DNSKEY_QUERY | FREC_DS_QUERY | FREC_NO_CACHE))) FREC_HAS_PHEADER | FREC_DNSKEY_QUERY | FREC_DS_QUERY | FREC_NO_CACHE)))
{ {
struct frec_src *src; struct frec_src *src;
struct dns_header *saved_header;
unsigned int casediff = 0; unsigned int casediff = 0;
unsigned int *bitvector = NULL; unsigned int *bitvector = NULL;
unsigned short id = ntohs(header->id); /* Retrieve the id from the new query before we overwrite it. */
/* Get the case-scambled version of the query to resend. This is important because we
may fall through below and forward the query in the packet buffer again and we
want to use the same case scrambling as the first time. */
blockdata_retrieve(forward->stash, forward->stash_len, (void *)header);
for (src = &forward->frec_src; src; src = src->next) for (src = &forward->frec_src; src; src = src->next)
if (src->orig_id == ntohs(header->id) && if (src->orig_id == id &&
sockaddr_isequal(&src->source, udpaddr)) sockaddr_isequal(&src->source, udpaddr))
break; break;
@@ -242,7 +247,7 @@ static void forward_query(int udpfd, union mysockaddr *udpaddr,
goto reply; goto reply;
} }
/* Find a bitmap of case differences between the query send upstream and this one, /* Find a bitmap of case differences between the query sent upstream and this one,
so we can reply to each query with the correct case pattern. so we can reply to each query with the correct case pattern.
Since we need this to get back the exact case pattern of each query when doing Since we need this to get back the exact case pattern of each query when doing
query combining, we have to handle the (rare) case that there are case differences query combining, we have to handle the (rare) case that there are case differences
@@ -253,9 +258,12 @@ static void forward_query(int udpfd, union mysockaddr *udpaddr,
we only scramble the first 32 letters for security reasons. we only scramble the first 32 letters for security reasons.
Note the two names are guaranteed to be the same length and differ only in the case Note the two names are guaranteed to be the same length and differ only in the case
of letters. */ of letters at this point.
if ((saved_header = blockdata_retrieve(forward->stash, forward->stash_len, NULL)) &&
extract_request(saved_header, forward->stash_len, daemon->workspacename, NULL)) The original query we sent is now in packet buffer and the query name in the
new instance is on daemon->namebuff. */
if (extract_request(header, forward->stash_len, daemon->workspacename, NULL))
{ {
unsigned int i, gobig = 0; unsigned int i, gobig = 0;
char *s1, *s2; char *s1, *s2;
@@ -294,7 +302,7 @@ static void forward_query(int udpfd, union mysockaddr *udpaddr,
daemon->free_frec_src = src->next; daemon->free_frec_src = src->next;
src->next = forward->frec_src.next; src->next = forward->frec_src.next;
forward->frec_src.next = src; forward->frec_src.next = src;
src->orig_id = ntohs(header->id); src->orig_id = id;
src->source = *udpaddr; src->source = *udpaddr;
src->dest = *dst_addr; src->dest = *dst_addr;
src->log_id = daemon->log_id; src->log_id = daemon->log_id;