From: Willy Tarreau Date: Mon, 25 Jul 2022 13:42:41 +0000 (+0200) Subject: DEBUG: fd: detect possibly invalid tgid in fd_insert() X-Git-Tag: v2.7-dev3~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51b1fcedebbec17fd38b8b1c1de10c7572d24ec8;p=thirdparty%2Fhaproxy.git DEBUG: fd: detect possibly invalid tgid in fd_insert() Since the API is still a bit young, let's make sure nobody tries to assign and FD to a group not strictly 1..MAX_TGROUPS as that would indicate a bug. Note: some of these might be relaxed to BUG_ON_HOT() in the future --- diff --git a/include/haproxy/fd.h b/include/haproxy/fd.h index b57076beff..e8ef4f3bcd 100644 --- a/include/haproxy/fd.h +++ b/include/haproxy/fd.h @@ -436,6 +436,7 @@ static inline void fd_insert(int fd, void *owner, void (*iocb)(int fd), int tgid BUG_ON(fd < 0 || fd >= global.maxsock); BUG_ON(fdtab[fd].owner != NULL); BUG_ON(fdtab[fd].state != 0); + BUG_ON(tgid < 1 || tgid > MAX_TGROUPS); thread_mask &= tg->threads_enabled; BUG_ON(thread_mask == 0);