]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fs/select: rework stack allocation hack for clang
authorArnd Bergmann <arnd@arndb.de>
Fri, 16 Feb 2024 20:23:34 +0000 (21:23 +0100)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:17 +0000 (18:19 -0400)
commit7a3894ec496e0b2cebf50244f4cde264f1ae69d3
tree3025a2415393bbebc927f5d4e5e2e018515377dc
parentb7f5aed55829f376e4f7e5ea5b80ccdcb023e983
fs/select: rework stack allocation hack for clang

[ Upstream commit ddb9fd7a544088ed70eccbb9f85e9cc9952131c1 ]

A while ago, we changed the way that select() and poll() preallocate
a temporary buffer just under the size of the static warning limit of
1024 bytes, as clang was frequently going slightly above that limit.

The warnings have recently returned and I took another look. As it turns
out, clang is not actually inherently worse at reserving stack space,
it just happens to inline do_select() into core_sys_select(), while gcc
never inlines it.

Annotate do_select() to never be inlined and in turn remove the special
case for the allocation size. This should give the same behavior for
both clang and gcc all the time and once more avoids those warnings.

Fixes: ad312f95d41c ("fs/select: avoid clang stack usage warning")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240216202352.2492798-1-arnd@kernel.org
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/select.c
include/linux/poll.h