From: Greg Kroah-Hartman Date: Thu, 18 May 2017 09:33:24 +0000 (+0200) Subject: 4.9-stable patches X-Git-Tag: v3.18.54~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=168f1a9af534040c7e83cc6eaf3c545a70340bd6;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: libnvdimm-pfn-fix-npfns-vs-section-alignment.patch libnvdimm-pmem-fix-a-null-pointer-bug-in-nd_pmem_notify.patch libnvdimm-region-fix-flush-hint-detection-crash.patch pstore-fix-flags-to-enable-dumps-on-powerpc.patch pstore-shut-down-worker-when-unregistering.patch --- diff --git a/queue-4.9/libnvdimm-pfn-fix-npfns-vs-section-alignment.patch b/queue-4.9/libnvdimm-pfn-fix-npfns-vs-section-alignment.patch new file mode 100644 index 00000000000..86110b90c86 --- /dev/null +++ b/queue-4.9/libnvdimm-pfn-fix-npfns-vs-section-alignment.patch @@ -0,0 +1,68 @@ +From d5483feda85a8f39ee2e940e279547c686aac30c Mon Sep 17 00:00:00 2001 +From: Dan Williams +Date: Thu, 4 May 2017 19:54:42 -0700 +Subject: libnvdimm, pfn: fix 'npfns' vs section alignment + +From: Dan Williams + +commit d5483feda85a8f39ee2e940e279547c686aac30c upstream. + +Fix failures to create namespaces due to the vmem_altmap not advertising +enough free space to store the memmap. + + WARNING: CPU: 15 PID: 8022 at arch/x86/mm/init_64.c:656 arch_add_memory+0xde/0xf0 + [..] + Call Trace: + dump_stack+0x63/0x83 + __warn+0xcb/0xf0 + warn_slowpath_null+0x1d/0x20 + arch_add_memory+0xde/0xf0 + devm_memremap_pages+0x244/0x440 + pmem_attach_disk+0x37e/0x490 [nd_pmem] + nd_pmem_probe+0x7e/0xa0 [nd_pmem] + nvdimm_bus_probe+0x71/0x120 [libnvdimm] + driver_probe_device+0x2bb/0x460 + bind_store+0x114/0x160 + drv_attr_store+0x25/0x30 + +In commit 658922e57b84 "libnvdimm, pfn: fix memmap reservation sizing" +we arranged for the capacity to be allocated, but failed to also update +the 'npfns' parameter. This leads to cases where there is enough +capacity reserved to hold all the allocated sections, but +vmemmap_populate_hugepages() still encounters -ENOMEM from +altmap_alloc_block_buf(). + +This fix is a stop-gap until we can teach the core memory hotplug +implementation to permit sub-section hotplug. + +Fixes: 658922e57b84 ("libnvdimm, pfn: fix memmap reservation sizing") +Reported-by: Anisha Allada +Signed-off-by: Dan Williams +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/nvdimm/pfn_devs.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/nvdimm/pfn_devs.c ++++ b/drivers/nvdimm/pfn_devs.c +@@ -538,7 +538,8 @@ static struct vmem_altmap *__nvdimm_setu + nd_pfn->npfns = le64_to_cpu(pfn_sb->npfns); + altmap = NULL; + } else if (nd_pfn->mode == PFN_MODE_PMEM) { +- nd_pfn->npfns = (resource_size(res) - offset) / PAGE_SIZE; ++ nd_pfn->npfns = PFN_SECTION_ALIGN_UP((resource_size(res) ++ - offset) / PAGE_SIZE); + if (le64_to_cpu(nd_pfn->pfn_sb->npfns) > nd_pfn->npfns) + dev_info(&nd_pfn->dev, + "number of pfns truncated from %lld to %ld\n", +@@ -625,7 +626,8 @@ static int nd_pfn_init(struct nd_pfn *nd + */ + start += start_pad; + size = resource_size(&nsio->res); +- npfns = (size - start_pad - end_trunc - SZ_8K) / SZ_4K; ++ npfns = PFN_SECTION_ALIGN_UP((size - start_pad - end_trunc - SZ_8K) ++ / PAGE_SIZE); + if (nd_pfn->mode == PFN_MODE_PMEM) { + /* + * vmemmap_populate_hugepages() allocates the memmap array in diff --git a/queue-4.9/libnvdimm-pmem-fix-a-null-pointer-bug-in-nd_pmem_notify.patch b/queue-4.9/libnvdimm-pmem-fix-a-null-pointer-bug-in-nd_pmem_notify.patch new file mode 100644 index 00000000000..615ad5ca312 --- /dev/null +++ b/queue-4.9/libnvdimm-pmem-fix-a-null-pointer-bug-in-nd_pmem_notify.patch @@ -0,0 +1,102 @@ +From b2518c78ce76896f0f8f7940bf02104b227e1709 Mon Sep 17 00:00:00 2001 +From: Toshi Kani +Date: Tue, 25 Apr 2017 17:04:13 -0600 +Subject: libnvdimm, pmem: fix a NULL pointer BUG in nd_pmem_notify + +From: Toshi Kani + +commit b2518c78ce76896f0f8f7940bf02104b227e1709 upstream. + +The following BUG was observed when nd_pmem_notify() was called +for a BTT device. The use of a pmem_device pointer is not valid +with BTT. + + BUG: unable to handle kernel NULL pointer dereference at 0000000000000030 + IP: nd_pmem_notify+0x30/0xf0 [nd_pmem] + Call Trace: + nd_device_notify+0x40/0x50 + child_notify+0x10/0x20 + device_for_each_child+0x50/0x90 + nd_region_notify+0x20/0x30 + nd_device_notify+0x40/0x50 + nvdimm_region_notify+0x27/0x30 + acpi_nfit_scrub+0x341/0x590 [nfit] + process_one_work+0x197/0x450 + worker_thread+0x4e/0x4a0 + kthread+0x109/0x140 + +Fix nd_pmem_notify() by setting nd_region and badblocks pointers +properly for BTT. + +Cc: Vishal Verma +Fixes: 719994660c24 ("libnvdimm: async notification support") +Signed-off-by: Toshi Kani +Signed-off-by: Dan Williams +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/nvdimm/pmem.c | 39 ++++++++++++++++++++++++++------------- + 1 file changed, 26 insertions(+), 13 deletions(-) + +--- a/drivers/nvdimm/pmem.c ++++ b/drivers/nvdimm/pmem.c +@@ -383,12 +383,12 @@ static void nd_pmem_shutdown(struct devi + + static void nd_pmem_notify(struct device *dev, enum nvdimm_event event) + { +- struct pmem_device *pmem = dev_get_drvdata(dev); +- struct nd_region *nd_region = to_region(pmem); ++ struct nd_region *nd_region; + resource_size_t offset = 0, end_trunc = 0; + struct nd_namespace_common *ndns; + struct nd_namespace_io *nsio; + struct resource res; ++ struct badblocks *bb; + + if (event != NVDIMM_REVALIDATE_POISON) + return; +@@ -397,20 +397,33 @@ static void nd_pmem_notify(struct device + struct nd_btt *nd_btt = to_nd_btt(dev); + + ndns = nd_btt->ndns; +- } else if (is_nd_pfn(dev)) { +- struct nd_pfn *nd_pfn = to_nd_pfn(dev); +- struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb; +- +- ndns = nd_pfn->ndns; +- offset = pmem->data_offset + __le32_to_cpu(pfn_sb->start_pad); +- end_trunc = __le32_to_cpu(pfn_sb->end_trunc); +- } else +- ndns = to_ndns(dev); ++ nd_region = to_nd_region(ndns->dev.parent); ++ nsio = to_nd_namespace_io(&ndns->dev); ++ bb = &nsio->bb; ++ } else { ++ struct pmem_device *pmem = dev_get_drvdata(dev); ++ ++ nd_region = to_region(pmem); ++ bb = &pmem->bb; ++ ++ if (is_nd_pfn(dev)) { ++ struct nd_pfn *nd_pfn = to_nd_pfn(dev); ++ struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb; ++ ++ ndns = nd_pfn->ndns; ++ offset = pmem->data_offset + ++ __le32_to_cpu(pfn_sb->start_pad); ++ end_trunc = __le32_to_cpu(pfn_sb->end_trunc); ++ } else { ++ ndns = to_ndns(dev); ++ } ++ ++ nsio = to_nd_namespace_io(&ndns->dev); ++ } + +- nsio = to_nd_namespace_io(&ndns->dev); + res.start = nsio->res.start + offset; + res.end = nsio->res.end - end_trunc; +- nvdimm_badblocks_populate(nd_region, &pmem->bb, &res); ++ nvdimm_badblocks_populate(nd_region, bb, &res); + } + + MODULE_ALIAS("pmem"); diff --git a/queue-4.9/libnvdimm-region-fix-flush-hint-detection-crash.patch b/queue-4.9/libnvdimm-region-fix-flush-hint-detection-crash.patch new file mode 100644 index 00000000000..479ef5f7285 --- /dev/null +++ b/queue-4.9/libnvdimm-region-fix-flush-hint-detection-crash.patch @@ -0,0 +1,66 @@ +From bc042fdfbb92b5b13421316b4548e2d6e98eed37 Mon Sep 17 00:00:00 2001 +From: Dan Williams +Date: Mon, 24 Apr 2017 15:43:05 -0700 +Subject: libnvdimm, region: fix flush hint detection crash + +From: Dan Williams + +commit bc042fdfbb92b5b13421316b4548e2d6e98eed37 upstream. + +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 + +Reviewed-by: Jeff Moyer +Fixes: f284a4f23752 ("libnvdimm: introduce nvdimm_flush() and nvdimm_has_flush()") +Signed-off-by: Dan Williams +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/nvdimm/region_devs.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- a/drivers/nvdimm/region_devs.c ++++ b/drivers/nvdimm/region_devs.c +@@ -968,17 +968,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 diff --git a/queue-4.9/pstore-fix-flags-to-enable-dumps-on-powerpc.patch b/queue-4.9/pstore-fix-flags-to-enable-dumps-on-powerpc.patch new file mode 100644 index 00000000000..5c45d907e4f --- /dev/null +++ b/queue-4.9/pstore-fix-flags-to-enable-dumps-on-powerpc.patch @@ -0,0 +1,36 @@ +From 041939c1ec54208b42f5cd819209173d52a29d34 Mon Sep 17 00:00:00 2001 +From: Ankit Kumar +Date: Thu, 27 Apr 2017 17:03:13 +0530 +Subject: pstore: Fix flags to enable dumps on powerpc + +From: Ankit Kumar + +commit 041939c1ec54208b42f5cd819209173d52a29d34 upstream. + +After commit c950fd6f201a kernel registers pstore write based on flag set. +Pstore write for powerpc is broken as flags(PSTORE_FLAGS_DMESG) is not set for +powerpc architecture. On panic, kernel doesn't write message to +/fs/pstore/dmesg*(Entry doesn't gets created at all). + +This patch enables pstore write for powerpc architecture by setting +PSTORE_FLAGS_DMESG flag. + +Fixes: c950fd6f201a ("pstore: Split pstore fragile flags") +Signed-off-by: Ankit Kumar +Signed-off-by: Kees Cook +Signed-off-by: Greg Kroah-Hartman + +--- + arch/powerpc/kernel/nvram_64.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/arch/powerpc/kernel/nvram_64.c ++++ b/arch/powerpc/kernel/nvram_64.c +@@ -561,6 +561,7 @@ static ssize_t nvram_pstore_read(u64 *id + static struct pstore_info nvram_pstore_info = { + .owner = THIS_MODULE, + .name = "nvram", ++ .flags = PSTORE_FLAGS_DMESG, + .open = nvram_pstore_open, + .read = nvram_pstore_read, + .write = nvram_pstore_write, diff --git a/queue-4.9/pstore-shut-down-worker-when-unregistering.patch b/queue-4.9/pstore-shut-down-worker-when-unregistering.patch new file mode 100644 index 00000000000..51bd2bb8c88 --- /dev/null +++ b/queue-4.9/pstore-shut-down-worker-when-unregistering.patch @@ -0,0 +1,53 @@ +From 6330d5534786d5315d56d558aa6d20740f97d80a Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Mon, 6 Mar 2017 12:42:12 -0800 +Subject: pstore: Shut down worker when unregistering + +From: Kees Cook + +commit 6330d5534786d5315d56d558aa6d20740f97d80a upstream. + +When built as a module and running with update_ms >= 0, pstore will Oops +during module unload since the work timer is still running. This makes sure +the worker is stopped before unloading. + +Signed-off-by: Kees Cook +Signed-off-by: Greg Kroah-Hartman + +--- + fs/pstore/platform.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +--- a/fs/pstore/platform.c ++++ b/fs/pstore/platform.c +@@ -704,6 +704,7 @@ int pstore_register(struct pstore_info * + if (psi->flags & PSTORE_FLAGS_PMSG) + pstore_register_pmsg(); + ++ /* Start watching for new records, if desired. */ + if (pstore_update_ms >= 0) { + pstore_timer.expires = jiffies + + msecs_to_jiffies(pstore_update_ms); +@@ -726,6 +727,11 @@ EXPORT_SYMBOL_GPL(pstore_register); + + void pstore_unregister(struct pstore_info *psi) + { ++ /* Stop timer and make sure all work has finished. */ ++ pstore_update_ms = -1; ++ del_timer_sync(&pstore_timer); ++ flush_work(&pstore_work); ++ + if (psi->flags & PSTORE_FLAGS_PMSG) + pstore_unregister_pmsg(); + if (psi->flags & PSTORE_FLAGS_FTRACE) +@@ -825,7 +831,9 @@ static void pstore_timefunc(unsigned lon + schedule_work(&pstore_work); + } + +- mod_timer(&pstore_timer, jiffies + msecs_to_jiffies(pstore_update_ms)); ++ if (pstore_update_ms >= 0) ++ mod_timer(&pstore_timer, ++ jiffies + msecs_to_jiffies(pstore_update_ms)); + } + + module_param(backend, charp, 0444); diff --git a/queue-4.9/series b/queue-4.9/series index 67489a9ea19..707c7ad7422 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -73,3 +73,8 @@ bluetooth-fix-user-channel-for-32bit-userspace-on-64bit-kernel.patch bluetooth-hci_bcm-add-missing-tty-device-sanity-check.patch bluetooth-hci_intel-add-missing-tty-device-sanity-check.patch ipmi-fix-kernel-panic-at-ipmi_ssif_thread.patch +libnvdimm-region-fix-flush-hint-detection-crash.patch +libnvdimm-pmem-fix-a-null-pointer-bug-in-nd_pmem_notify.patch +libnvdimm-pfn-fix-npfns-vs-section-alignment.patch +pstore-fix-flags-to-enable-dumps-on-powerpc.patch +pstore-shut-down-worker-when-unregistering.patch