Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: emilne@redhat.com (Ewan D. Milne)
Subject: [PATCH 0/1] Fix crash when failing to connect to FC NVMe target
Date: Mon, 24 Apr 2017 13:24:15 -0400	[thread overview]
Message-ID: <1493054656-18296-1-git-send-email-emilne@redhat.com> (raw)

From: "Ewan D. Milne" <emilne@redhat.com>

This patch fixes the following crash, caused because nvmf_create_ctrl()
calls nvmf_free_options() when an error is returned from nvme_fc_create_ctrl().

However, if we get as far as calling nvme_fc_create_assocation() and it returns
an error, we have an nvme_fc_ctrl kobject with a pointer to the nvmf_ctrl_options,
and nvmf_free_options() will be called upon object destruction.

Since the caller allocated the nvmf_ctrl_options, and frees it on error,
ensure that the kobject will not free the options unless a good status is
returned from the ops->create_ctrl() call.

[ 1175.863718] general protection fault: 0000 [#1] SMP
[ 1175.869157] Modules linked in: intel_rapl sb_edac edac_core x86_pkg_temp_thermal intel_powerclamp coretep
[ 1175.929882] CPU: 2 PID: 11385 Comm: sh Not tainted 4.10.0-rc2+ #31
[ 1175.936776] Hardware name: Dell Inc. PowerEdge R730/072T6D, BIOS 2.3.4 11/08/2016
[ 1175.945123] task: ffff880840cc1880 task.stack: ffffc9000ea14000
[ 1175.951728] RIP: 0010:nvmf_free_options+0x16/0x70
[ 1175.956973] RSP: 0018:ffffc9000ea17d50 EFLAGS: 00010202
[ 1175.962800] RAX: 00000000fffffffb RBX: ffff88083cc3fb18 RCX: 0000000000000000
[ 1175.970761] RDX: ffff880840cc1880 RSI: ffffffff8151a3e0 RDI: 6b6b6b6b6b6b6b6b
[ 1175.978721] RBP: ffffc9000ea17d58 R08: ffff880843d09bf8 R09: fffffffffffffffb
[ 1175.986680] R10: ffff880843d08958 R11: ffff880843d09bf8 R12: fffffffffffffffb
[ 1175.994639] R13: ffff88084b3435a8 R14: ffff880843c07da8 R15: ffff88083cc3fb18
[ 1176.002598] FS:  00007f8bbce7a740(0000) GS:ffff88085f280000(0000) knlGS:0000000000000000
[ 1176.011634] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1176.018044] CR2: 00007f8bbca3c090 CR3: 000000083a981000 CR4: 00000000003406e0
[ 1176.026004] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1176.033964] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 1176.041937] Call Trace:
[ 1176.044663]  nvmf_dev_write+0x428/0x9a0
[ 1176.048946]  ? __slab_free+0x17d/0x2c0
[ 1176.053126]  __vfs_write+0x37/0x160
[ 1176.057015]  ? selinux_file_permission+0xe5/0x120
[ 1176.062262]  ? security_file_permission+0x3b/0xc0
[ 1176.067506]  vfs_write+0xb2/0x1b0
[ 1176.071203]  ? syscall_trace_enter+0x1d0/0x2b0
[ 1176.076157]  SyS_write+0x55/0xc0
[ 1176.079755]  do_syscall_64+0x67/0x180
[ 1176.083839]  entry_SYSCALL64_slow_path+0x25/0x25
[ 1176.088987] RIP: 0033:0x7f8bbc560c60
[ 1176.092971] RSP: 002b:00007ffeaf3d5f28 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[ 1176.101415] RAX: ffffffffffffffda RBX: 0000000000000084 RCX: 00007f8bbc560c60
[ 1176.109374] RDX: 0000000000000084 RSI: 00007f8bbce7d000 RDI: 0000000000000001
[ 1176.117333] RBP: 00007f8bbce7d000 R08: 000000000000000a R09: 00007f8bbce7a740
[ 1176.125293] R10: 0000000000000083 R11: 0000000000000246 R12: 00007f8bbc833400
[ 1176.133252] R13: 0000000000000084 R14: 0000000000000001 R15: 0000000000000000
[ 1176.141213] Code: 89 1c 24 48 c7 c7 40 c5 d0 81 e8 86 fd 22 00 5b 41 5c 5d c3 90 0f 1f 44 00 00 55 48 89 
[ 1176.162277] RIP: nvmf_free_options+0x16/0x70 RSP: ffffc9000ea17d50
[ 1176.172046] ---[ end trace b6423bd8df867883 ]---
[ 1176.179704] Kernel panic - not syncing: Fatal exception
[ 1176.185570] Kernel Offset: disabled

Ewan D. Milne (1):
  nvme-fc: avoid memory corruption caused by calling nvmf_free_options()
    twice

 drivers/nvme/host/fc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
1.8.3.1

             reply	other threads:[~2017-04-24 17:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24 17:24 Ewan D. Milne [this message]
2017-04-24 17:24 ` [PATCH 1/1] nvme-fc: avoid memory corruption caused by calling nvmf_free_options() twice Ewan D. Milne
2017-04-25 17:54   ` Christoph Hellwig
2017-04-25 17:57     ` Christoph Hellwig
2017-04-25 18:00       ` Christoph Hellwig

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=1493054656-18296-1-git-send-email-emilne@redhat.com \
    --to=emilne@redhat.com \
    /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