lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <eab9dee1-a542-b079-7c49-7f3cb2974e47@themaw.net>
Date:   Wed, 13 Dec 2023 09:13:27 +0800
From:   Ian Kent <raven@...maw.net>
To:     Arnd Bergmann <arnd@...nel.org>,
        Alexander Viro <viro@...iv.linux.org.uk>,
        Christian Brauner <brauner@...nel.org>
Cc:     Arnd Bergmann <arnd@...db.de>, Jan Kara <jack@...e.cz>,
        Miklos Szeredi <mszeredi@...hat.com>,
        "Seth Forshee (DigitalOcean)" <sforshee@...nel.org>,
        Dave Chinner <dchinner@...hat.com>,
        Amir Goldstein <amir73il@...il.com>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] statmount: reduce runtime stack usage

On 13/12/23 05:48, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@...db.de>
>
> prepare_kstatmount() constructs a copy of 'struct kstatmount' on the stack
> and copies it into the local variable on the stack of its caller. Because
> of the size of this structure, this ends up overflowing the limit for
> a single function's stack frame when prepare_kstatmount() gets inlined
> and both copies are on the same frame without the compiler being able
> to collapse them into one:
>
> fs/namespace.c:4995:1: error: stack frame size (1536) exceeds limit (1024) in '__se_sys_statmount' [-Werror,-Wframe-larger-than]
>   4995 | SYSCALL_DEFINE4(statmount, const struct mnt_id_req __user *, req,
>
> Mark the inner function as noinline_for_stack so the second copy is
> freed before calling do_statmount() enters filesystem specific code.
> The extra copy of the structure is a bit inefficient, but this
> system call should not be performance critical.

Are you sure this is not performance sensitive, or is the performance

critical comment not related to the system call being called many times?


It's going to be a while (if ever) before callers change there ways.


Consider what happens when a bunch of mounts are being mounted.


First there are a lot of events and making the getting of mount info.

more efficient means more of those events get processed (itself an issue

that's going to need notification sub-system improvement) resulting in

the system call being called even more.


There are 3 or 4 common programs that monitor the mounts, systemd is

one of those, it usually has 3 processes concurrently listening for

mount table events and every one of these processes grabs the entire

table. Thing is systemd is actually quite good at handling events and

can process a lot of them if they are being occuring.


So this system call will be called a lot.


Ian

>
> Fixes: 49889374ab92 ("statmount: simplify string option retrieval")
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>   fs/namespace.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index d036196f949c..e22fb5c4a9bb 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -4950,7 +4950,8 @@ static inline bool retry_statmount(const long ret, size_t *seq_size)
>   	return true;
>   }
>   
> -static int prepare_kstatmount(struct kstatmount *ks, struct mnt_id_req *kreq,
> +static int noinline_for_stack
> +prepare_kstatmount(struct kstatmount *ks, struct mnt_id_req *kreq,
>   			      struct statmount __user *buf, size_t bufsize,
>   			      size_t seq_size)
>   {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ