Skip to content

Commit bbb325e

Browse files
kirylgregkh
authored andcommitted
mm: Fix false-positive VM_BUG_ON() in page_cache_{get,add}_speculative()
[ Upstream commit 591a3d7c09fa08baff48ad86c2347dbd28a52753 ] 0day testing by Fengguang Wu triggered this crash while running Trinity: kernel BUG at include/linux/pagemap.h:151! ... CPU: 0 PID: 458 Comm: trinity-c0 Not tainted 4.11.0-rc2-00251-g2947ba0 #1 ... Call Trace: __get_user_pages_fast() get_user_pages_fast() get_futex_key() futex_requeue() do_futex() SyS_futex() do_syscall_64() entry_SYSCALL64_slow_path() It' VM_BUG_ON() due to false-negative in_atomic(). We call page_cache_get_speculative() with disabled local interrupts. It should be atomic enough. So let's check for disabled interrupts in the VM_BUG_ON() condition too, to resolve this. ( This got triggered by the conversion of the x86 GUP code to the generic GUP code. ) Reported-by: Fengguang Wu <[email protected]> Signed-off-by: Kirill A. Shutemov <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: LKP <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 65c161c commit bbb325e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/linux/pagemap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static inline int page_cache_get_speculative(struct page *page)
146146

147147
#ifdef CONFIG_TINY_RCU
148148
# ifdef CONFIG_PREEMPT_COUNT
149-
VM_BUG_ON(!in_atomic());
149+
VM_BUG_ON(!in_atomic() && !irqs_disabled());
150150
# endif
151151
/*
152152
* Preempt must be disabled here - we rely on rcu_read_lock doing
@@ -184,7 +184,7 @@ static inline int page_cache_add_speculative(struct page *page, int count)
184184

185185
#if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU)
186186
# ifdef CONFIG_PREEMPT_COUNT
187-
VM_BUG_ON(!in_atomic());
187+
VM_BUG_ON(!in_atomic() && !irqs_disabled());
188188
# endif
189189
VM_BUG_ON_PAGE(page_count(page) == 0, page);
190190
atomic_add(count, &page->_count);

0 commit comments

Comments
 (0)