Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2360299lqp; Sun, 24 Mar 2024 15:41:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuWSUeu7E8s4p+ZznFVwJYWEAJto5ilETBSBhHkrqCaiU+xnaSwwovsKsNL7wCOF6lD1C03ODOkjocKVntzEGMEY2+iNEXJcaovMXKHA== X-Google-Smtp-Source: AGHT+IFv8QkVfNS2mP3NCAr27o2FeFGCGeMcmqrbQFwaArg6nNKUAb6w8TlaaWcISweUhfWjcOu0 X-Received: by 2002:a05:622a:1a1e:b0:431:39af:a9e7 with SMTP id f30-20020a05622a1a1e00b0043139afa9e7mr5984652qtb.0.1711320070893; Sun, 24 Mar 2024 15:41:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711320070; cv=pass; d=google.com; s=arc-20160816; b=fCutYLqdc/hTJfFW5PFcEMzFL2cYIyD9SfEGdTTft6F69IiPEW7bNgf83um3KpNECu RbyhHZGLG7/EH4G6QnSMsikX0A79rgp3C1eN+5RTGEFEkmaJNAtsA8cwfj9q/DeoeMZF LY32MFTQfamxhRrti3Br+Mfi8pUJfnJjT0PpTkK2kdD8Bf1o1Siig8vtuT4SoHF7/BdF mSxtas1xKPVedq1qwcJX7+GmoVsslz8oK1N8eUJme6qAi1M53Iw+owpbwIkiMuQh6r4t 7frFLvLMDQ/MuXo3hdQDK0VKZvzO6rB+/sLkr4L/8OeQgWwYD5+6U+Ua0VubbunMK5Fl sgqQ== 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=VzMIdxD71y/bO7upsiOuU3NKk3PckqOaYlYibM5gemYePZxGyBrY2+ghZZ4wBfIxX8 QAL9MFhKZv1gRn1AmpD4i/KSiZFwJobLn+DizzdP5eWohxCLAB/9ImR7ObF90WMor2PA 2FJMP7ouNf+Grhxcq1CgXcCkVclbzTXHKrHIcZMlxY5/G/GRODB+DwaGSdRRZPZliVSo qDg/Jd/oU1tpbXIunCMM6PjBICZmIm+Uw1FxvXqu/RhhIKJIzdFVotzJ1NthdF7zVM3Q 4i51+cHAajMJbQHesivMdZTH2ws+Lmk63HIx8O7nyTamFplb/mfiqq25ziVGYr3uSW6X vPwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gZF9RYIw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112910-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112910-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id hg10-20020a05622a610a00b0043120539247si3863792qtb.679.2024.03.24.15.41.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:41:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112910-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gZF9RYIw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112910-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112910-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 98D4D1C2116E for ; Sun, 24 Mar 2024 22:41:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A0DF67A0D; Sun, 24 Mar 2024 22:35:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gZF9RYIw" 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 8104E62802; Sun, 24 Mar 2024 22:35:21 +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=1711319721; cv=none; b=XF3zFEQE7SmVk3Jyj5qerzzfJ3yuu4cA56LlRH0n5TuBqTAOQSNvq7wG6M9yxH4gps1vxoQk0fe+T0/ZnlrgSA8IEDD1iA6qg7R6zj3oSAl+SD7Gn/+MVsSxjNzkYVyKr3yj+KxBYpxEbgScsQZWrW1/oY3Ic19sK70Y3+gfLV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319721; c=relaxed/simple; bh=c/8ThzkfXePMKSUnih7WKsu2s/C2H5smRXIfTXnLdnc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MvOSQoLrOwn8IfQTRVQd3TRc7E/V0Gwffb3na/ErmdQr/gUADDJTtXcA79sV+kNC1/OJB5yOzjQ55/36NxGbpRj7pQ9R06kwZ5NHyUAM6xm6aq6CC9Wfj8gEx89GSPskmZu6Fz0nNeTV6B+suUyOr8R34hjb134A6D+FxoKYgdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gZF9RYIw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B6FEC433C7; Sun, 24 Mar 2024 22:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319721; bh=c/8ThzkfXePMKSUnih7WKsu2s/C2H5smRXIfTXnLdnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gZF9RYIw/nR3jg+ructF7EbBdjduUsN/Odhm1nHGHUd8iG2u3U07pdCc8es1tnm3Q mB5Zsk7AlI7TRD4zn9do1YDTInmLYBGf7QADlZiMayaFuqN7zzhDuI7J7UoOEVKT0A o5qhRIEug0HyhWq0ulZ6chSB8s9Mq7w4IdYNEA85IuAt7JxgYmJ402Op9CcfmyrQ+M 6gIWd+v/QTo4gfzvmXVvsu5s+yBbwwqMUq8RwWOz2pUkB0kxxlZfI2xnEuWRamu+oA WHjprW2VuSlODvY3V49dUUFHxHDQpiqvIDjbv8ppkq/aAgIVOzPL0sZJ9SYvXYBx2O RqWgmELXwpRZQ== 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.8 023/715] fs/select: rework stack allocation hack for clang Date: Sun, 24 Mar 2024 18:23:22 -0400 Message-ID: <20240324223455.1342824-24-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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