Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

NOMMU: Lock i_mmap_mutex for access to the VMA prio list

Lock i_mmap_mutex for access to the VMA prio list to prevent concurrent
access. Currently, certain parts of the mmap handling are protected by
the region mutex, but not all.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Howells and committed by
Linus Torvalds
918e556e 37e79cbf

+7
+7
mm/nommu.c
··· 696 696 if (vma->vm_file) { 697 697 mapping = vma->vm_file->f_mapping; 698 698 699 + mutex_lock(&mapping->i_mmap_mutex); 699 700 flush_dcache_mmap_lock(mapping); 700 701 vma_prio_tree_insert(vma, &mapping->i_mmap); 701 702 flush_dcache_mmap_unlock(mapping); 703 + mutex_unlock(&mapping->i_mmap_mutex); 702 704 } 703 705 704 706 /* add the VMA to the tree */ ··· 762 760 if (vma->vm_file) { 763 761 mapping = vma->vm_file->f_mapping; 764 762 763 + mutex_lock(&mapping->i_mmap_mutex); 765 764 flush_dcache_mmap_lock(mapping); 766 765 vma_prio_tree_remove(vma, &mapping->i_mmap); 767 766 flush_dcache_mmap_unlock(mapping); 767 + mutex_unlock(&mapping->i_mmap_mutex); 768 768 } 769 769 770 770 /* remove from the MM's tree and list */ ··· 2056 2052 high = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 2057 2053 2058 2054 down_write(&nommu_region_sem); 2055 + mutex_lock(&inode->i_mapping->i_mmap_mutex); 2059 2056 2060 2057 /* search for VMAs that fall within the dead zone */ 2061 2058 vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap, ··· 2064 2059 /* found one - only interested if it's shared out of the page 2065 2060 * cache */ 2066 2061 if (vma->vm_flags & VM_SHARED) { 2062 + mutex_unlock(&inode->i_mapping->i_mmap_mutex); 2067 2063 up_write(&nommu_region_sem); 2068 2064 return -ETXTBSY; /* not quite true, but near enough */ 2069 2065 } ··· 2092 2086 } 2093 2087 } 2094 2088 2089 + mutex_unlock(&inode->i_mapping->i_mmap_mutex); 2095 2090 up_write(&nommu_region_sem); 2096 2091 return 0; 2097 2092 }