BUG/MAJOR: dns: multi-thread concurrency issue on UDP socket

This patch adds a lock on the struct dgram_conn to ensure
that an other thread cannot trash a fd or alter its status
while the current thread processing it on for send/receive/connect
operations.

Starting with the 2.4 version this could cause a crash when a DNS
request is failing, setting the FD of the dgram structure to -1. If the
dgram structure is reused after that, a read access to fdtab[-1] is
attempted. The crash was only triggered when compiled with ASAN.

In previous versions the concurrency issue also exists but is less
likely to crash.

This patch must be backported until v2.4 and should be
adapt for v < 2.4.

(cherry picked from commit 314e6ec8224e3636d019502286ec46ab418a6e9b)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit 3add3e1215c042500162df0b0007d7955513b229)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
2 files changed