linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Lorenzo Stoakes <lstoakes@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>, Jan Kara <jack@suse.cz>,
	Michal Hocko <mhocko@suse.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ben Hutchings <ben.hutchings@codethink.co.uk>
Subject: [PATCH 4.4 75/88] mm: remove write/force parameters from __get_user_pages_unlocked()
Date: Fri, 14 Dec 2018 13:00:49 +0100	[thread overview]
Message-ID: <20181214115708.360510296@linuxfoundation.org> (raw)
In-Reply-To: <20181214115702.151309521@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Lorenzo Stoakes <lstoakes@gmail.com>

commit d4944b0ecec0af882483fe44b66729316e575208 upstream.

This removes the redundant 'write' and 'force' parameters from
__get_user_pages_unlocked() to make the use of FOLL_FORCE explicit in
callers as use of this flag can result in surprising behaviour (and
hence bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[bwh: Backported to 4.4:
 - Defer changes in process_vm_rw_single_vec() and async_pf_execute() since
   they use get_user_pages_unlocked() here
 - Adjust context]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/mm.h  |    3 +--
 mm/gup.c            |   19 ++++++++++---------
 mm/nommu.c          |   14 ++++++++++----
 virt/kvm/kvm_main.c |   11 ++++++++---
 4 files changed, 29 insertions(+), 18 deletions(-)

--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1207,8 +1207,7 @@ long get_user_pages_locked(struct task_s
 		    int *locked);
 long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
 			       unsigned long start, unsigned long nr_pages,
-			       int write, int force, struct page **pages,
-			       unsigned int gup_flags);
+			       struct page **pages, unsigned int gup_flags);
 long get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
 		    unsigned long start, unsigned long nr_pages,
 		    int write, int force, struct page **pages);
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -764,17 +764,11 @@ EXPORT_SYMBOL(get_user_pages_locked);
  */
 __always_inline long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
 					       unsigned long start, unsigned long nr_pages,
-					       int write, int force, struct page **pages,
-					       unsigned int gup_flags)
+					       struct page **pages, unsigned int gup_flags)
 {
 	long ret;
 	int locked = 1;
 
-	if (write)
-		gup_flags |= FOLL_WRITE;
-	if (force)
-		gup_flags |= FOLL_FORCE;
-
 	down_read(&mm->mmap_sem);
 	ret = __get_user_pages_locked(tsk, mm, start, nr_pages, pages, NULL,
 				      &locked, false, gup_flags);
@@ -805,8 +799,15 @@ long get_user_pages_unlocked(struct task
 			     unsigned long start, unsigned long nr_pages,
 			     int write, int force, struct page **pages)
 {
-	return __get_user_pages_unlocked(tsk, mm, start, nr_pages, write,
-					 force, pages, FOLL_TOUCH);
+	unsigned int flags = FOLL_TOUCH;
+
+	if (write)
+		flags |= FOLL_WRITE;
+	if (force)
+		flags |= FOLL_FORCE;
+
+	return __get_user_pages_unlocked(tsk, mm, start, nr_pages,
+					 pages, flags);
 }
 EXPORT_SYMBOL(get_user_pages_unlocked);
 
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -211,8 +211,7 @@ EXPORT_SYMBOL(get_user_pages_locked);
 
 long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
 			       unsigned long start, unsigned long nr_pages,
-			       int write, int force, struct page **pages,
-			       unsigned int gup_flags)
+			       struct page **pages, unsigned int gup_flags)
 {
 	long ret;
 	down_read(&mm->mmap_sem);
@@ -227,8 +226,15 @@ long get_user_pages_unlocked(struct task
 			     unsigned long start, unsigned long nr_pages,
 			     int write, int force, struct page **pages)
 {
-	return __get_user_pages_unlocked(tsk, mm, start, nr_pages, write,
-					 force, pages, 0);
+	unsigned int flags = 0;
+
+	if (write)
+		flags |= FOLL_WRITE;
+	if (force)
+		flags |= FOLL_FORCE;
+
+	return __get_user_pages_unlocked(tsk, mm, start, nr_pages,
+					 pages, flags);
 }
 EXPORT_SYMBOL(get_user_pages_unlocked);
 
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1352,10 +1352,15 @@ static int hva_to_pfn_slow(unsigned long
 		npages = get_user_page_nowait(current, current->mm,
 					      addr, write_fault, page);
 		up_read(&current->mm->mmap_sem);
-	} else
+	} else {
+		unsigned int flags = FOLL_TOUCH | FOLL_HWPOISON;
+
+		if (write_fault)
+			flags |= FOLL_WRITE;
+
 		npages = __get_user_pages_unlocked(current, current->mm, addr, 1,
-						   write_fault, 0, page,
-						   FOLL_TOUCH|FOLL_HWPOISON);
+						   page, flags);
+	}
 	if (npages != 1)
 		return npages;
 



  parent reply	other threads:[~2018-12-14 12:16 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 11:59 [PATCH 4.4 00/88] 4.4.168-stable review Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 01/88] ipv6: Check available headroom in ip6_xmit() even without options Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 02/88] net: 8139cp: fix a BUG triggered by changing mtu with network traffic Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 03/88] net: phy: dont allow __set_phy_supported to add unsupported modes Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 04/88] net: Prevent invalid access to skb->prev in __qdisc_drop_all Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 05/88] rtnetlink: ndo_dflt_fdb_dump() only work for ARPHRD_ETHER devices Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 06/88] tcp: fix NULL ref in tail loss probe Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 07/88] tun: forbid iface creation with rtnl ops Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 08/88] neighbour: Avoid writing before skb->head in neigh_hh_output() Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 09/88] ipv4: ipv6: netfilter: Adjust the frag mem limit when truesize changes Greg Kroah-Hartman
2018-12-16  9:57   ` jwiesner
2018-12-14 11:59 ` [PATCH 4.4 10/88] ARM: OMAP2+: prm44xx: Fix section annotation on omap44xx_prm_enable_io_wakeup Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 11/88] ARM: OMAP1: ams-delta: Fix possible use of uninitialized field Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 12/88] sysv: return err instead of 0 in __sysv_write_inode Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 13/88] s390/cpum_cf: Reject request for sampling in event initialization Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 14/88] hwmon: (ina2xx) Fix current value calculation Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 15/88] ASoC: dapm: Recalculate audio map forcely when card instantiated Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 16/88] hwmon: (w83795) temp4_type has writable permission Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 17/88] Btrfs: send, fix infinite loop due to directory rename dependencies Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 18/88] ASoC: omap-mcpdm: Add pm_qos handling to avoid under/overruns with CPU_IDLE Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 19/88] ASoC: omap-dmic: Add pm_qos handling to avoid overruns " Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 20/88] exportfs: do not read dentry after free Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 21/88] bpf: fix check of allowed specifiers in bpf_trace_printk Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 22/88] USB: omap_udc: use devm_request_irq() Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 23/88] USB: omap_udc: fix crashes on probe error and module removal Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 24/88] USB: omap_udc: fix omap_udc_start() on 15xx machines Greg Kroah-Hartman
2018-12-14 11:59 ` [PATCH 4.4 25/88] USB: omap_udc: fix USB gadget functionality on Palm Tungsten E Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 26/88] KVM: x86: fix empty-body warnings Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 27/88] net: thunderx: fix NULL pointer dereference in nic_remove Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 28/88] ixgbe: recognize 1000BaseLX SFP modules as 1Gbps Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 29/88] net: hisilicon: remove unexpected free_netdev Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 30/88] drm/ast: fixed reading monitor EDID not stable issue Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 31/88] xen: xlate_mmu: add missing header to fix W=1 warning Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 32/88] fscache: fix race between enablement and dropping of object Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 33/88] fscache, cachefiles: remove redundant variable cache Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 34/88] ocfs2: fix deadlock caused by ocfs2_defrag_extent() Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 35/88] hfs: do not free node before using Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 36/88] hfsplus: " Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 37/88] debugobjects: avoid recursive calls with kmemleak Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 38/88] ocfs2: fix potential use after free Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 39/88] pstore: Convert console write to use ->write_buf Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 40/88] ALSA: pcm: remove SNDRV_PCM_IOCTL1_INFO internal command Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 41/88] KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 42/88] KVM: nVMX: mark vmcs12 pages dirty on L2 exit Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 43/88] KVM: nVMX: Eliminate vmcs02 pool Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 44/88] KVM: VMX: introduce alloc_loaded_vmcs Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 45/88] KVM: VMX: make MSR bitmaps per-VCPU Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 46/88] KVM/x86: Add IBPB support Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 47/88] KVM/VMX: Emulate MSR_IA32_ARCH_CAPABILITIES Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 48/88] KVM/VMX: Allow direct access to MSR_IA32_SPEC_CTRL Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 49/88] KVM/SVM: " Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 50/88] KVM/x86: Remove indirect MSR op calls from SPEC_CTRL Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 51/88] x86: reorganize SMAP handling in user space accesses Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 52/88] x86: fix SMAP in 32-bit environments Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 53/88] x86: Introduce __uaccess_begin_nospec() and uaccess_try_nospec Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 54/88] x86/usercopy: Replace open coded stac/clac with __uaccess_{begin, end} Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 55/88] x86/uaccess: Use __uaccess_begin_nospec() and uaccess_try_nospec Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 56/88] x86/bugs, KVM: Support the combination of guest and host IBRS Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 57/88] x86/KVM/VMX: Expose SPEC_CTRL Bit(2) to the guest Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 58/88] KVM: SVM: Move spec control call after restore of GS Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 59/88] x86/bugs, KVM: Extend speculation control for VIRT_SPEC_CTRL Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 60/88] x86/speculation: Use synthetic bits for IBRS/IBPB/STIBP Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 61/88] KVM: SVM: Implement VIRT_SPEC_CTRL support for SSBD Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 62/88] bpf: support 8-byte metafield access Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 63/88] bpf/verifier: Add spi variable to check_stack_write() Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 64/88] bpf/verifier: Pass instruction index to check_mem_access() and check_xadd() Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 65/88] bpf: Prevent memory disambiguation attack Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 66/88] wil6210: missing length check in wmi_set_ie Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 67/88] posix-timers: Sanitize overrun handling Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 68/88] mm/hugetlb.c: dont call region_abort if region_chg fails Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 69/88] hugetlbfs: fix offset overflow in hugetlbfs mmap Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 70/88] hugetlbfs: check for pgoff value overflow Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 71/88] hugetlbfs: fix bug in pgoff overflow checking Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 72/88] swiotlb: clean up reporting Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 73/88] sr: pass down correctly sized SCSI sense buffer Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 74/88] mm: remove write/force parameters from __get_user_pages_locked() Greg Kroah-Hartman
2018-12-14 12:00 ` Greg Kroah-Hartman [this message]
2018-12-14 12:00 ` [PATCH 4.4 76/88] mm: replace get_user_pages_unlocked() write/force parameters with gup_flags Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 77/88] mm: replace get_user_pages_locked() " Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 78/88] mm: replace get_vaddr_frames() " Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 79/88] mm: replace get_user_pages() " Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 80/88] mm: replace __access_remote_vm() write parameter " Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 81/88] mm: replace access_remote_vm() " Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 82/88] proc: dont use FOLL_FORCE for reading cmdline and environment Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 83/88] proc: do not access cmdline nor environ from file-backed areas Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 84/88] media: dvb-frontends: fix i2c access helpers for KASAN Greg Kroah-Hartman
2018-12-14 12:00 ` [PATCH 4.4 85/88] matroxfb: fix size of memcpy Greg Kroah-Hartman
2018-12-14 12:01 ` [PATCH 4.4 86/88] staging: speakup: Replace strncpy with memcpy Greg Kroah-Hartman
2018-12-14 12:01 ` [PATCH 4.4 87/88] rocker: fix rocker_tlv_put_* functions for KASAN Greg Kroah-Hartman
2018-12-14 12:01 ` [PATCH 4.4 88/88] selftests: Move networking/timestamping from Documentation Greg Kroah-Hartman
2018-12-14 15:39 ` [PATCH 4.4 00/88] 4.4.168-stable review Guenter Roeck
2018-12-14 17:33 ` kernelci.org bot
2018-12-14 20:12 ` shuah
2018-12-15  2:10 ` Guenter Roeck
2018-12-15  8:07   ` Greg Kroah-Hartman
2018-12-15 15:45     ` Guenter Roeck
2018-12-16 23:58       ` Ben Hutchings
2018-12-17  9:05         ` Greg Kroah-Hartman
2018-12-17 13:46           ` Guenter Roeck
2018-12-17 19:08             ` Greg Kroah-Hartman
2018-12-17 20:12               ` Guenter Roeck
2018-12-17 20:52                 ` Greg Kroah-Hartman
2018-12-15 11:15 ` Harsh Shandilya
2018-12-17  9:06   ` Greg Kroah-Hartman
2018-12-15 16:44 ` Dan Rue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181214115708.360510296@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=ben.hutchings@codethink.co.uk \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lstoakes@gmail.com \
    --cc=mhocko@suse.com \
    --cc=pbonzini@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).