]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: fd: detect possibly invalid tgid in fd_insert()
authorWilly Tarreau <w@1wt.eu>
Mon, 25 Jul 2022 13:42:41 +0000 (15:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Jul 2022 13:47:45 +0000 (15:47 +0200)
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

include/haproxy/fd.h

index b57076beff8f8e9609f1e21ef44bb4be8fffcb2d..e8ef4f3bcd0a125ba2e2d769e17db92d9fc6f36d 100644 (file)
@@ -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);