Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1999593imu; Fri, 14 Dec 2018 04:17:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/UwzNrbDhN3CnD64j0mQV63Xp2PAtM2iAxzh5c00SY/tBFyaBmHQyLugA15owh9QcYjFIFI X-Received: by 2002:a17:902:7c05:: with SMTP id x5mr2584401pll.273.1544789847997; Fri, 14 Dec 2018 04:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789847; cv=none; d=google.com; s=arc-20160816; b=TOO/4RVKYvjZC36LNpoAWc3MGG8+doEPosah6rYN99UWLQkOCIB4XTgManyAg/iUmT nvu2tn2FdUtZvguVBJ/Z1J5WLnFMeL/dhU3aa+73pxc0CJdew4ug8bYkSMScS5BfmbJq MkN2rKbx2A4j+45DhV91bQCg1aGptAPBXD7KSTqT+1WjP+q064pSgEDZ5+B1D9xlH8HX tYblinqXfVPegtGZBH4dpBCU+ZIKAdrc7pub5bz171PMcOaFL6bnLuzMIR3ve8QxnYIK g4NzmdltKSdp96FnTAOlZ4johLn06tI+UNbnmABJS9F1hLKSZKdB2YCVzGFsxWHKpNpr zfcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AD3J+D/Wm/+Knf66foNcPOXpEiWtQv8NRb9/AvUe59k=; b=xOu/ygFrBHC7Z03s7pVLjSQEjYHfXvqH7paXlg1P+ASbk+AGmbus+jCh6v2YR8gZHD ZNLQn9QaOmo54XwAxQKuWf6aI4GDzhtJApxZLYyQRXTMVnSOdiUM3/1qTOJnMK46EIZ/ 7bIoszTn7vVrtnauz+Y/wEZyvAuzMJ7aOxsbpKI9YwqiHN6ZejmASJaMippk3ZZUlh2V LQnKk/7MktfENjde09FsyeTzwpF0POx7K1LK8B2Rh81WHyJSNEkKjR/fa5e4amgi9oBR +zT7BnoC8RuJgPZU7pOOIuBvHFZjHAV5R5EYUTvaDPzkbAMBOQk0YdelyLWx/WcQYy8X 5bvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="yd0qt94/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18si4013519pgg.522.2018.12.14.04.17.13; Fri, 14 Dec 2018 04:17:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="yd0qt94/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732749AbeLNMQW (ORCPT + 99 others); Fri, 14 Dec 2018 07:16:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:36552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732139AbeLNMQV (ORCPT ); Fri, 14 Dec 2018 07:16:21 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5800D2148E; Fri, 14 Dec 2018 12:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789780; bh=jqZhj4tmnKukO3pMtsvGyJLHZ0tmxPbj0vUuR/MIURo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yd0qt94/l1Jg41WcnPJnRVduhSlrUba+mluQLgYstJ0HUKHOWZknRPAjqgiSF+2MY hIcwBtYMcAo+dluI3guxX0AqntmW/cwj2g0ga9JUN6DAk2t+3vvubeH82H4Ld+1rs3 aOAs/flC1ax41ij8DdLtzhMgGPQyDjX1DpZyCSAc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Stoakes , Jan Kara , Michal Hocko , Linus Torvalds , Ben Hutchings Subject: [PATCH 4.4 74/88] mm: remove write/force parameters from __get_user_pages_locked() Date: Fri, 14 Dec 2018 13:00:48 +0100 Message-Id: <20181214115708.318156906@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115702.151309521@linuxfoundation.org> References: <20181214115702.151309521@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lorenzo Stoakes commit 859110d7497cdd0e6b21010d6f777049d676382c upstream. This removes the redundant 'write' and 'force' parameters from __get_user_pages_locked() 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 Reviewed-by: Jan Kara Acked-by: Michal Hocko Signed-off-by: Linus Torvalds [bwh: Backported to 4.4: - Drop change in get_user_pages_remote() - Adjust context] Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- mm/gup.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) --- a/mm/gup.c +++ b/mm/gup.c @@ -627,7 +627,6 @@ static __always_inline long __get_user_p struct mm_struct *mm, unsigned long start, unsigned long nr_pages, - int write, int force, struct page **pages, struct vm_area_struct **vmas, int *locked, bool notify_drop, @@ -645,10 +644,6 @@ static __always_inline long __get_user_p if (pages) flags |= FOLL_GET; - if (write) - flags |= FOLL_WRITE; - if (force) - flags |= FOLL_FORCE; pages_done = 0; lock_dropped = false; @@ -745,8 +740,15 @@ long get_user_pages_locked(struct task_s int write, int force, struct page **pages, int *locked) { - return __get_user_pages_locked(tsk, mm, start, nr_pages, write, force, - pages, NULL, locked, true, FOLL_TOUCH); + unsigned int flags = FOLL_TOUCH; + + if (write) + flags |= FOLL_WRITE; + if (force) + flags |= FOLL_FORCE; + + return __get_user_pages_locked(tsk, mm, start, nr_pages, + pages, NULL, locked, true, flags); } EXPORT_SYMBOL(get_user_pages_locked); @@ -767,9 +769,15 @@ __always_inline long __get_user_pages_un { 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, write, force, - pages, NULL, &locked, false, gup_flags); + ret = __get_user_pages_locked(tsk, mm, start, nr_pages, pages, NULL, + &locked, false, gup_flags); if (locked) up_read(&mm->mmap_sem); return ret; @@ -861,8 +869,15 @@ long get_user_pages(struct task_struct * unsigned long start, unsigned long nr_pages, int write, int force, struct page **pages, struct vm_area_struct **vmas) { - return __get_user_pages_locked(tsk, mm, start, nr_pages, write, force, - pages, vmas, NULL, false, FOLL_TOUCH); + unsigned int flags = FOLL_TOUCH; + + if (write) + flags |= FOLL_WRITE; + if (force) + flags |= FOLL_FORCE; + + return __get_user_pages_locked(tsk, mm, start, nr_pages, + pages, vmas, NULL, false, flags); } EXPORT_SYMBOL(get_user_pages);