Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2471559lqp; Sun, 24 Mar 2024 22:11:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVoCV0LuI+wxA5cAoYIwKgrFeJQYXkXmgjmwVzHZw82W6BDnyllQneOmryh9Ab7hFF0HDBjJW9gsl8p4LX3Di8eSTMg1QHrz33HhbEdCA== X-Google-Smtp-Source: AGHT+IGhO/3x0QWnykCjAZ+/n6hG6ZFJjM3uVWLyRZqVqD+jcBORA2Eu/+bZBiT3iMzKMnC0TrVs X-Received: by 2002:a17:906:b189:b0:a46:a8ba:60b3 with SMTP id w9-20020a170906b18900b00a46a8ba60b3mr3839337ejy.37.1711343491954; Sun, 24 Mar 2024 22:11:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711343491; cv=pass; d=google.com; s=arc-20160816; b=HlWaisy6qFm3GLrKkp/E7YaYOJe3Rgm63WcVISLeQTuEVIzxj4Kf+eEemI5EZtjIzQ Kmh18LYEs4KhcH+duX+5H/awQxUTFuyzsCqft3e0olBVY83VZ0e7+8iiJcd24BqDhcML rTeQPY0nzbrcpiRDnrYs6GJOVc8PbYgkdWBujxCIrxGtNJWwR968/MtY5AZD8Qtd4U/s IGWZSXVoUEI3PF0qImDuVvH/lJhTA6SUgVSwBf0iSlTCVMJqe5ZTvaB1WTFby3/D2xcp mRxUMVhCSbXWCedASM9wWZWKiYPhP9Dvhd1Q+t5NlT+lD8vrxKqLibV0z0YFiE5esGJw 0Idw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=p5jks18C0vTh4OFPpPoTm4Mr7NKR6+frZAnPazSpbbM=; fh=s4hGUIhJmzbSYltfwIkYH/wC7ATbZmvEzKR2+FLFnlA=; b=kEwEnGESZ81X9JS8nmWeIJrqBtTPwlHJVMd5TSiZNSOg3EM6YG2Oic+XabfKQAHfCX iv44GiwDKVw6yzk7paST3blB4xj0pumrESLRshd3CSu1gZRXJEdaUuqGI9qaSMjs+K1I TmKN+m4EYIJteEtUghcEx39joowYT0Vl16stDH2/Jb6mZTEpcbsBmNH6X6Cn1rYUDIHI d5VxaPE9jKoiqja/O9vhJn99aEy6eVXI4jCVlQrel7LnBbzpOZA/VJHjrZdlq/qZlU/W ee1smBef/Rw+kmyOOolGszEVZd3ZC2bG/+rzfKa4y3aADr2JKG9I6Ung4uMgUD/WJkHv /WlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zx1I6V8S; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113634-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113634-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id uz12-20020a170907118c00b00a4a399a97e2si292560ejb.726.2024.03.24.22.11.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 22:11:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113634-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zx1I6V8S; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113634-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113634-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AD2101F2F190 for ; Mon, 25 Mar 2024 05:11:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E3B782D69; Sun, 24 Mar 2024 22:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zx1I6V8S" 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 0690C81AC4; Sun, 24 Mar 2024 22:49:01 +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=1711320542; cv=none; b=puAM5w+h1GfqhkqaGWyhP5QA42EcAh5xJsd9Rj3HGAsD6eS18kL+Ke1j8kg0BYzPE8YhKhcAI3TLvDKgifehR91+dJBYF8ZaIJ8pLwu0s4N5G9/ctYRtSwQYIOP6xWhBQSBBejQlgiqyPk4oLao8mxRoY7LLb12Ddi0fe2OBUjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320542; c=relaxed/simple; bh=c/8ThzkfXePMKSUnih7WKsu2s/C2H5smRXIfTXnLdnc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BDTjPqOWV0LNId6hi4+gYSSRyFn8Hetc4320BjkBbC85ty3EgpnVYr5jJuP0BaPWaUQgrsxka/aJLtymjFzO+m2G7OGxH/4xk/QrYx3l0+opq8g/UBhOKhCuv3fuVk247A8DeIO18PC1hYWb3dRrGfW4yoN3TOsnsofhNdZOV9I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zx1I6V8S; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00504C43394; Sun, 24 Mar 2024 22:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320540; bh=c/8ThzkfXePMKSUnih7WKsu2s/C2H5smRXIfTXnLdnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zx1I6V8SZhU5lPYPsb2DoXt0nt+lNVe68ymZwsD9ZkexNhxl248Uug2ovtvNQ3P/Q 1ElvFnqnxyXsbD84zYnq8+rXBjdDgM/iEfJLh9PO/8H5l9uyHtpMBqhzb52HpezHDn LJFTJWNLYI31jygyMlp7SAOlVMpBzKLN03nXgOPmNKn/KMlSI71GkO2I3//60S7mQk GC/ZqYiCIUxmbElYzV9W3fAQuJN4vTe2074huHKvKdrmC1iJ/+QlLU1JIER5foF85N ou9RY20LzyXCEELeBMjpkSdBaE/0aKuRZydPni8K3HvmnxgGUOlsxYqJQt7eEj6zNv 7IMhIMSJZIpYw== 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 6.7 102/713] fs/select: rework stack allocation hack for clang Date: Sun, 24 Mar 2024 18:37:08 -0400 Message-ID: <20240324224720.1345309-103-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-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: 8bit 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 0ee55af1a55c2..d4d881d439dcd 100644 --- a/fs/select.c +++ b/fs/select.c @@ -476,7 +476,7 @@ static inline void wait_key_set(poll_table *wait, unsigned long in, wait->_key |= POLLOUT_SET; } -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 timespec64 *end_time) { ktime_t expire, *to = NULL; struct poll_wqueues table; diff --git a/include/linux/poll.h b/include/linux/poll.h index a9e0e1c2d1f2f..d1ea4f3714a84 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h @@ -14,11 +14,7 @@ /* ~832 bytes of stack space used max in sys_select/sys_poll before allocating 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 -- 2.43.0