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-next>] [day] [month] [year] [list]
Date:   Thu, 30 Jun 2022 23:05:07 +0000
From:   Ioannis Angelakopoulos <iangelak@...com>
To:     "mingo@...hat.com" <mingo@...hat.com>,
        "jack@...e.com" <jack@...e.com>
CC:     "boris@....io" <boris@....io>,
        "josef@...icpanda.com" <josef@...icpanda.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Modeling wait events with Lockdep

Hello,

I would like to ask some questions regarding modeling waiting for events 
(i.e the wait_event) in Linux using Lockdep.
I am trying to model these events in btrfs since there are deadlocks 
detected involving waiting for events and Lockdep is not currently able 
to address them (e.g., 
https://lore.kernel.org/linux-btrfs/cover.1655147296.git.josef@toxicpanda.com/).

I am very new to Lockdep so I would like to know, what would be the 
correct way of implementing these models using Lockdep?
I noticed that JBD2 uses a read-write lockdep map. It takes the read 
lockdep map when it creates a transaction handle and unlocks the read 
lockdep map when it frees the handle. Also, every time the thread has to 
wait for resources (e.g., transaction credits) and the handle is not 
supposed to be alive, the thread locks and unlocks immediately the write 
lockdep map before the waiting event (maybe I understood something wrong 
here?). Is this the only Lockdep model that can be used for these 
waiting events?

For your reference, here are 2 examples that we are trying to annotate 
with Lockdep and we would like to know if we are on the correct track.

In the first example it makes sense to use the JBD2 model, however we 
are not sure how to apply the model in the second case. The comments 
indicate our concerns.

------------------------------
Simple Case:

TA
rwsem_acquire_read(lockdep_map);
cond=false
do_work()
cond=true
rwsem_release_read(lockdep_map);
signal(w)

TB
rwsem_acquire(lockdep_map);
rswem_release(lockdep_map);
wait_event(w, cond==true)

Advanced Case:

TA
rwsem_acquire_read(lockdep_map)
cond=false
// exits while holding the lock

TB
cond=true
rwsem_release_read(lockdep_map) // We do not know that we hold the lock
signal(w)

TC
rwsem_acquire(lockdep_map);
rswem_release(lockdep_map);
wait_event(w, cond==true)

------------------------------

I am aware that DEPT (Dependency Tracker) which targets waiting for 
events in Linux is under development.
However, I need to implement these Lockdep models to aid the btrfs 
developers to catch existing deadlocks until DEPT is mature enough to be 
used.

Thanks,
Ioannis

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ