login
Header Space

 
 

Re: [patch 04/26] writeback: dont propagate AOP_WRITEPAGE_ACTIVATE

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Greg Kroah-Hartman <gregkh@...>
Cc: <linux-kernel@...>, <stable@...>, <torvalds@...>, Justin Forbes <jmforbes@...>, Zwane Mwaikambo <zwane@...>, Theodore Ts'o <tytso@...>, Randy Dunlap <rdunlap@...>, Dave Jones <davej@...>, Chuck Wolber <chuckw@...>, Chris Wedgwood <reviews@...>, Michael Krufky <mkrufky@...>, Chuck Ebbert <cebbert@...>, Domenico Andreoli <cavokz@...>, <akpm@...>, <alan@...>, Erez Zadok <ezk@...>, Pekka Enberg <penberg@...>
Date: Monday, November 19, 2007 - 3:04 pm

On Mon, 19 Nov 2007, Greg Kroah-Hartman wrote:

It's fine by me that this should go into 2.6.22-stable, but then please
also put in this related patch from 2.6.23-stable: it's arguable whether
either are strictly needed (they were originally provoked by unionfs, in
Ubuntu but not mainline), but more helpful to include than exclude them.

Thanks,
Hugh


Subject: [patch 12/13] fix tmpfs BUG and AOP_WRITEPAGE_ACTIVATE

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

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

From: Hugh Dickins <hugh@veritas.com>

patch 487e9bf25cbae11b131d6a14bdbb3a6a77380837 in mainline.

It's possible to provoke unionfs (not yet in mainline, though in mm and
some distros) to hit shmem_writepage's BUG_ON(page_mapped(page)).  I expect
it's possible to provoke the 2.6.23 ecryptfs in the same way (but the
2.6.24 ecryptfs no longer calls lower level's ->writepage).

This came to light with the recent find that AOP_WRITEPAGE_ACTIVATE could
leak from tmpfs via write_cache_pages and unionfs to userspace.  There's
already a fix (e423003028183df54f039dfda8b58c49e78c89d7 - writeback: don't
propagate AOP_WRITEPAGE_ACTIVATE) in the tree for that, and it's okay so
far as it goes; but insufficient because it doesn't address the underlying
issue, that shmem_writepage expects to be called only by vmscan (relying on
backing_dev_info capabilities to prevent the normal writeback path from
ever approaching it).

That's an increasingly fragile assumption, and ramdisk_writepage (the other
source of AOP_WRITEPAGE_ACTIVATEs) is already careful to check
wbc->for_reclaim before returning it.  Make the same check in
shmem_writepage, thereby sidestepping the page_mapped BUG also.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Cc: Erez Zadok <ezk@cs.sunysb.edu>
Reviewed-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 mm/shmem.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -916,6 +916,21 @@ static int shmem_writepage(struct page *
 	struct inode *inode;
 
 	BUG_ON(!PageLocked(page));
+	/*
+	 * shmem_backing_dev_info's capabilities prevent regular writeback or
+	 * sync from ever calling shmem_writepage; but a stacking filesystem
+	 * may use the ->writepage of its underlying filesystem, in which case
+	 * we want to do nothing when that underlying filesystem is tmpfs
+	 * (writing out to swap is useful as a response to memory pressure, but
+	 * of no use to stabilize the data) - just redirty the page, unlock it
+	 * and claim success in this case.  AOP_WRITEPAGE_ACTIVATE, and the
+	 * page_mapped check below, must be avoided unless we're in reclaim.
+	 */
+	if (!wbc->for_reclaim) {
+		set_page_dirty(page);
+		unlock_page(page);
+		return 0;
+	}
 	BUG_ON(page_mapped(page));
 
 	mapping = page->mapping;
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/26] 2.6.22-stable review, Greg Kroah-Hartman, (Mon Nov 19, 2:17 pm)
Re: [patch 00/26] 2.6.22-stable review, Greg Kroah-Hartman, (Mon Nov 19, 2:22 pm)
[patch 26/26] i2c/eeprom: Recognize VGN as a valid Sony Vaio..., Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 25/26] i2c/eeprom: Hide Sony Vaio serial numbers, Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 23/26] ocfs2: fix write() performance regression, Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 15/26] forcedeth msi bugfix, Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 24/26] i2c-pasemi: Fix NACK detection, Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 22/26] ide: fix serverworks.c UDMA regression, Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 21/26] i4l: fix random freezes with AVM B1 drivers, Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 18/26] USB: usbserial - fix potential deadlock betwee..., Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 20/26] i4l: Fix random hard freeze with AVM c4 card, Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 19/26] USB: mutual exclusion for EHCI init and port r..., Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 17/26] USB: kobil_sct: trivial backport to fix libct, Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 16/26] hptiop: avoid buffer overflow when returning s..., Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 13/26] ALSA: hdsp - Fix zero division, Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 14/26] ALSA: hda-codec - Add array terminator for dmi..., Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 12/26] Fix crypto_alloc_comp() error checking., Greg Kroah-Hartman, (Mon Nov 19, 2:19 pm)
[patch 11/26] Fix endianness bug in U32 classifier., Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
[patch 10/26] Fix error returns in sys_socketpair(), Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
[patch 08/26] Fix TEQL oops., Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
[patch 06/26] NETFILTER: nf_conntrack_tcp: fix connection re..., Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
[patch 05/26] fix param_sysfs_builtin name length check, Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
[patch 07/26] fix the softlockup watchdog to actually work, Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
[patch 09/26] Fix netlink timeouts., Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
[patch 03/26] x86: fix TSC clock source calibration error, Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
[patch 04/26] writeback: dont propagate AOP_WRITEPAGE_ACTIVATE, Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
Re: [patch 04/26] writeback: dont propagate AOP_WRITEPAGE_AC..., Hugh Dickins, (Mon Nov 19, 3:04 pm)
[patch 01/26] SLUB: Fix memory leak by not reusing cpu_slab, Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
[patch 02/26] Fix compat futex hangs., Greg Kroah-Hartman, (Mon Nov 19, 2:18 pm)
speck-geostationary