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: <20220124113758.y34xceepk7oe26h7@wittgenstein>
Date:   Mon, 24 Jan 2022 12:37:58 +0100
From:   Christian Brauner <brauner@...nel.org>
To:     Waiman Long <longman@...hat.com>
Cc:     Al Viro <viro@...iv.linux.org.uk>, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] vfs: Pre-allocate superblock in sget_fc() if !test

On Fri, Jan 21, 2022 at 01:52:55PM -0500, Waiman Long wrote:
> When the test function is not defined in sget_fc(), we always need
> to allocate a new superblock. So there is no point in acquiring the
> sb_lock twice in this case. Optimize the !test case by pre-allocating
> the superblock first before acquring the lock.
> 
> Signed-off-by: Waiman Long <longman@...hat.com>
> ---
>  fs/super.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/super.c b/fs/super.c
> index a6405d44d4ca..c2bd5c34a826 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -520,6 +520,8 @@ struct super_block *sget_fc(struct fs_context *fc,
>  	struct user_namespace *user_ns = fc->global ? &init_user_ns : fc->user_ns;
>  	int err;
>  
> +	if (!test)
> +		s = alloc_super(fc->fs_type, fc->sb_flags, user_ns);

Shouldn't we treat this allocation failure as "fatal" right away and not
bother taking locks, walking lists and so on? Seems strange to treat it
as fatal below but not here.

(The code-flow in here has always been a bit challenging to follow imho.
So not super keen to see more special-cases in there. Curious: do you
see any noticeable performance impact from that lock being taken and
dropped for the !test case?)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ