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] [day] [month] [year] [list]
Message-ID: <CAEVVKH8TYoQjZSJr7DjecgEq-EAZEqWqC=EC_pFPzti3VLh6_g@mail.gmail.com>
Date:   Fri, 18 Jun 2021 09:54:59 +0800
From:   Xiongwei Song <sxwjean@...il.com>
To:     Boqun Feng <boqun.feng@...il.com>
Cc:     Xiongwei Song <sxwjean@...com>, peterz@...radead.org,
        mingo@...hat.com, will@...nel.org, longman@...hat.com,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] locking/lockdep: print possible warning after
 counting deps

On Thu, Jun 17, 2021 at 11:13 PM Boqun Feng <boqun.feng@...il.com> wrote:
>
> Hi,
>
> On Thu, Jun 17, 2021 at 10:28:28PM +0800, Xiongwei Song wrote:
> > From: Xiongwei Song <sxwjean@...il.com>
> >
> > The graph walk might hit error when counting dependencies. Once the
> > return value is negative, print a warning to reminder users.
> >
>
> Thanks for the improvement, but please see below:
>
> > Suggested-by: Waiman Long <longman@...hat.com>
> > Signed-off-by: Xiongwei Song <sxwjean@...il.com>
> > ---
> >  kernel/locking/lockdep.c | 12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> > index cb94097014d8..cfe0f4374594 100644
> > --- a/kernel/locking/lockdep.c
> > +++ b/kernel/locking/lockdep.c
> > @@ -2028,8 +2028,12 @@ static unsigned long __lockdep_count_forward_deps(struct lock_list *this)
> >  {
> >       unsigned long  count = 0;
> >       struct lock_list *target_entry;
> > +     enum bfs_result ret;
> > +
> > +     ret = __bfs_forwards(this, (void *)&count, noop_count, NULL, &target_entry);
> >
> > -     __bfs_forwards(this, (void *)&count, noop_count, NULL, &target_entry);
> > +     if (bfs_error(ret))
> > +             print_bfs_bug(ret);
>
> Here print_bfs_bug() will eventually call debug_locks_off_graph_unlock()
> to release the graph lock, and the caller (lockdep_count_fowards_deps())
> will also call graph_unlock() afterwards, and that means we unlock
> *twice* if a BFS error happens... although in that case, lockdep should
> stop working so messing up with the graph lock may not hurt anything,
> but still, I don't think we want to do that.
>
> So probably you can open-code __lockdep_count_forward_deps() into
> lockdep_count_forwards_deps(), and call print_bfs_bug() or
> graph_unlock() accordingly. The body of __lockdep_count_forward_deps()
> is really small, so I think it's OK to open-code it into its caller.

Thank you so much for the detailed comments. Let me improve and update
the patch.

Regards,
Xiongwei

>
> Regards,
> Boqun
>
> >
> >       return count;
> >  }
> > @@ -2053,8 +2057,12 @@ static unsigned long __lockdep_count_backward_deps(struct lock_list *this)
> >  {
> >       unsigned long  count = 0;
> >       struct lock_list *target_entry;
> > +     enum bfs_result ret;
> > +
> > +     ret = __bfs_backwards(this, (void *)&count, noop_count, NULL, &target_entry);
> >
> > -     __bfs_backwards(this, (void *)&count, noop_count, NULL, &target_entry);
> > +     if (bfs_error(ret))
> > +             print_bfs_bug(ret);
> >
> >       return count;
> >  }
> > --
> > 2.30.2
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ