]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - block/blk-core.c
SCSI: Fix NULL pointer dereference in runtime PM
authorKen Xue <ken.xue@amd.com>
Tue, 1 Dec 2015 06:45:46 +0000 (14:45 +0800)
committerJens Axboe <axboe@fb.com>
Fri, 4 Dec 2015 03:35:02 +0000 (20:35 -0700)
commit4fd41a8552afc01054d9d9fc7f1a63c324867d27
tree6e2f5b3206f75c732b307402d2f726317499f712
parent071f5d105a0ae93aeb02197c4ee3557e8cc57a21
SCSI: Fix NULL pointer dereference in runtime PM

The routines in scsi_pm.c assume that if a runtime-PM callback is
invoked for a SCSI device, it can only mean that the device's driver
has asked the block layer to handle the runtime power management (by
calling blk_pm_runtime_init(), which among other things sets q->dev).

However, this assumption turns out to be wrong for things like the ses
driver.  Normally ses devices are not allowed to do runtime PM, but
userspace can override this setting.  If this happens, the kernel gets
a NULL pointer dereference when blk_post_runtime_resume() tries to use
the uninitialized q->dev pointer.

This patch fixes the problem by checking q->dev in block layer before
handle runtime PM. Since ses doesn't define any PM callbacks and call
blk_pm_runtime_init(), the crash won't occur.

This fixes Bugzilla #101371.
https://bugzilla.kernel.org/show_bug.cgi?id=101371

More discussion can be found from below link.
http://marc.info/?l=linux-scsi&m=144163730531875&w=2

Signed-off-by: Ken Xue <Ken.Xue@amd.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Xiangliang Yu <Xiangliang.Yu@amd.com>
Cc: James E.J. Bottomley <JBottomley@odin.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Michael Terry <Michael.terry@canonical.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-core.c