From: Jeff Moyer <jmoyer@redhat.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@lists.01.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] libnvdimm, region: fix flush hint detection crash
Date: Wed, 26 Apr 2017 15:43:00 -0400 [thread overview]
Message-ID: <x49bmrj9cqj.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <149307779612.7155.12969380677038292861.stgit@dwillia2-desk3.amr.corp.intel.com> (Dan Williams's message of "Mon, 24 Apr 2017 16:49:56 -0700")
Dan Williams <dan.j.williams@intel.com> writes:
> In the case where a dimm does not have any associated flush hints the
> ndrd->flush_wpq array may be uninitialized leading to crashes with the
> following signature:
>
> BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
> IP: region_visible+0x10f/0x160 [libnvdimm]
>
> Call Trace:
> internal_create_group+0xbe/0x2f0
> sysfs_create_groups+0x40/0x80
> device_add+0x2d8/0x650
> nd_async_device_register+0x12/0x40 [libnvdimm]
> async_run_entry_fn+0x39/0x170
> process_one_work+0x212/0x6c0
> ? process_one_work+0x197/0x6c0
> worker_thread+0x4e/0x4a0
> kthread+0x10c/0x140
> ? process_one_work+0x6c0/0x6c0
> ? kthread_create_on_node+0x60/0x60
> ret_from_fork+0x31/0x40
Sorry for being dense, but I'm having a tough time connecting the dots,
here. How does region_visible trip over the missing (not uninitialized,
you're actually walking off the end of the structure) wpq_flush array?
Anyway, the fix looks valid.
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Thanks,
Jeff
>
> Cc: <stable@vger.kernel.org>
> Fixes: f284a4f23752 ("libnvdimm: introduce nvdimm_flush() and nvdimm_has_flush()")
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> drivers/nvdimm/region_devs.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> index 8de5a04644a1..24abceda986a 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -1000,17 +1000,20 @@ EXPORT_SYMBOL_GPL(nvdimm_flush);
> */
> int nvdimm_has_flush(struct nd_region *nd_region)
> {
> - struct nd_region_data *ndrd = dev_get_drvdata(&nd_region->dev);
> int i;
>
> /* no nvdimm == flushing capability unknown */
> if (nd_region->ndr_mappings == 0)
> return -ENXIO;
>
> - for (i = 0; i < nd_region->ndr_mappings; i++)
> - /* flush hints present, flushing required */
> - if (ndrd_get_flush_wpq(ndrd, i, 0))
> + for (i = 0; i < nd_region->ndr_mappings; i++) {
> + struct nd_mapping *nd_mapping = &nd_region->mapping[i];
> + struct nvdimm *nvdimm = nd_mapping->nvdimm;
> +
> + /* flush hints present / available */
> + if (nvdimm->num_flush)
> return 1;
> + }
>
> /*
> * The platform defines dimm devices without hints, assume
>
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2017-04-26 19:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-24 23:49 [PATCH v2 0/2] libnvdimm: export wpq flush interface Dan Williams
[not found] ` <149307779085.7155.436029631521340565.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-24 23:49 ` [PATCH v2 1/2] libnvdimm, region: fix flush hint detection crash Dan Williams
2017-04-26 19:43 ` Jeff Moyer [this message]
2017-04-26 20:04 ` Dan Williams
2017-04-24 23:50 ` [PATCH v2 2/2] libnvdimm, region: sysfs trigger for nvdimm_flush() Dan Williams
[not found] ` <149307780135.7155.11108531648914675756.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-25 16:37 ` Ross Zwisler
2017-04-25 16:38 ` Dan Williams
2017-04-25 20:17 ` [PATCH v3] " Dan Williams
2017-04-26 20:38 ` Jeff Moyer
2017-04-26 23:00 ` Dan Williams
2017-04-27 13:45 ` Jeff Moyer
2017-04-27 16:56 ` Dan Williams
2017-04-27 18:41 ` Jeff Moyer
[not found] ` <x49d1bxsngb.fsf-RRHT56Q3PSP4kTEheFKJxxDDeQx5vsVwAInAS/Ez/D0@public.gmane.org>
2017-04-27 19:17 ` Dan Williams
2017-04-27 19:21 ` Dan Williams
2017-04-27 19:43 ` Jeff Moyer
2017-04-27 19:40 ` Jeff Moyer
2017-04-27 20:02 ` Dan Williams
2017-04-27 21:36 ` Dan Williams
2017-04-26 23:36 ` [PATCH v4] " Dan Williams
2017-04-27 22:17 ` [PATCH v5] " Dan Williams
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=x49bmrj9cqj.fsf@segfault.boston.devel.redhat.com \
--to=jmoyer@redhat.com \
--cc=dan.j.williams@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.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