Matthew Wilcox
2018-06-21 04:29:12 UTC
The kernel may sleep with holding a spinlock.
[FUNC] kmem_cache_alloc(GFP_KERNEL)
kmem_cache_alloc in fsnotify_attach_connector_to_object
fsnotify_attach_connector_to_object in fsnotify_add_mark_list
fsnotify_add_mark_list in fsnotify_add_mark_locked
fsnotify_add_mark_locked in tag_chunk
spin_lock in tag_chunk
There are several locks here; your report would be improved by saying[FUNC] kmem_cache_alloc(GFP_KERNEL)
kmem_cache_alloc in fsnotify_attach_connector_to_object
fsnotify_attach_connector_to_object in fsnotify_add_mark_list
fsnotify_add_mark_list in fsnotify_add_mark_locked
fsnotify_add_mark_locked in tag_chunk
spin_lock in tag_chunk
which one is the problem. I'm assuming it's old_entry->lock.
spin_lock(&old_entry->lock);
...
if (fsnotify_add_inode_mark_locked(chunk_entry,
old_entry->connector->inode, 1)) {
...
return fsnotify_add_mark_locked(mark, inode, NULL, allow_dups);
...
ret = fsnotify_add_mark_list(mark, inode, mnt, allow_dups);
...
if (inode)
connp = &inode->i_fsnotify_marks;
conn = fsnotify_grab_connector(connp);
if (!conn) {
err = fsnotify_attach_connector_to_object(connp, inode, mnt);
It seems to me that this is safe because old_entry is looked up from
fsnotify_find_mark, and it can't be removed while its lock is held.
Therefore there's always a 'conn' returned from fsnotify_grab_connector(),
and so this path will never be taken.
But this code path is confusing to me, and I could be wrong. Jan, please
confirm my analysis is correct?
[FUNC] kmem_cache_alloc(GFP_KERNEL)
kmem_cache_alloc in fsnotify_attach_connector_to_object
fsnotify_attach_connector_to_object in fsnotify_add_mark_list
fsnotify_add_mark_list in fsnotify_add_mark_locked
fsnotify_add_mark_locked in untag_chunk
spin_lock in untag_chunk
I'm just going to assume this one is the same.kmem_cache_alloc in fsnotify_attach_connector_to_object
fsnotify_attach_connector_to_object in fsnotify_add_mark_list
fsnotify_add_mark_list in fsnotify_add_mark_locked
fsnotify_add_mark_locked in untag_chunk
spin_lock in untag_chunk