linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix NULL pointer deref in nvme_ctrl_fast_io_fail_tmo_show
@ 2021-04-13  6:49 Gopal Tiwari
  2021-04-13  9:11 ` Daniel Wagner
  0 siblings, 1 reply; 2+ messages in thread
From: Gopal Tiwari @ 2021-04-13  6:49 UTC (permalink / raw)
  To: linux-nvme, kbusch; +Cc: gtiwari

When accessing fast_io_fail_tmo from /sys hit kernel crash

 #7 [ffff9ddf82467d80] page_fault at ffffffff90e010fe
    [exception RIP: nvme_ctrl_fast_io_fail_tmo_show+22]
    RIP: ffffffffc0465116  RSP: ffff9ddf82467e38  RFLAGS: 00010286
    RAX: 0000000000000000  RBX: ffffffffc0476260  RCX: ffff8b617fe94000
    RDX: ffff8b617fe94000  RSI: ffffffffc0476260  RDI: ffff8b5e45a303a8
    RBP: ffffffff912b7d30   R8: ffff8b5e45a303b8   R9: ffff8b618dae5900
    R10: ffff8b617fe94000  R11: 0000000000000001  R12: 00000000ffffffff
    R13: 0000000000000001  R14: ffff8b617f46ee00  R15: ffff8b60e9a56380
    ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
 #8 [ffff9ddf82467e30] mutex_lock at ffffffff90d4a5ce
 #9 [ffff9ddf82467e50] sysfs_kf_seq_show at ffffffff907b0abb

Fixed by the checking opts for NULL.

Fixes: 09fbed636382 (nvme: export fast_io_fail_tmo to sysfs)
Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 314705da2c10..39b8fbe87adb 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3752,7 +3752,7 @@ static ssize_t nvme_ctrl_fast_io_fail_tmo_show(struct device *dev,
 {
 	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
 
-	if (ctrl->opts->fast_io_fail_tmo == -1)
+	if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo == -1)
 		return sysfs_emit(buf, "off\n");
 	return sysfs_emit(buf, "%d\n", ctrl->opts->fast_io_fail_tmo);
 }
-- 
2.26.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix NULL pointer deref in nvme_ctrl_fast_io_fail_tmo_show
  2021-04-13  6:49 [PATCH] Fix NULL pointer deref in nvme_ctrl_fast_io_fail_tmo_show Gopal Tiwari
@ 2021-04-13  9:11 ` Daniel Wagner
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Wagner @ 2021-04-13  9:11 UTC (permalink / raw)
  To: Gopal Tiwari; +Cc: linux-nvme, kbusch

On Tue, Apr 13, 2021 at 12:19:53PM +0530, Gopal Tiwari wrote:
> When accessing fast_io_fail_tmo from /sys hit kernel crash
> 
>  #7 [ffff9ddf82467d80] page_fault at ffffffff90e010fe
>     [exception RIP: nvme_ctrl_fast_io_fail_tmo_show+22]
>     RIP: ffffffffc0465116  RSP: ffff9ddf82467e38  RFLAGS: 00010286
>     RAX: 0000000000000000  RBX: ffffffffc0476260  RCX: ffff8b617fe94000
>     RDX: ffff8b617fe94000  RSI: ffffffffc0476260  RDI: ffff8b5e45a303a8
>     RBP: ffffffff912b7d30   R8: ffff8b5e45a303b8   R9: ffff8b618dae5900
>     R10: ffff8b617fe94000  R11: 0000000000000001  R12: 00000000ffffffff
>     R13: 0000000000000001  R14: ffff8b617f46ee00  R15: ffff8b60e9a56380
>     ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
>  #8 [ffff9ddf82467e30] mutex_lock at ffffffff90d4a5ce
>  #9 [ffff9ddf82467e50] sysfs_kf_seq_show at ffffffff907b0abb
> 
> Fixed by the checking opts for NULL.
> 
> Fixes: 09fbed636382 (nvme: export fast_io_fail_tmo to sysfs)
> Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>

Do the other functions like nvme_ctrl_loss_tmo_*(),
nvme_sysfs_show_address(), ... not also need this treatment?

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-13  9:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13  6:49 [PATCH] Fix NULL pointer deref in nvme_ctrl_fast_io_fail_tmo_show Gopal Tiwari
2021-04-13  9:11 ` Daniel Wagner

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).