Re: [Dnsmasq-discuss] State of blocking type=65 requests?

2023-03-15 Thread Simon Kelley




On 11/03/2023 17:34, Ed W wrote:

On 07/03/2023 21:50, Simon Kelley wrote:


On 06/03/2023 22:36, Ed W wrote:

Hi, can I get a leg up in understanding the options for blocking dns queries 
for a specific resource
type, specifically type 65 queries



My motivation for needing this is that we operate a firewalling system for a 
very bandwidth
constrained system (even DNS is extremely expensive) and we operate a 'blocked 
unless whitelisted'
firewalling system. The type 65 queries are currently inhibiting some of the 
whitelisting
capability. Whilst we can potentially improve things, the short term solution 
would be to block
type 65

I see that there is an option in pi-hole, but I'm looking for an option within 
dnsmasq, ideally
without maintaining my own out of tree patch




Just to make clear, as I know you count every every byte of traffic, these 
filters are on
_answers_ not on queries. The query for A or  (or in future an arbitrary 
type) still gets sent
upstream and when the answer comes back, the RRs are stripped out of the 
answer. It has to be that
way because the upstream there may not be an positive answer from upstream, and 
in that case we
need to know is it's a NODATA answer (The RRtype we queried doesn't exist) or 
an NXDOMAIN answer
(the domain we queried doesn't exist.)



So I've kind of realised that it might be difficult to implement my preferred 
option to kill the
upstream query (and save the bytes).

I created a very simple iptables rule that (probably) blocks  queries by 
just matching on the
query type in the packet (motivation is that then I can block only on expensive 
connections and
leave cheap connections untouched)

However, I then hit an issue with the musl resolver. It seems that this got 
changed last year to
return both A and  results OR error. So if the  query fails, then it 
retries a few times and
then returns an error (rather than partial result with just the A). There is 
some reference in the
commit to this being "correct"?

I'm not sure I know which RFC might dictate this? I'm tempted to patch this to 
do what I want it to
do, but first any observations on why this might be a bad idea in the real 
world (to be clear,
change of behaviour that failed  request will be ignored and remaining A 
response will be
returned on it's own)? My proposal would be to match the A response, so if 
NX-Fail on A, then that's
what you get, but otherwise "NO-DATA" for the . What am I missing?



The problem with doing this in dnsmasq or with iptables is that the A 
and  queries are separate.



If you want to suppress the  query (rather than the answer) you need 
to know is the answer should be NODATA or NXDOMAIN.


If the A query happens first then A query happens first then you have 
that information: an NXDOMAIN answer means the  query can be 
NXDOMAIN too. A NODATA or actual data means that the answer to the  
query can be NODATA without every sending it upstream.



Of course there's the possibility that nothing is cached for the domain, 
in which case you have to send the query upstream.



The resolver is somewhat different: it just returns IPv4 and IPv6 
answers, if you could hack it to always return an empty set of IPv6 
addresses and never make  DNS queries, you're fixed, as long as 
everything uses the resolver library calls to do DNS. As long.



For dnsmasq, an  query will get an immediate NXDOMAIN if the A query 
already happened and cached the NXDOMAIN response. Otherwise the  
query gets sent upstream and if any RR are returned, that answer gets 
turned into a NODATA answer by filter-.


What doesn'y happen, but could, is a search of the cache for A or other 
records. If they exist, an  query with filter- could get turned 
into a NODATA answer without being sent upstream.


Simon.




Thanks

Ed W



___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss



___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] [PATCH] Value stored to 'outmsgtype' is never read

2023-03-15 Thread Simon Kelley

Yes, that's a bug.

I prefer to goto theend of the function rather than duplicate the scary 
code that sets the message type. By reordering some code there, the 
logging works better too.


https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=00be8b39e240934e404533deda08cbae2aae25a8


Cheers,

Simon.

On 14/03/2023 11:51, Petr Menšík wrote:

Hi!

Our coverity scan detected new CLANG warning after I have cherry-picked 
commit 03345ecefeb0d82e3c3a4c28f27c3554f0611b39 [1] into our rhel8 
release. It reported it for 2.79 version, but even the last commit in 
master branch still has the same issue present. In attached patch I have 
suggested fix.


I am not sure how to trigger this code from the client, so this is not 
tested with real dhcp client. I track it under Fedora bug [2]. Coverity 
reported it as:


1. Defect type: CLANG_WARNING
1. dnsmasq-2.79/src/rfc3315.c:344:7: warning[deadcode.DeadStores]: Value stored 
to 'outmsgtype' is never read
#   342|
#   343|   {
#   344|->   outmsgtype = DHCP6REPLY;
#   345| o1 = new_opt6(OPTION6_STATUS_CODE);
#   346| put_opt6_short(DHCP6USEMULTI);

1. 
http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=03345ecefeb0d82e3c3a4c28f27c3554f0611b39

2. https://bugzilla.redhat.com/show_bug.cgi?id=2178069

--
Petr Menšík
Software Engineer, RHEL
Red Hat,http://www.redhat.com/
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB


___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss


___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss