Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/select: Annotate struct poll_list with __counted_by()

Add the __counted_by compiler attribute to the flexible array member
entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Link: https://lore.kernel.org/r/20240808150023.72578-2-thorsten.blum@toblux.com
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Thorsten Blum and committed by
Christian Brauner
193b7279 0f93bb54

+1 -1
+1 -1
fs/select.c
··· 840 840 struct poll_list { 841 841 struct poll_list *next; 842 842 unsigned int len; 843 - struct pollfd entries[]; 843 + struct pollfd entries[] __counted_by(len); 844 844 }; 845 845 846 846 #define POLLFD_PER_PAGE ((PAGE_SIZE-sizeof(struct poll_list)) / sizeof(struct pollfd))