stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Maxim Patlasov <mpatlasov@parallels.com>,
	Miklos Szeredi <mszeredi@suse.cz>,
	Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 60/93] fuse: postpone end_page_writeback() in fuse_writepage_locked()
Date: Fri, 20 Sep 2013 13:08:55 -0700	[thread overview]
Message-ID: <1379707768-1804-61-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1379707768-1804-1-git-send-email-kamal@canonical.com>

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

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

From: Maxim Patlasov <MPatlasov@parallels.com>

commit 4a4ac4eba1010ef9a804569058ab29e3450c0315 upstream.

The patch fixes a race between ftruncate(2), mmap-ed write and write(2):

1) An user makes a page dirty via mmap-ed write.
2) The user performs shrinking truncate(2) intended to purge the page.
3) Before fuse_do_setattr calls truncate_pagecache, the page goes to
   writeback. fuse_writepage_locked fills FUSE_WRITE request and releases
   the original page by end_page_writeback.
4) fuse_do_setattr() completes and successfully returns. Since now, i_mutex
   is free.
5) Ordinary write(2) extends i_size back to cover the page. Note that
   fuse_send_write_pages do wait for fuse writeback, but for another
   page->index.
6) fuse_writepage_locked proceeds by queueing FUSE_WRITE request.
   fuse_send_writepage is supposed to crop inarg->size of the request,
   but it doesn't because i_size has already been extended back.

Moving end_page_writeback to the end of fuse_writepage_locked fixes the
race because now the fact that truncate_pagecache is successfully returned
infers that fuse_writepage_locked has already called end_page_writeback.
And this, in turn, infers that fuse_flush_writepages has already called
fuse_send_writepage, and the latter used valid (shrunk) i_size. write(2)
could not extend it because of i_mutex held by ftruncate(2).

Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/fuse/file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index f3ab824..e9c40f3 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1299,7 +1299,6 @@ static int fuse_writepage_locked(struct page *page)
 
 	inc_bdi_stat(mapping->backing_dev_info, BDI_WRITEBACK);
 	inc_zone_page_state(tmp_page, NR_WRITEBACK_TEMP);
-	end_page_writeback(page);
 
 	spin_lock(&fc->lock);
 	list_add(&req->writepages_entry, &fi->writepages);
@@ -1307,6 +1306,8 @@ static int fuse_writepage_locked(struct page *page)
 	fuse_flush_writepages(inode);
 	spin_unlock(&fc->lock);
 
+	end_page_writeback(page);
+
 	return 0;
 
 err_free:
-- 
1.8.1.2


  parent reply	other threads:[~2013-09-20 20:08 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20 20:07 [ 3.8.y.z extended stable ] Linux 3.8.13.10 stable review Kamal Mostafa
2013-09-20 20:07 ` [PATCH 01/93] Revert "net/core/sock.c: add missing VSOCK string in af_family_*_key_strings" Kamal Mostafa
2013-09-20 20:07 ` [PATCH 02/93] Revert "zram: use zram->lock to protect zram_free_page() in swap free notify path" Kamal Mostafa
2013-09-20 20:07 ` [PATCH 03/93] zram: allow request end to coincide with disksize Kamal Mostafa
2013-09-20 20:07 ` [PATCH 04/93] mtd: nand: fix NAND_BUSWIDTH_AUTO for x16 devices Kamal Mostafa
2013-09-20 20:08 ` [PATCH 05/93] HID: hidraw: correctly deallocate memory on device disconnect Kamal Mostafa
2013-09-20 20:08 ` [PATCH 06/93] xen-gnt: prevent adding duplicate gnt callbacks Kamal Mostafa
2013-09-20 20:08 ` [PATCH 07/93] ath9k: always clear ps filter bit on new assoc Kamal Mostafa
2013-09-20 20:08 ` [PATCH 08/93] ceph: Don't forget the 'up_read(&osdc->map_sem)' if met error Kamal Mostafa
2013-09-20 20:08 ` [PATCH 09/93] libceph: unregister request in __map_request failed and nofail == false Kamal Mostafa
2013-09-20 20:08 ` [PATCH 10/93] usb: config->desc.bLength may not exceed amount of data returned by the device Kamal Mostafa
2013-09-20 20:08 ` [PATCH 11/93] USB: cdc-wdm: fix race between interrupt handler and tasklet Kamal Mostafa
2013-09-20 20:08 ` [PATCH 12/93] powerpc: Handle unaligned ldbrx/stdbrx Kamal Mostafa
2013-09-20 20:08 ` [PATCH 13/93] intel-iommu: Fix leaks in pagetable freeing Kamal Mostafa
2013-09-20 20:08 ` [PATCH 14/93] drivers/misc/hpilo: Correct panic when an AUX iLO is detected Kamal Mostafa
2013-09-20 20:08 ` [PATCH 15/93] USB: handle LPM errors during device suspend correctly Kamal Mostafa
2013-09-20 20:08 ` [PATCH 16/93] xhci-plat: Don't enable legacy PCI interrupts Kamal Mostafa
2013-09-20 20:08 ` [PATCH 17/93] ath9k: fix rx descriptor related race condition Kamal Mostafa
2013-09-20 20:08 ` [PATCH 18/93] ath9k: avoid accessing MRC registers on single-chain devices Kamal Mostafa
2013-09-20 20:08 ` [PATCH 19/93] brcmsmac: Fix WARNING caused by lack of calls to dma_mapping_error() Kamal Mostafa
2013-09-20 20:08 ` [PATCH 20/93] ext4: simplify truncation code in ext4_setattr() Kamal Mostafa
2013-09-20 20:08 ` [PATCH 21/93] ext4: fix lost truncate due to race with writeback Kamal Mostafa
2013-09-20 20:08 ` [PATCH 22/93] ASoC: wm8960: Fix PLL register writes Kamal Mostafa
2013-09-20 20:08 ` [PATCH 23/93] rculist: list_first_or_null_rcu() should use list_entry_rcu() Kamal Mostafa
2013-09-20 20:08 ` [PATCH 24/93] USB: mos7720: use GFP_ATOMIC under spinlock Kamal Mostafa
2013-09-20 20:08 ` [PATCH 25/93] USB: mos7720: fix big-endian control requests Kamal Mostafa
2013-09-20 20:08 ` [PATCH 26/93] arm64: perf: fix group validation when using enable_on_exec Kamal Mostafa
2013-09-20 20:08 ` [PATCH 27/93] arm64: perf: fix ARMv8 EVTYPE_MASK to include NSH bit Kamal Mostafa
2013-09-20 20:08 ` [PATCH 28/93] staging: comedi: dt282x: dt282x_ai_insn_read() always fails Kamal Mostafa
2013-09-20 20:08 ` [PATCH 29/93] usb: ehci-mxc: check for pdata before dereferencing Kamal Mostafa
2013-09-20 20:08 ` [PATCH 30/93] mmc: tmio_mmc_dma: fix PIO fallback on SDHI Kamal Mostafa
2013-09-20 20:08 ` [PATCH 31/93] proc: Restrict mounting the proc filesystem Kamal Mostafa
2013-09-20 20:08 ` [PATCH 32/93] usb: xhci: Disable runtime PM suspend for quirky controllers Kamal Mostafa
2013-09-20 20:08 ` [PATCH 33/93] USB: OHCI: Allow runtime PM without system sleep Kamal Mostafa
2013-09-20 20:08 ` [PATCH 34/93] pinctrl: at91: fix get_pullup/down function return Kamal Mostafa
2013-09-20 20:08 ` [PATCH 35/93] ACPI / EC: Add HP Folio 13 to ec_dmi_table in order to skip DSDT scan Kamal Mostafa
2013-09-20 20:08 ` [PATCH 36/93] ACPI / EC: Add ASUSTEK L4R to quirk list in order to validate ECDT Kamal Mostafa
2013-09-20 20:08 ` [PATCH 37/93] HID: validate HID report id size Kamal Mostafa
2013-09-20 20:08 ` [PATCH 38/93] cpuidle: coupled: abort idle if pokes are pending Kamal Mostafa
2013-09-20 20:08 ` [PATCH 39/93] cpuidle: coupled: disable interrupts after entering safe state Kamal Mostafa
2013-09-20 20:08 ` [PATCH 40/93] cpuidle: coupled: fix race condition between pokes and " Kamal Mostafa
2013-09-20 20:08 ` [PATCH 41/93] of: Fix missing memory initialization on FDT unflattening Kamal Mostafa
2013-09-20 20:08 ` [PATCH 42/93] leds: wm831x-status: Request a REG resource Kamal Mostafa
2013-09-20 20:08 ` [PATCH 43/93] USB: fix build error when CONFIG_PM_SLEEP isn't enabled Kamal Mostafa
2013-09-20 20:08 ` [PATCH 44/93] clk: wm831x: Initialise wm831x pointer on init Kamal Mostafa
2013-09-20 20:08 ` [PATCH 45/93] drm/edid: add quirk for Medion MD30217PG Kamal Mostafa
2013-09-20 20:08 ` [PATCH 46/93] drm/radeon: fix endian bugs in hw i2c atom routines Kamal Mostafa
2013-09-20 20:08 ` [PATCH 47/93] drm/radeon: update line buffer allocation for dce4.1/5 Kamal Mostafa
2013-09-20 20:08 ` [PATCH 48/93] drm/radeon: update line buffer allocation for dce6 Kamal Mostafa
2013-09-20 20:08 ` [PATCH 49/93] drm/radeon: fix LCD record parsing Kamal Mostafa
2013-09-20 20:08 ` [PATCH 50/93] drm/radeon: fix resume on some rs4xx boards (v2) Kamal Mostafa
2013-09-20 20:08 ` [PATCH 51/93] drm/radeon: fix handling of variable sized arrays for router objects Kamal Mostafa
2013-09-20 20:08 ` [PATCH 52/93] radeon kms: fix uninitialised hotplug work usage in r100_irq_process() Kamal Mostafa
2013-09-20 20:08 ` [PATCH 53/93] pidns: Fix hang in zap_pid_ns_processes by sending a potentially extra wakeup Kamal Mostafa
2013-09-20 20:08 ` [PATCH 54/93] x86, smap: Handle csum_partial_copy_*_user() Kamal Mostafa
2013-09-20 20:08 ` [PATCH 55/93] Introduce [compat_]save_altstack_ex() to unbreak x86 SMAP Kamal Mostafa
2013-09-20 20:08 ` [PATCH 56/93] drm: fix DRM_IOCTL_MODE_GETFB handle-leak Kamal Mostafa
2013-09-20 20:08 ` [PATCH 57/93] HID: picolcd: Prevent NULL pointer dereference on _remove() Kamal Mostafa
2013-09-20 20:08 ` [PATCH 58/93] HID: battery: don't do DMA from stack Kamal Mostafa
2013-09-20 20:08 ` [PATCH 59/93] ALSA: hda - hdmi: Fallback to ALSA allocation when selecting CA Kamal Mostafa
2013-09-20 20:08 ` Kamal Mostafa [this message]
2013-09-20 20:08 ` [PATCH 61/93] fuse: invalidate inode attributes on xattr modification Kamal Mostafa
2013-09-20 20:08 ` [PATCH 62/93] [media] media: coda: Fix DT driver data pointer for i.MX27 Kamal Mostafa
2013-09-20 20:08 ` [PATCH 63/93] [media] s5p-g2d: Fix registration failure Kamal Mostafa
2013-09-20 20:08 ` [PATCH 64/93] [media] DocBook: upgrade media_api DocBook version to 4.2 Kamal Mostafa
2013-09-20 20:09 ` [PATCH 65/93] [media] v4l2: added missing mutex.h include to v4l2-ctrls.h Kamal Mostafa
2013-09-20 20:09 ` [PATCH 66/93] [media] hdpvr: fix iteration over uninitialized lists in hdpvr_probe() Kamal Mostafa
2013-09-20 20:09 ` [PATCH 67/93] [media] exynos-gsc: Register v4l2 device Kamal Mostafa
2013-09-20 20:09 ` [PATCH 68/93] fuse: readdir: check for slash in names Kamal Mostafa
2013-09-20 20:09 ` [PATCH 69/93] MIPS: ath79: Fix ar933x watchdog clock Kamal Mostafa
2013-09-20 20:09 ` [PATCH 70/93] libceph: use pg_num_mask instead of pgp_num_mask for pg.seed calc Kamal Mostafa
2013-09-20 20:09 ` [PATCH 71/93] HID: pantherlord: validate output report details Kamal Mostafa
2013-09-20 20:09 ` [PATCH 72/93] HID: ntrig: validate feature " Kamal Mostafa
2013-09-20 20:09 ` [PATCH 73/93] HID: sensor-hub: " Kamal Mostafa
2013-09-20 20:09 ` [PATCH 74/93] HID: picolcd_core: validate output " Kamal Mostafa
2013-09-20 20:09 ` [PATCH 75/93] HID: check for NULL field when setting values Kamal Mostafa
2013-09-20 20:09 ` [PATCH 76/93] ARM: PCI: versatile: Fix map_irq function to match hardware Kamal Mostafa
2013-09-20 20:09 ` [PATCH 77/93] ARM: PCI: versatile: Fix PCI I/O Kamal Mostafa
2013-09-20 20:09 ` [PATCH 78/93] ARM: PCI: versatile: Fix SMAP register offsets Kamal Mostafa
2013-09-20 20:09 ` [PATCH 79/93] net: mvneta: properly disable HW PHY polling and ensure adjust_link() works Kamal Mostafa
2013-09-20 20:09 ` [PATCH 80/93] drm/i915: try not to lose backlight CBLV precision Kamal Mostafa
2013-09-20 20:09 ` [PATCH 81/93] crypto: api - Fix race condition in larval lookup Kamal Mostafa
2013-09-20 20:09 ` [PATCH 82/93] cifs: ensure that srv_mutex is held when dealing with ssocket pointer Kamal Mostafa
2013-09-20 20:09 ` [PATCH 83/93] CIFS: Fix a memory leak when a lease break comes Kamal Mostafa
2013-09-20 20:09 ` [PATCH 84/93] ALSA: hda - Add Toshiba Satellite C870 to MSI blacklist Kamal Mostafa
2013-09-20 20:09 ` [PATCH 85/93] lguest: Point to the right directory for the lguest launcher Kamal Mostafa
2013-09-20 20:09 ` [PATCH 86/93] powerpc: Default arch idle could cede processor on pseries Kamal Mostafa
2013-09-20 20:09 ` [PATCH 87/93] ASoC: mc13783: add spi errata fix Kamal Mostafa
2013-09-20 20:09 ` [PATCH 88/93] [SCSI] sd: Fix potential out-of-bounds access Kamal Mostafa
2013-09-20 20:09 ` [PATCH 89/93] pidns: fix vfork() after unshare(CLONE_NEWPID) Kamal Mostafa
2013-09-20 20:09 ` [PATCH 90/93] ocfs2: fix the end cluster offset of FIEMAP Kamal Mostafa
2013-09-20 20:09 ` [PATCH 91/93] mm/huge_memory.c: fix potential NULL pointer dereference Kamal Mostafa
2013-09-20 20:09 ` [PATCH 92/93] mm: fix aio performance regression for database caused by THP Kamal Mostafa
2013-09-20 20:09 ` [PATCH 93/93] memcg: fix multiple large threshold notifications Kamal Mostafa

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=1379707768-1804-61-git-send-email-kamal@canonical.com \
    --to=kamal@canonical.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatlasov@parallels.com \
    --cc=mszeredi@suse.cz \
    --cc=stable@vger.kernel.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).