Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4776599rwe; Mon, 17 Apr 2023 19:10:14 -0700 (PDT) X-Google-Smtp-Source: AKy350bldzL2nCSF38vmBfnGxhtQwYpFYw8dKohw/WnN4YzmykX68NIXTzzGNtLPUC8CKVAj/hHb X-Received: by 2002:a05:6a21:9991:b0:ee:8450:a3c9 with SMTP id ve17-20020a056a21999100b000ee8450a3c9mr15585609pzb.2.1681783813927; Mon, 17 Apr 2023 19:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681783813; cv=none; d=google.com; s=arc-20160816; b=K+lp1evKThlxaHEfb1so6nOPMHFJAofelVR45t8rylcCfyblrBgNjBGq/6v6FfXOhC YlltzFEB0PWcCoZ4kuUGMqOO6NDlgKsLS6rdCQEvJja4+jJ2FZTH+21WiJV62ZQijUb2 ci1Y/qFnH9v1SqffE2xwKIqKXSEL/TjkDf/owJ/E9gwHs74DTQpV18rQX6fk/tczTZA6 9XDkGLrP/VCRwgw5AbmGzf/nPTyMvjH+bXCWDDecjqPnesDvOEdvAUZxsEOWXJs9D1Al GztjSTiYjXuCWyLRgcyipXeVIzeOX63zgU20+nX7gJW7BiDQ6ogMxuatFJFzGoRbrRiG H25g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=ah6f8MBFB7TfVYgDFOew2836ZvDJYbTnNZHM57oDzSM=; b=EoL6LUAU8Ik5aYcBSM5+3BAeFM6JqnWAWKOgWFAl09tBILthFEaX+qiC/9x6StCKDp 1yK9l2EyesF7dLfD3GY9BktZdTQ6pYtMX5XthlShgqN3vUzVHaCJm2BcfgI4J/3teHLI kZKXqQ84qbxqFmoJrrN0APCVvdA36JAbkLZeG9AiTgkhSk+zN4+bZQ/BkLOAgHDuKl6v 9mWevChIsMykxuZY25bhE0pXw9EhGtVT5Wfn8SeX9PcNzMqXtxHO+Yk2W23cLDbGS2ML Um8yCuklQ4rliSDlIENpHlqh/mO5Dctm6lF4JnYwdD7RHaj/prRan1vnV3p/PWuGViui JHqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r13-20020aa7988d000000b0063b897210a4si5516434pfl.14.2023.04.17.19.10.02; Mon, 17 Apr 2023 19:10:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229687AbjDRBym (ORCPT + 99 others); Mon, 17 Apr 2023 21:54:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbjDRByk (ORCPT ); Mon, 17 Apr 2023 21:54:40 -0400 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD3675BB4 for ; Mon, 17 Apr 2023 18:54:01 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0VgMyoZU_1681782265; Received: from 30.221.129.246(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0VgMyoZU_1681782265) by smtp.aliyun-inc.com; Tue, 18 Apr 2023 09:44:26 +0800 Message-ID: <1cd0f938-72b8-2686-1db9-d8c229700e14@linux.alibaba.com> Date: Tue, 18 Apr 2023 09:44:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] ocfs2: reduce ioctl stack usage To: Arnd Bergmann , Mark Fasheh , Joel Becker , akpm Cc: Arnd Bergmann , David Sterba , =?UTF-8?Q?Christoph_B=c3=b6hmwalder?= , Jens Axboe , "Martin K. Petersen" , =?UTF-8?Q?Jan_H=c3=b6ppner?= , Christian Brauner , ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org References: <20230417205631.1956027-1-arnd@kernel.org> Content-Language: en-US From: Joseph Qi In-Reply-To: <20230417205631.1956027-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/18/23 4:56 AM, Arnd Bergmann wrote: > From: Arnd Bergmann > > On 32-bit architectures with KASAN_STACK enabled, the total stack usage > of the ocfs2_ioctl function grows beyond the warning limit: > > fs/ocfs2/ioctl.c: In function 'ocfs2_ioctl': > fs/ocfs2/ioctl.c:934:1: error: the frame size of 1448 bytes is larger than 1400 bytes [-Werror=frame-larger-than=] > > Move each of the variables into a basic block, and mark ocfs2_info_handle() > as noinline_for_stack, in order to have the variable share stack slots. > > Signed-off-by: Arnd Bergmann Looks good. Reviewed-by: Joseph Qi > --- > fs/ocfs2/ioctl.c | 37 ++++++++++++++++++++++++++----------- > 1 file changed, 26 insertions(+), 11 deletions(-) > > diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c > index 811a6ea374bb..b1550ba73f96 100644 > --- a/fs/ocfs2/ioctl.c > +++ b/fs/ocfs2/ioctl.c > @@ -803,8 +803,8 @@ static int ocfs2_get_request_ptr(struct ocfs2_info *info, int idx, > * a better backward&forward compatibility, since a small piece of > * request will be less likely to be broken if disk layout get changed. > */ > -static int ocfs2_info_handle(struct inode *inode, struct ocfs2_info *info, > - int compat_flag) > +static noinline_for_stack int > +ocfs2_info_handle(struct inode *inode, struct ocfs2_info *info, int compat_flag) > { > int i, status = 0; > u64 req_addr; > @@ -840,27 +840,26 @@ static int ocfs2_info_handle(struct inode *inode, struct ocfs2_info *info, > long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > { > struct inode *inode = file_inode(filp); > - int new_clusters; > - int status; > - struct ocfs2_space_resv sr; > - struct ocfs2_new_group_input input; > - struct reflink_arguments args; > - const char __user *old_path; > - const char __user *new_path; > - bool preserve; > - struct ocfs2_info info; > void __user *argp = (void __user *)arg; > + int status; > > switch (cmd) { > case OCFS2_IOC_RESVSP: > case OCFS2_IOC_RESVSP64: > case OCFS2_IOC_UNRESVSP: > case OCFS2_IOC_UNRESVSP64: > + { > + struct ocfs2_space_resv sr; > + > if (copy_from_user(&sr, (int __user *) arg, sizeof(sr))) > return -EFAULT; > > return ocfs2_change_file_space(filp, cmd, &sr); > + } > case OCFS2_IOC_GROUP_EXTEND: > + { > + int new_clusters; > + > if (!capable(CAP_SYS_RESOURCE)) > return -EPERM; > > @@ -873,8 +872,12 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > status = ocfs2_group_extend(inode, new_clusters); > mnt_drop_write_file(filp); > return status; > + } > case OCFS2_IOC_GROUP_ADD: > case OCFS2_IOC_GROUP_ADD64: > + { > + struct ocfs2_new_group_input input; > + > if (!capable(CAP_SYS_RESOURCE)) > return -EPERM; > > @@ -887,7 +890,14 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > status = ocfs2_group_add(inode, &input); > mnt_drop_write_file(filp); > return status; > + } > case OCFS2_IOC_REFLINK: > + { > + struct reflink_arguments args; > + const char __user *old_path; > + const char __user *new_path; > + bool preserve; > + > if (copy_from_user(&args, argp, sizeof(args))) > return -EFAULT; > old_path = (const char __user *)(unsigned long)args.old_path; > @@ -895,11 +905,16 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > preserve = (args.preserve != 0); > > return ocfs2_reflink_ioctl(inode, old_path, new_path, preserve); > + } > case OCFS2_IOC_INFO: > + { > + struct ocfs2_info info; > + > if (copy_from_user(&info, argp, sizeof(struct ocfs2_info))) > return -EFAULT; > > return ocfs2_info_handle(inode, &info, 0); > + } > case FITRIM: > { > struct super_block *sb = inode->i_sb;