Skip to content

Commit c853680

Browse files
author
Miklos Szeredi
committed
ovl: fix lockdep warning for async write
Lockdep reports "WARNING: lock held when returning to user space!" due to async write holding freeze lock over the write. Apparently aio.c already deals with this by lying to lockdep about the state of the lock. Do the same here. No need to check for S_IFREG() here since these file ops are regular-only. Reported-by: syzbot+9331a354f4f624a52a55@syzkaller.appspotmail.com Fixes: 2406a30 ("ovl: implement async IO routines") Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 53afcd3 commit c853680

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

fs/overlayfs/file.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ static void ovl_aio_cleanup_handler(struct ovl_aio_req *aio_req)
244244
if (iocb->ki_flags & IOCB_WRITE) {
245245
struct inode *inode = file_inode(orig_iocb->ki_filp);
246246

247+
/* Actually acquired in ovl_write_iter() */
248+
__sb_writers_acquired(file_inode(iocb->ki_filp)->i_sb,
249+
SB_FREEZE_WRITE);
247250
file_end_write(iocb->ki_filp);
248251
ovl_copyattr(ovl_inode_real(inode), inode);
249252
}
@@ -346,6 +349,9 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
346349
goto out;
347350

348351
file_start_write(real.file);
352+
/* Pacify lockdep, same trick as done in aio_write() */
353+
__sb_writers_release(file_inode(real.file)->i_sb,
354+
SB_FREEZE_WRITE);
349355
aio_req->fd = real;
350356
real.flags = 0;
351357
aio_req->orig_iocb = iocb;

0 commit comments

Comments
 (0)