aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-22 13:49:40 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-22 13:49:40 -0700
commit1b17844b29ae042576bea588164f2f1e9590a8bc (patch)
treeca1751393012b54f7be0b5b1750299e4e2ff4a8a
parentMerge tag 'gpio-v3.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/lin... (diff)
downloadlinux-1b17844b29ae042576bea588164f2f1e9590a8bc.tar.gz
linux-1b17844b29ae042576bea588164f2f1e9590a8bc.zip
mm: make fixup_user_fault() check the vma access rights too
fixup_user_fault() is used by the futex code when the direct user access fails, and the futex code wants it to either map in the page in a usable form or return an error. It relied on handle_mm_fault() to map the page, and correctly checked the error return from that, but while that does map the page, it doesn't actually guarantee that the page will be mapped with sufficient permissions to be then accessed. So do the appropriate tests of the vma access rights by hand. [ Side note: arguably handle_mm_fault() could just do that itself, but we have traditionally done it in the caller, because some callers - notably get_user_pages() - have been able to access pages even when they are mapped with PROT_NONE. Maybe we should re-visit that design decision, but in the meantime this is the minimal patch. ] Found by Dave Jones running his trinity tool. Reported-by: Dave Jones <davej@redhat.com> Acked-by: Hugh Dickins <hughd@google.com> Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/memory.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/mm/memory.c b/mm/memory.c
index d0f0bef3be48..93e332d5ed77 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1955,12 +1955,17 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
unsigned long address, unsigned int fault_flags)
{
struct vm_area_struct *vma;
+ vm_flags_t vm_flags;
int ret;
vma = find_extend_vma(mm, address);
if (!vma || address < vma->vm_start)
return -EFAULT;
+ vm_flags = (fault_flags & FAULT_FLAG_WRITE) ? VM_WRITE : VM_READ;
+ if (!(vm_flags & vma->vm_flags))
+ return -EFAULT;
+
ret = handle_mm_fault(mm, vma, address, fault_flags);
if (ret & VM_FAULT_ERROR) {
if (ret & VM_FAULT_OOM)
href='/linux/commit/MAINTAINERS?id=a1ffc2d25ae98878f37445d223b3344686b5c822&follow=1'>MAINTAINERS: greybus: Fix typo s/LOOBACK/LOOPBACKSedat Dilek1-1/+1 2017-08-08random: fix warning message on ia64 and pariscHelge Deller1-1/+1 2017-08-07qed: Fix a memory allocation failure test in 'qed_mcp_cmd_init()'Christophe Jaillet1-1/+1 2017-08-07hysdn: fix to a race condition in put_log_bufferAnton Volkov1-15/+13 2017-08-07s390/qeth: fix L3 next-hop in xmit qeth hdrJulian Wiedmann1-2/+2 2017-08-07asix: Fix small memory leak in ax88772_unbind()Dean Jenkins3-0/+17 2017-08-07asix: Ensure asix_rx_fixup_info members are all resetDean Jenkins1-9/+25 2017-08-07asix: Add rx->ax_skb = NULL after usbnet_skb_return()Dean Jenkins1-1/+3 2017-08-07bpf: fix selftest/bpf/test_pkt_md_access on s390xThomas Richter1-0/+11 2017-08-06netvsc: fix race on sub channel creationstephen hemminger3-7/+11 2017-08-06Linux 4.13-rc4v4.13-rc4Linus Torvalds1-1/+1 2017-08-06Fix compat_sys_sigpending breakageDmitry V. Levin1-4/+7 2017-08-06ext4: fix copy paste error in ext4_swap_extents()Maninder Singh1-1/+1 2017-08-06ext4: fix overflow caused by missing cast in ext4_resize_fs()Jerry Lee1-1/+2 2017-08-06ext4, project: expand inode extra size if possibleMiao Xie3-24/+85 2017-08-06ext4: cleanup ext4_expand_extra_isize_ea()Miao Xie1-9/+5 2017-08-06ext4: restructure ext4_expand_extra_isizeMiao Xie2-40/+36 2017-08-06ext4: fix forgetten xattr lock protection in ext4_expand_extra_isizeMiao Xie2-12/+16 2017-08-06ext4: make xattr inode reads fasterTahsin Erdogan4-48/+92 2017-08-05ext4: inplace xattr block update fails to deduplicate blocksTahsin Erdogan1-3/+1 2017-08-05ext4: remove unused mode parameterTahsin Erdogan1-5/+4 2017-08-05ext4: fix warning about stack corruptionArnd Bergmann1-5/+6 2017-08-05ext4: fix dir_nlink behaviourAndreas Dilger2-10/+14 2017-08-05ext4: silence array overflow warningDan Carpenter1-1/+1 2017-08-05ext4: fix SEEK_HOLE/SEEK_DATA for blocksize < pagesizeJan Kara1-0/+3 2017-08-05platform/x86: intel-vbtn: match power button on press rather than releaseMario Limonciello1-2/+2 2017-08-05ext4: release discard bio after sending discard commandsDaeho Jeong1-1/+3 2017-08-04bpf: fix byte order test in test_verifierDaniel Borkmann1-9/+10 2017-08-04xfs: Fix per-inode DAX flag inheritanceLukas Czerner1-5/+7 2017-08-04xfs: Fix leak of discard bioJan Kara1-0/+1 2017-08-04IB/hns: checking for IS_ERR() instead of NULLDan Carpenter1-1/+1 2017-08-04xgene: Always get clk source, but ignore if it's missing for SGMII portsThomas Bogendoerfer1-3/+3 2017-08-04RDMA/mlx5: Fix existence check for extended address vectorLeon Romanovsky2-2/+1 2017-08-04IB/uverbs: Fix device cleanupYishai Hadas1-2/+1 2017-08-04RDMA/uverbs: Prevent leak of reserved fieldLeon Romanovsky1-1/+1 2017-08-04IB/core: Fix race condition in resolving IP to MACParav Pandit1-14/+48