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: <20191213194943.GA959@quack2.suse.cz>
Date:   Fri, 13 Dec 2019 20:49:43 +0100
From:   Jan Kara <jack@...e.cz>
To:     Joel Fernandes <joel@...lfernandes.org>
Cc:     Phong Tran <tranmanphong@...il.com>, Jan Kara <jack@...e.cz>,
        "Theodore Y. Ts'o" <tytso@....edu>, adilger.kernel@...ger.ca,
        "Paul E. McKenney" <paulmck@...nel.org>,
        linux-ext4@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
        linux-kernel-mentees@...ts.linuxfoundation.org,
        rcu <rcu@...r.kernel.org>, stable <stable@...r.kernel.org>
Subject: Re: [PATCH V2] ext4: use rcu API in debug_print_tree

On Fri 13-12-19 10:11:50, Joel Fernandes wrote:
> On Fri, Dec 13, 2019 at 7:39 AM Phong Tran <tranmanphong@...il.com> wrote:
> >
> > struct ext4_sb_info.system_blks was marked __rcu.
> > But access the pointer without using RCU lock and dereference.
> > Sparse warning with __rcu notation:
> >
> > block_validity.c:139:29: warning: incorrect type in argument 1 (different address spaces)
> > block_validity.c:139:29:    expected struct rb_root const *
> > block_validity.c:139:29:    got struct rb_root [noderef] <asn:4> *
> >
> > Reviewed-by: Jan Kara <jack@...e.cz>
> > Signed-off-by: Phong Tran <tranmanphong@...il.com>
> 
> Thanks Phong! Looks like a real bug fix caught thanks to Sparse. So
> let us mark for stable as well?

Well, not really. The code is active only with CONFIG_EXT4_DEBUG enabled
and in this case there's no race with remount (and thus sbi->system_blks
changing) possible. So the change is really only to silence the sparse
warning.

								Honza

> 
> - Joel
> 
> > ---
> >  fs/ext4/block_validity.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > ---
> > change log:
> > V2: Add Reviewed-by: Jan Kara <jack@...e.cz>
> >
> > diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
> > index d4d4fdfac1a6..1ee04e76bbe0 100644
> > --- a/fs/ext4/block_validity.c
> > +++ b/fs/ext4/block_validity.c
> > @@ -133,10 +133,13 @@ static void debug_print_tree(struct ext4_sb_info *sbi)
> >  {
> >         struct rb_node *node;
> >         struct ext4_system_zone *entry;
> > +       struct ext4_system_blocks *system_blks;
> >         int first = 1;
> >
> >         printk(KERN_INFO "System zones: ");
> > -       node = rb_first(&sbi->system_blks->root);
> > +       rcu_read_lock();
> > +       system_blks = rcu_dereference(sbi->system_blks);
> > +       node = rb_first(&system_blks->root);
> >         while (node) {
> >                 entry = rb_entry(node, struct ext4_system_zone, node);
> >                 printk(KERN_CONT "%s%llu-%llu", first ? "" : ", ",
> > @@ -144,6 +147,7 @@ static void debug_print_tree(struct ext4_sb_info *sbi)
> >                 first = 0;
> >                 node = rb_next(node);
> >         }
> > +       rcu_read_unlock();
> >         printk(KERN_CONT "\n");
> >  }
> >
> > --
> > 2.20.1
> >
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ