mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] fs/afs/flock: possible sleep-in-atomic bugs in afs_do_setlk
@ 2017-10-07 10:11 Jia-Ju Bai
  0 siblings, 0 replies; only message in thread
From: Jia-Ju Bai @ 2017-10-07 10:11 UTC (permalink / raw)
  To: viro, dhowells; +Cc: linux-afs, linux-kernel

According to fs/afs/flock.c, the kernel may sleep under a spinlock,
and the function call paths are:
afs_do_setlk (acquire the spinlock: inode->i_lock)
   afs_vnode_fetch_status
     schedule --> may sleep

afs_do_setlk (acquire the spinlock: inode->i_lock)
   wait_event_interruptible --> may sleep

These bugs may be introduced by only considering "vnode->lock" but 
ignoring "inode->i_lock".

A possible fix is to unlock "inode->i_lock" before calling 
afs_vnode_fetch_status and wait_event_interruptible, and lock 
"inode->i_lock" again after them.

These bugs are found by my static analysis tool and my code review.


Thanks,
Jia-Ju Bai

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-07 10:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-07 10:11 [BUG] fs/afs/flock: possible sleep-in-atomic bugs in afs_do_setlk Jia-Ju Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®