From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Eryu Guan <eguan@redhat.com>,
Christoph Hellwig <hch@lst.de>,
Chandan Rajendra <chandan@linux.vnet.ibm.com>,
"Darrick J. Wong" <darrick.wong@oracle.com>
Subject: [PATCH 4.13 68/85] iomap_dio_rw: Allocate AIO completion queue before submitting dio
Date: Tue, 24 Oct 2017 15:07:42 +0200 [thread overview]
Message-ID: <20171024125656.721943131@linuxfoundation.org> (raw)
In-Reply-To: <20171024125654.028122623@linuxfoundation.org>
4.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
commit 546e7be8244dc050effef0555df5b8d94d10dafc upstream.
Executing xfs/104 test in a loop on Linux-v4.13 kernel on a ppc64
machine can cause the following NULL pointer dereference,
.queue_work_on+0x4c/0x80
.iomap_dio_bio_end_io+0xbc/0x1f0
.bio_endio+0x118/0x1f0
.blk_update_request+0xd0/0x470
.blk_mq_end_request+0x24/0xc0
.lo_complete_rq+0x40/0xe0
.__blk_mq_complete_request_remote+0x28/0x40
.flush_smp_call_function_queue+0xc4/0x1e0
.smp_ipi_demux_relaxed+0x8c/0x100
.icp_hv_ipi_action+0x54/0xa0
.__handle_irq_event_percpu+0x84/0x2c0
.handle_irq_event_percpu+0x28/0x80
.handle_percpu_irq+0x78/0xc0
.generic_handle_irq+0x40/0x70
.__do_irq+0x88/0x200
.call_do_irq+0x14/0x24
.do_IRQ+0x84/0x130
This occurs due to the following sequence of events,
1. Allocate dio for Direct I/O write.
2. Invoke iomap_apply() until iov_iter_count() bytes have been submitted.
- Assume that we have submitted atleast one bio. Hence iomap_dio->ref value
will be >= 2.
- If during the second iteration, iomap_apply() ends up returning -ENOSPC, we would
break out of the loop and since the 'ret' value is a negative number we
end up not allocating memory for super_block->s_dio_done_wq.
3. Meanwhile, iomap_dio_bio_end_io() is invoked for bios that have been
submitted and here the code ends up dereferencing the NULL pointer stored
at super_block->s_dio_done_wq.
This commit fixes the bug by allocating memory for
super_block->s_dio_done_wq before iomap_apply() is invoked.
Reported-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/iomap.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -993,6 +993,13 @@ iomap_dio_rw(struct kiocb *iocb, struct
WARN_ON_ONCE(ret);
ret = 0;
+ if (iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) &&
+ !inode->i_sb->s_dio_done_wq) {
+ ret = sb_init_dio_done_wq(inode->i_sb);
+ if (ret < 0)
+ goto out_free_dio;
+ }
+
inode_dio_begin(inode);
blk_start_plug(&plug);
@@ -1015,13 +1022,6 @@ iomap_dio_rw(struct kiocb *iocb, struct
if (ret < 0)
iomap_dio_set_error(dio, ret);
- if (ret >= 0 && iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) &&
- !inode->i_sb->s_dio_done_wq) {
- ret = sb_init_dio_done_wq(inode->i_sb);
- if (ret < 0)
- iomap_dio_set_error(dio, ret);
- }
-
if (!atomic_dec_and_test(&dio->ref)) {
if (!is_sync_kiocb(iocb))
return -EIOCBQUEUED;
next prev parent reply other threads:[~2017-10-24 13:07 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 13:06 [PATCH 4.13 00/85] 4.13.10-stable review Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 01/85] staging: bcm2835-audio: Fix memory corruption Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 02/85] USB: devio: Revert "USB: devio: Dont corrupt user memory" Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 03/85] USB: core: fix out-of-bounds access bug in usb_get_bos_descriptor() Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 04/85] USB: serial: metro-usb: add MS7820 device id Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 05/85] usb: cdc_acm: Add quirk for Elatec TWN3 Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 07/85] usb: hub: Allow reset retry for USB2 devices on connect bounce Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 08/85] ALSA: usb-audio: Add native DSD support for Pro-Ject Pre Box S2 Digital Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 09/85] can: gs_usb: fix busy loop if no more TX context is available Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 10/85] scsi: qla2xxx: Fix uninitialized work element Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 11/85] nbd: dont set the device size until were connected Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 12/85] s390/cputime: fix guest/irq/softirq times after CPU hotplug Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 13/85] parisc: Fix double-word compare and exchange in LWS code on 32-bit kernels Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 14/85] parisc: Fix detection of nonsynchronous cr16 cycle counters Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 15/85] iio: dummy: events: Add missing break Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 16/85] usb: musb: sunxi: Explicitly release USB PHY on exit Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 17/85] USB: musb: fix session-bit runtime-PM quirk Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 18/85] USB: musb: fix late external abort on suspend Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 19/85] usb: musb: musb_cppi41: Fix the address of teardown and autoreq registers Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 20/85] usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 21/85] usb: musb: musb_cppi41: Configure the number of channels " Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 22/85] usb: musb: Check for host-mode using is_host_active() on reset interrupt Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 23/85] xhci: Identify USB 3.1 capable hosts by their port protocol capability Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 24/85] xhci: Cleanup current_cmd in xhci_cleanup_command_queue() Greg Kroah-Hartman
2017-10-24 13:06 ` [PATCH 4.13 25/85] usb: xhci: Reset halted endpoint if trb is noop Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 26/85] usb: xhci: Handle error condition in xhci_stop_device() Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 28/85] can: af_can: can_pernet_init(): add missing error handling for kzalloc returning NULL Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 29/85] can: flexcan: fix state transition regression Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 30/85] can: flexcan: rename legacy error state quirk Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 31/85] can: flexcan: implement error passive " Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 32/85] can: flexcan: fix i.MX6 state transition issue Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 33/85] can: flexcan: fix i.MX28 " Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 34/85] can: flexcan: fix p1010 " Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 35/85] KEYS: encrypted: fix dereference of NULL user_key_payload Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 36/85] mmc: sdhci-pci: Fix default d3_retune for Intel host controllers Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 38/85] drm/nouveau/kms/nv50: fix oops during DP IRQ handling on non-MST boards Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 39/85] drm/nouveau/bsp/g92: disable by default Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 40/85] drm/nouveau/mmu: flush tlbs before deleting page tables Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 41/85] media: s5p-cec: add NACK detection support Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 42/85] media: cec: Respond to unregistered initiators, when applicable Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 43/85] media: dvb: i2c transfers over usb cannot be done from stack Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 44/85] tracing/samples: Fix creation and deletion of simple_thread_fn creation Greg Kroah-Hartman
2017-10-30 19:57 ` Steven Rostedt
2017-10-30 21:17 ` Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 45/85] ALSA: seq: Enable use locking in all configurations Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 46/85] ALSA: hda: Remove superfluous - added by printk conversion Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 47/85] ALSA: hda: Abort capability probe at invalid register read Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 48/85] i2c: ismt: Separate I2C block read from SMBus block read Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 50/85] Revert "tools/power turbostat: stop migrating, unless -m" Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 51/85] Input: stmfts - fix setting ABS_MT_POSITION_* maximum size Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 52/85] brcmfmac: Add check for short event packets Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 53/85] brcmsmac: make some local variables static const to reduce stack size Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 54/85] ARM: dts: sun6i: Fix endpoint IDs in second display pipeline Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 55/85] bus: mbus: fix window size calculation for 4GB windows Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 56/85] clockevents/drivers/cs5535: Improve resilience to spurious interrupts Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 57/85] rtlwifi: rtl8821ae: Fix connection lost problem Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 58/85] x86/microcode/intel: Disable late loading on model 79 Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 59/85] lib/digsig: fix dereference of NULL user_key_payload Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 60/85] fscrypt: " Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 61/85] ecryptfs: " Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 62/85] KEYS: Fix race between updating and finding a negative key Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 63/85] FS-Cache: fix dereference of NULL user_key_payload Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 64/85] KEYS: dont let add_key() update an uninstantiated key Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 65/85] pkcs7: Prevent NULL pointer dereference, since sinfo is not always set Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 66/85] arm64: dts: rockchip: correct vqmmc voltage for rk3399 platforms Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 67/85] ALSA: hda - Fix incorrect TLV callback check introduced during set_fs() removal Greg Kroah-Hartman
2017-10-24 13:07 ` Greg Kroah-Hartman [this message]
2017-10-24 13:07 ` [PATCH 4.13 69/85] xfs: dont unconditionally clear the reflink flag on zero-block files Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 70/85] xfs: evict CoW fork extents when performing finsert/fcollapse Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 71/85] fs/xfs: Use %pS printk format for direct addresses Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 72/85] xfs: report zeroed or not correctly in xfs_zero_range() Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 73/85] xfs: update i_size after unwritten conversion in dio completion Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 74/85] xfs: perag initialization should only touch m_ag_max_usable for AG 0 Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 75/85] xfs: Capture state of the right inode in xfs_iflush_done Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 76/85] xfs: always swap the cow forks when swapping extents Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 77/85] xfs: handle racy AIO in xfs_reflink_end_cow Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 78/85] xfs: Dont log uninitialised fields in inode structures Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 79/85] xfs: move more RT specific code under CONFIG_XFS_RT Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 80/85] xfs: dont change inode mode if ACL update fails Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 81/85] xfs: reinit btree pointer on attr tree inactivation walk Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 82/85] xfs: handle error if xfs_btree_get_bufs fails Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 83/85] xfs: cancel dirty pages on invalidation Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 84/85] xfs: trim writepage mapping to within eof Greg Kroah-Hartman
2017-10-24 13:07 ` [PATCH 4.13 85/85] xfs: move two more RT specific functions into CONFIG_XFS_RT Greg Kroah-Hartman
2017-10-25 21:09 ` Arnd Bergmann
2017-10-26 7:09 ` Greg Kroah-Hartman
2017-10-24 21:28 ` [PATCH 4.13 00/85] 4.13.10-stable review Guenter Roeck
2017-10-25 6:48 ` Greg Kroah-Hartman
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=20171024125656.721943131@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=chandan@linux.vnet.ibm.com \
--cc=darrick.wong@oracle.com \
--cc=eguan@redhat.com \
--cc=hch@lst.de \
--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).