All of lore.kernel.org
 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, Jan Kara <jack@suse.cz>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Jinshan Xiong <jinshan.xiong@intel.com>,
	Matthew Wilcox <willy@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Sasha Levin <alexander.levin@verizon.com>
Subject: [PATCH 3.18 16/26] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers
Date: Thu,  7 Dec 2017 13:48:29 +0100	[thread overview]
Message-ID: <20171207124656.767281264@linuxfoundation.org> (raw)
In-Reply-To: <20171207124654.669583826@linuxfoundation.org>

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

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

From: Jan Kara <jack@suse.cz>


[ Upstream commit 0911d0041c22922228ca52a977d7b0b0159fee4b ]

Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return
code (GFS2 or Lustre can definitely do this).  However VM_FAULT_RETRY
from ->page_mkwrite is completely unhandled by the mm code and results
in locking and writeably mapping the page which definitely is not what
the caller wanted.

Fix Lustre and block_page_mkwrite_ret() used by other filesystems
(notably GFS2) to return VM_FAULT_NOPAGE instead which results in
bailing out from the fault code, the CPU then retries the access, and we
fault again effectively doing what the handler wanted.

Link: http://lkml.kernel.org/r/20170203150729.15863-1-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/staging/lustre/lustre/llite/llite_mmap.c |    4 +---
 include/linux/buffer_head.h                      |    4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -407,15 +407,13 @@ static int ll_page_mkwrite(struct vm_are
 		result = VM_FAULT_LOCKED;
 		break;
 	case -ENODATA:
+	case -EAGAIN:
 	case -EFAULT:
 		result = VM_FAULT_NOPAGE;
 		break;
 	case -ENOMEM:
 		result = VM_FAULT_OOM;
 		break;
-	case -EAGAIN:
-		result = VM_FAULT_RETRY;
-		break;
 	default:
 		result = VM_FAULT_SIGBUS;
 		break;
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -236,12 +236,10 @@ static inline int block_page_mkwrite_ret
 {
 	if (err == 0)
 		return VM_FAULT_LOCKED;
-	if (err == -EFAULT)
+	if (err == -EFAULT || err == -EAGAIN)
 		return VM_FAULT_NOPAGE;
 	if (err == -ENOMEM)
 		return VM_FAULT_OOM;
-	if (err == -EAGAIN)
-		return VM_FAULT_RETRY;
 	/* -ENOSPC, -EDQUOT, -EIO ... */
 	return VM_FAULT_SIGBUS;
 }

  parent reply	other threads:[~2017-12-07 12:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 12:48 [PATCH 3.18 00/26] 3.18.87-stable review Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 01/26] bcache: only permit to recovery read error when cache device is clean Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 02/26] bcache: recover data from backing when data " Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 03/26] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl() Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 04/26] spi: sh-msiof: Fix DMA transfer size check Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 05/26] EDAC, sb_edac: Fix missing break in switch Greg Kroah-Hartman
2017-12-07 12:48   ` [3.18,05/26] " Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 06/26] sysrq : fix Show Regs call trace on ARM Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 07/26] usbip: tools: Install all headers needed for libusbip development Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 08/26] perf test attr: Fix ignored test case result Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 09/26] ARM: OMAP1: DMA: Correct the number of logical channels Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 10/26] vti6: fix device register to report IFLA_INFO_KIND Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 11/26] net/appletalk: Fix kernel memory disclosure Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 12/26] nfs: Dont take a reference on fl->fl_file for LOCK operation Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 13/26] NFSv4: Fix client recovery when server reboots multiple times Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 14/26] net: sctp: fix array overrun read on sctp_timer_tbl Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 15/26] tipc: fix cleanup at module unload Greg Kroah-Hartman
2017-12-07 12:48 ` Greg Kroah-Hartman [this message]
2017-12-07 12:48 ` [PATCH 3.18 17/26] net: fec: fix multicast filtering hardware setup Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 18/26] ima: fix hash algorithm initialization Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 19/26] uas: Always apply US_FL_NO_ATA_1X quirk to Seagate devices Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 20/26] usb: quirks: Add no-lpm quirk for KY-688 USB 3.1 Type-C Hub Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 21/26] serial: 8250_pci: Add Amazon PCI serial device ID Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 22/26] usb: hub: Cycle HUB power when initialization fails Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 23/26] USB: Increase usbfs transfer limit Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 24/26] USB: devio: Prevent integer overflow in proc_do_submiturb() Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 25/26] USB: usbfs: Filter flags passed in from user space Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 26/26] usb: host: fix incorrect updating of offset Greg Kroah-Hartman
2017-12-07 20:54 ` [PATCH 3.18 00/26] 3.18.87-stable review Guenter Roeck
2017-12-08  0:06 ` Shuah Khan

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=20171207124656.767281264@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.levin@verizon.com \
    --cc=jack@suse.cz \
    --cc=jinshan.xiong@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.