bind9/lib
Michał Kępień 6505056267 Fix fetch context use-after-free bugs
fctx_decreference() may call fctx_destroy(), which in turn may free the
fetch context by calling isc_mem_putanddetach().  This means that
whenever fctx_decreference() is called, the fetch context pointer should
be assumed to point to garbage after that call.  Meanwhile, the
following pattern is used in several places in lib/dns/resolver.c:

    LOCK(&res->buckets[fctx->bucketnum].lock);
    bucket_empty = fctx_decreference(fctx);
    UNLOCK(&res->buckets[fctx->bucketnum].lock);

Given that 'fctx' may be freed by the fctx_decreference() call, there is
no guarantee that the value of fctx->bucketnum will be the same before
and after the fctx_decreference() call.  This can cause all kinds of
locking issues as LOCK() calls no longer match up with their UNLOCK()
counterparts.

Fix by always using a helper variable to hold the bucket number when the
pattern above is used.

Note that fctx_try() still uses 'fctx' after calling fctx_decreference()
(it calls fctx_done()).  This is safe to do because the reference count
for 'fctx' is increased a few lines earlier and it also cannot be zero
right before that increase happens, so the fctx_decreference() call in
that particular location never invokes fctx_destroy().  Nevertheless,
use a helper variable for that call site as well, to retain consistency
and to prevent copy-pasted code from causing similar problems in the
future.
2022-07-08 11:26:34 +02:00
..
bind9 prevent a possible buffer overflow in configuration check 2022-05-13 20:30:41 -07:00
dns Fix fetch context use-after-free bugs 2022-07-08 11:26:34 +02:00
irs Update clang to version 14 2022-06-16 18:11:03 +02:00
isc Update clang to version 14 2022-06-16 18:11:03 +02:00
isccc Update clang to version 14 2022-06-16 18:11:03 +02:00
isccfg Update clang to version 14 2022-06-16 18:11:03 +02:00
ns Fix destination port extraction for client queries 2022-06-22 13:52:08 +02:00
win32/bindevt Update the copyright information in all files in the repository 2022-01-11 12:22:09 +01:00
.gitignore added gitignore, removed cvsignore 2012-03-03 23:10:05 -08:00
Kyuafile Update the copyright information in all files in the repository 2022-01-11 12:22:09 +01:00
Makefile.in Update the copyright information in all files in the repository 2022-01-11 12:22:09 +01:00