stable.vger.kernel.org archive mirror
 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,
	Bart Van Assche <bart.vanassche@sandisk.com>,
	Junichi Nomura <j-nomura@ce.jp.nec.com>,
	Mike Snitzer <snitzer@redhat.com>
Subject: [PATCH 4.0 20/22] dm: fix NULL pointer when clone_and_map_rq returns !DM_MAPIO_REMAPPED
Date: Fri, 26 Jun 2015 18:09:02 -0700	[thread overview]
Message-ID: <20150627010854.787363024@linuxfoundation.org> (raw)
In-Reply-To: <20150627010854.064848055@linuxfoundation.org>

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

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

From: Junichi Nomura <j-nomura@ce.jp.nec.com>

commit 3a1407559a593d4360af12dd2df5296bf8eb0d28 upstream.

When stacking request-based DM on blk_mq device, request cloning and
remapping are done in a single call to target's clone_and_map_rq().
The clone is allocated and valid only if clone_and_map_rq() returns
DM_MAPIO_REMAPPED.

The "IS_ERR(clone)" check in map_request() does not cover all the
!DM_MAPIO_REMAPPED cases that are possible (E.g. if underlying devices
are not ready or unavailable, clone_and_map_rq() may return
DM_MAPIO_REQUEUE without ever having established an ERR_PTR).  Fix this
by explicitly checking for a return that is not DM_MAPIO_REMAPPED in
map_request().

Without this fix, DM core may call setup_clone() for a NULL clone
and oops like this:

   BUG: unable to handle kernel NULL pointer dereference at 0000000000000068
   IP: [<ffffffff81227525>] blk_rq_prep_clone+0x7d/0x137
   ...
   CPU: 2 PID: 5793 Comm: kdmwork-253:3 Not tainted 4.0.0-nm #1
   ...
   Call Trace:
    [<ffffffffa01d1c09>] map_tio_request+0xa9/0x258 [dm_mod]
    [<ffffffff81071de9>] kthread_worker_fn+0xfd/0x150
    [<ffffffff81071cec>] ? kthread_parkme+0x24/0x24
    [<ffffffff81071cec>] ? kthread_parkme+0x24/0x24
    [<ffffffff81071fdd>] kthread+0xe6/0xee
    [<ffffffff81093a59>] ? put_lock_stats+0xe/0x20
    [<ffffffff81071ef7>] ? __init_kthread_worker+0x5b/0x5b
    [<ffffffff814c2d98>] ret_from_fork+0x58/0x90
    [<ffffffff81071ef7>] ? __init_kthread_worker+0x5b/0x5b

Fixes: e5863d9ad ("dm: allocate requests in target when stacking on blk-mq devices")
Reported-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


---
 drivers/md/dm.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1889,8 +1889,8 @@ static int map_request(struct dm_target
 			dm_kill_unmapped_request(rq, r);
 			return r;
 		}
-		if (IS_ERR(clone))
-			return DM_MAPIO_REQUEUE;
+		if (r != DM_MAPIO_REMAPPED)
+			return r;
 		if (setup_clone(clone, rq, tio, GFP_KERNEL)) {
 			/* -ENOMEM */
 			ti->type->release_clone_rq(clone);



  parent reply	other threads:[~2015-06-27  1:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-27  1:08 [PATCH 4.0 00/22] 4.0.7-stable review Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 01/22] crypto: caam - improve initalization for context state saves Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 02/22] crypto: caam - fix RNG buffer cache alignment Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 04/22] clk: at91: pll: fix input range validity check Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 05/22] clk: at91: fix h32mx prototype inclusion in pmc header Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 06/22] ALSA: hda - adding a DAC/pin preference map for a HP Envy TS machine Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 07/22] tracing: Have filter check for balanced ops Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 08/22] iser-target: Fix variable-length response error completion Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 09/22] iser-target: Fix possible use-after-free Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 10/22] drm/mgag200: Reject non-character-cell-aligned mode widths Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 11/22] drm/i915: Always reset vma->ggtt_view.pages cache on unbinding Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 14/22] ath3k: Add support of 0489:e076 AR3012 device Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 15/22] ath3k: add support of 13d3:3474 " Greg Kroah-Hartman
2015-06-27  1:08 ` [PATCH 4.0 17/22] cdc-acm: Add support of ATOL FPrint fiscal printers Greg Kroah-Hartman
2015-06-27  1:09 ` [PATCH 4.0 18/22] ARM: EXYNOS: Fix failed second suspend on Exynos4 Greg Kroah-Hartman
2015-06-27  1:09 ` [PATCH 4.0 19/22] kprobes/x86: Return correct length in __copy_instruction() Greg Kroah-Hartman
2015-06-27  1:09 ` Greg Kroah-Hartman [this message]
2015-06-27  1:09 ` [PATCH 4.0 21/22] drm/i915: Avoid GPU hang when coming out of s3 or s4 Greg Kroah-Hartman
2015-06-27  1:09 ` [PATCH 4.0 22/22] powerpc/powernv: Restore non-volatile CRs after nap Greg Kroah-Hartman
2015-06-27  3:13 ` [PATCH 4.0 00/22] 4.0.7-stable review Shuah Khan
2015-06-27  6:07 ` Guenter Roeck
2015-06-27  9:04 ` Sudip Mukherjee

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=20150627010854.787363024@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=bart.vanassche@sandisk.com \
    --cc=j-nomura@ce.jp.nec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=snitzer@redhat.com \
    --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).