Commit bf2efbc5 authored by Linus Torvalds's avatar Linus Torvalds

Make mm writelock testing less intrusive.

This enables it only for debug kernels, and also makes sure
that if some external module is still broken, we don't leave
the mmap-sem locked after warning about it.
parent 6a424eda
......@@ -1870,6 +1870,16 @@ asmlinkage long sys_munmap(unsigned long addr, size_t len)
return ret;
}
static inline void verify_mm_writelocked(struct mm_struct *mm)
{
#ifdef CONFIG_DEBUG_KERNEL
if (unlikely(down_read_trylock(&mm->mmap_sem))) {
WARN_ON(1);
up_read(&mm->mmap_sem);
}
#endif
}
/*
* this is really a simplified "do_mmap". it only handles
* anonymous maps. eventually we may be able to do some
......@@ -1906,7 +1916,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
* mm->mmap_sem is required to protect against another thread
* changing the mappings in case we sleep.
*/
WARN_ON(down_read_trylock(&mm->mmap_sem));
verify_mm_writelocked(mm);
/*
* Clear old maps. this also does some error checking for us
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment