From nobody Fri Dec 19 20:34:39 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD8B017A39F; Sun, 24 Mar 2024 23:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323660; cv=none; b=V4JssnGr36UWCeJJPSCA454V4WQrv9DTdl6vDOMeO0qJ/6Exn0dK451lqAQtvtv3JFSl0/M7lMERvZ7XP86yrT/zXSbmVk1dUpb7qn+D5GwpUe3U7yXV/gowRIakAEE/IEiYio2dTsDNNEdOREf439VME57o+jMJ1Wa/GZCRFLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323660; c=relaxed/simple; bh=2QmnBqFaoclGLhXwzEZp6wAs7/ysaG7ABlc3lWoqZTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IwoZRafgYBeoeDXBWK2rJk856VZjU+hMtKbrjeqrPf9J5Fm0WHkcBxrbTufFVMrKqXnYUn22drYAVZtvCmSvqf6hzq3SIh101Hf0YitBgxUQ+lL91o3tfp6tGMNY9tbp68J3WjBgD1J/7/R3KyiJ8YX57daqHq70xrk+1XM6i6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SNT3HR9V; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SNT3HR9V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4050C43390; Sun, 24 Mar 2024 23:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323659; bh=2QmnBqFaoclGLhXwzEZp6wAs7/ysaG7ABlc3lWoqZTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SNT3HR9VFsSlI3G+PwfxNK4DD2xvT9Jc4FjJcQ19QZQIBnVIauTLVmHjhCW1H1iUH mDKZV3SY6D+pRvWOrCb18kIPri9AHVoBGWmBj0dX9dpO1yWMg5lgm+Py+yw9nNLI7v L6iBZenLZUylEj7qeJqYgJUYJxn/bkXAjiZaZHem6PMEg+6d91mzKA/L+9C43NZCn1 wDCunvi4Rr+tQlRQIQ2RgSPbETbpuPLoTQx+A6WQ58bXBWmflx2QBX/SOtYmebSvxe AbTGCSCQx/rRJmOVifZkKH035uHB5OOQfUx9XXOmrUhU/RMQqtdlL1inXJzPecXTQ+ uuQBd1o0JvhwQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , Kees Cook , Andi Kleen , Jan Kara , Christian Brauner , Sasha Levin Subject: [PATCH 5.10 031/238] fs/select: rework stack allocation hack for clang Date: Sun, 24 Mar 2024 19:36:59 -0400 Message-ID: <20240324234027.1354210-32-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann [ 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 Link: https://lore.kernel.org/r/20240216202352.2492798-1-arnd@kernel.org Reviewed-by: Kees Cook Reviewed-by: Andi Kleen Reviewed-by: Jan Kara Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/select.c | 2 +- include/linux/poll.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/select.c b/fs/select.c index 5edffee1162c2..668a5200503ae 100644 --- a/fs/select.c +++ b/fs/select.c @@ -475,7 +475,7 @@ static inline void wait_key_set(poll_table *wait, unsig= ned long in, wait->_key |=3D POLLOUT_SET; } =20 -static int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time) +static noinline_for_stack int do_select(int n, fd_set_bits *fds, struct ti= mespec64 *end_time) { ktime_t expire, *to =3D NULL; struct poll_wqueues table; diff --git a/include/linux/poll.h b/include/linux/poll.h index 1cdc32b1f1b08..7e0fdcf905d2e 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h @@ -16,11 +16,7 @@ extern struct ctl_table epoll_table[]; /* for sysctl */ /* ~832 bytes of stack space used max in sys_select/sys_poll before alloca= ting additional memory. */ -#ifdef __clang__ -#define MAX_STACK_ALLOC 768 -#else #define MAX_STACK_ALLOC 832 -#endif #define FRONTEND_STACK_ALLOC 256 #define SELECT_STACK_ALLOC FRONTEND_STACK_ALLOC #define POLL_STACK_ALLOC FRONTEND_STACK_ALLOC --=20 2.43.0