loop: Fix irq lock ordering bug
Subsystems (2)
PATCH 1/1 loop: Fix irq lock ordering bug
"loop: Use worker per cgroup instead of kworker" in patch series "Charge loop device i/o to issuing cgroup", v3. introduced a lock ordering bug. The previously existing lo->lo_lock was always acquired as spin_lock_irq but never actually used in irq context. The above patch started to use this lock in irq context which triggered a lockdep warning on sysfs reading.
Fix this by executing file_path outside of the lock.
Signed-off-by Dan Schatzberg <[email protected]>
--- drivers/block/loop.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/block/loop.c +7 -1
@@ -768,12 +768,18 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf) {ssize_t ret;char *p =NULL ; +struct file *filp =NULL ;spin_lock_irq (&lo->lo_lock);if (lo->lo_backing_file) - p =file_path (lo->lo_backing_file, buf,PAGE_SIZE -1 ); + filp =get_file (lo->lo_backing_file);spin_unlock_irq (&lo->lo_lock); +if (filp) { + p =file_path (filp, buf,PAGE_SIZE -1 ); +fput (filp); + } +if (IS_ERR_OR_NULL (p)) ret =PTR_ERR (p);else {
Signature · 1 line
2.17.1