linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Dave Chinner <dchinner@redhat.com>,
	Dave Chinner <david@fromorbit.com>, Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 49/56] xfs: xfs_iflush_cluster fails to abort on error
Date: Wed, 15 Jun 2016 09:31:13 +0200	[thread overview]
Message-ID: <90222356784cae9dd20211c9af03ebd81091ddd0.1465975780.git.jslaby@suse.cz> (raw)
In-Reply-To: <352d108e14e126b7dfb5fbecde3dc78be62a5ce5.1465975780.git.jslaby@suse.cz>
In-Reply-To: <cover.1465975780.git.jslaby@suse.cz>

From: Dave Chinner <dchinner@redhat.com>

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

===============

commit b1438f477934f5a4d5a44df26f3079a7575d5946 upstream.

When a failure due to an inode buffer occurs, the error handling
fails to abort the inode writeback correctly. This can result in the
inode being reclaimed whilst still in the AIL, leading to
use-after-free situations as well as filesystems that cannot be
unmounted as the inode log items left in the AIL never get removed.

Fix this by ensuring fatal errors from xfs_imap_to_bp() result in
the inode flush being aborted correctly.

[js] 3.12 needs EAGAIN, not -EAGAIN

Reported-by: Shyam Kaushik <shyam@zadarastorage.com>
Diagnosed-by: Shyam Kaushik <shyam@zadarastorage.com>
Tested-by: Shyam Kaushik <shyam@zadarastorage.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/xfs/xfs_inode.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index e3606f26f82d..771f5359799c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3022,7 +3022,7 @@ xfs_iflush(
 	struct xfs_buf		**bpp)
 {
 	struct xfs_mount	*mp = ip->i_mount;
-	struct xfs_buf		*bp;
+	struct xfs_buf		*bp = NULL;
 	struct xfs_dinode	*dip;
 	int			error;
 
@@ -3064,14 +3064,22 @@ xfs_iflush(
 	}
 
 	/*
-	 * Get the buffer containing the on-disk inode.
+	 * Get the buffer containing the on-disk inode. We are doing a try-lock
+	 * operation here, so we may get  an EAGAIN error. In that case, we
+	 * simply want to return with the inode still dirty.
+	 *
+	 * If we get any other error, we effectively have a corruption situation
+	 * and we cannot flush the inode, so we treat it the same as failing
+	 * xfs_iflush_int().
 	 */
 	error = xfs_imap_to_bp(mp, NULL, &ip->i_imap, &dip, &bp, XBF_TRYLOCK,
 			       0);
-	if (error || !bp) {
+	if (error == EAGAIN) {
 		xfs_ifunlock(ip);
 		return error;
 	}
+	if (error)
+		goto corrupt_out;
 
 	/*
 	 * First flush out the inode that xfs_iflush was called with.
@@ -3099,7 +3107,8 @@ xfs_iflush(
 	return 0;
 
 corrupt_out:
-	xfs_buf_relse(bp);
+	if (bp)
+		xfs_buf_relse(bp);
 	xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
 cluster_corrupt_out:
 	error = XFS_ERROR(EFSCORRUPTED);
-- 
2.9.0

  parent reply	other threads:[~2016-06-15  7:33 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  7:30 [PATCH 3.12 00/56] 3.12.61-stable review Jiri Slaby
2016-06-15  7:29 ` [PATCH 3.12 01/56] NFS: Don't attempt to decode missing directory entries Jiri Slaby
2016-06-15  7:29 ` [PATCH 3.12 02/56] IB/security: Restrict use of the write() interface Jiri Slaby
2016-06-15  7:29 ` [PATCH 3.12 03/56] HID: usbhid: quirks for Corsair RGB keyboard & mice (K70R, K95RGB, M65RGB, K70RGB, K65RGB) Jiri Slaby
2016-06-15  7:29 ` [PATCH 3.12 04/56] HID: Fix boot delay for Creative SB Omni Surround 5.1 with quirk Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 05/56] HID: microsoft: Add Surface Power Cover Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 06/56] HID: microsoft: Add Surface 3 type cover Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 07/56] HID: microsoft: add support for 3 more devices Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 08/56] HID: Add new Microsoft Type Cover 3 product ID Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 09/56] HID: microsoft: Add ID for MS Wireless Comfort Keyboard Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 10/56] HID: chicony: Add support for Acer Aspire Switch 12 Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 11/56] HID: sjoy: support Super Joy Box 4 Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 12/56] HID: wiimote: Fix wiimote mp scale linearization Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 13/56] HID: usbhid: enable NO_INIT_REPORTS quirk for Semico USB Keykoard2 Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 14/56] ARC: use ASL assembler mnemonic Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 15/56] remove directory incorrectly tries to set delete on close on non-empty directories Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 16/56] fs/cifs: correctly to anonymous authentication via NTLMSSP Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 17/56] ring-buffer: Use long for nr_pages to avoid overflow failures Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 18/56] ring-buffer: Prevent overflow of size in ring_buffer_resize() Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 19/56] mmc: mmc: Fix partition switch timeout for some eMMCs Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 20/56] ACPI / osi: Fix an issue that acpi_osi=!* cannot disable ACPICA internal strings Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 21/56] mmc: longer timeout for long read time quirk Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 22/56] [media] usbvision: revert commit 588afcc1 Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 23/56] USB: serial: keyspan: fix use-after-free in probe error path Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 24/56] USB: serial: quatech2: " Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 25/56] USB: serial: io_edgeport: fix memory leaks in attach " Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 26/56] USB: serial: io_edgeport: fix memory leaks in probe " Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 27/56] USB: serial: option: add support for Cinterion PH8 and AHxx Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 28/56] tty: vt, return error when con_startup fails Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 29/56] serial: samsung: Reorder the sequence of clock control when call s3c24xx_serial_set_termios() Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 30/56] MIPS: math-emu: Fix jalr emulation when rd == $0 Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 31/56] MIPS: Fix siginfo.h to use strict posix types Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 32/56] MIPS: ath79: make bootconsole wait for both THRE and TEMT Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 33/56] Input: uinput - handle compat ioctl for UI_SET_PHYS Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 34/56] ath5k: Change led pin configuration for compaq c700 laptop Jiri Slaby
2016-06-15  7:30 ` [PATCH 3.12 35/56] aacraid: Relinquish CPU during timeout wait Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 36/56] aacraid: Fix for aac_command_thread hang Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 37/56] cpuidle: Indicate when a device has been unregistered Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 38/56] PCI: Disable all BAR sizing for devices with non-compliant BARs Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 39/56] rtlwifi: Fix logic error in enter/exit power-save mode Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 40/56] powerpc/book3s64: Fix branching to OOL handlers in relocatable kernel Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 41/56] xen/events: Don't move disabled irqs Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 42/56] sunrpc: fix stripping of padded MIC tokens Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 43/56] drm/gma500: Fix possible out of bounds read Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 44/56] drm/fb_helper: Fix references to dev->mode_config.num_connector Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 45/56] ext4: fix hang when processing corrupted orphaned inode list Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 46/56] ext4: address UBSAN warning in mb_find_order_for_block() Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 47/56] ext4: silence UBSAN in ext4_mb_init() Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 48/56] dma-debug: avoid spinlock recursion when disabling dma-debug Jiri Slaby
2016-06-15  7:31 ` Jiri Slaby [this message]
2016-06-15  7:31 ` [PATCH 3.12 50/56] xfs: fix inode validity check in xfs_iflush_cluster Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 51/56] xfs: skip stale inodes " Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 52/56] [media] af9035: correct eeprom offsets Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 53/56] misc: ad525x_dpot: Fix the enabling of the "otpXen" attributes Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 54/56] pch_phub: return -ENODATA if ROM can't be mapped Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 55/56] Bluetooth: btmrvl_sdio: fix firmware activation failure Jiri Slaby
2016-06-15  7:31 ` [PATCH 3.12 56/56] Bluetooth: hci_ldisc: Fix null pointer derefence in case of early data Jiri Slaby
2016-06-15 15:34 ` [PATCH 3.12 00/56] 3.12.61-stable review Shuah Khan
2016-06-20  8:07   ` Jiri Slaby
2016-06-15 18:42 ` Guenter Roeck

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=90222356784cae9dd20211c9af03ebd81091ddd0.1465975780.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=david@fromorbit.com \
    --cc=dchinner@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --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).