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: <20160926161126.GA32458@quack2.suse.cz>
Date:   Mon, 26 Sep 2016 18:11:26 +0200
From:   Jan Kara <jack@...e.cz>
To:     Oleg Nesterov <oleg@...hat.com>
Cc:     Al Viro <viro@...iv.linux.org.uk>,
        Dave Chinner <david@...morbit.com>, Jan Kara <jack@...e.cz>,
        Nikolay Borisov <kernel@...p.com>,
        "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] fs/super.c: fix race between freeze_super() and
 thaw_super()

On Mon 26-09-16 18:07:48, Oleg Nesterov wrote:
> Change thaw_super() to check frozen != SB_FREEZE_COMPLETE rather than
> frozen == SB_UNFROZEN, otherwise it can race with freeze_super() which
> drops sb->s_umount after SB_FREEZE_WRITE to preserve the lock ordering.
> 
> In this case thaw_super() will wrongly call s_op->unfreeze_fs() before
> it was actually frozen, and call sb_freeze_unlock() which leads to the
> unbalanced percpu_up_write(). Unfortunately lockdep can't detect this,
> so this triggers misc BUG_ON()'s in kernel/rcu/sync.c.
> 
> Reported-and-tested-by: Nikolay Borisov <kernel@...p.com>
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>
> Cc: stable@...r.kernel.org

The patch looks good. Thanks!

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza
> ---
>  fs/super.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/super.c b/fs/super.c
> index d78b984..2549896c 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -1324,8 +1324,8 @@ int freeze_super(struct super_block *sb)
>  		}
>  	}
>  	/*
> -	 * This is just for debugging purposes so that fs can warn if it
> -	 * sees write activity when frozen is set to SB_FREEZE_COMPLETE.
> +	 * For debugging purposes so that fs can warn if it sees write activity
> +	 * when frozen is set to SB_FREEZE_COMPLETE, and for thaw_super().
>  	 */
>  	sb->s_writers.frozen = SB_FREEZE_COMPLETE;
>  	up_write(&sb->s_umount);
> @@ -1344,7 +1344,7 @@ int thaw_super(struct super_block *sb)
>  	int error;
>  
>  	down_write(&sb->s_umount);
> -	if (sb->s_writers.frozen == SB_UNFROZEN) {
> +	if (sb->s_writers.frozen != SB_FREEZE_COMPLETE) {
>  		up_write(&sb->s_umount);
>  		return -EINVAL;
>  	}
> -- 
> 2.5.0
> 
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ