]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.16.4/nfit-address-range-scrub-fix-scrub-in-progress-reporting.patch
fix up queue-5.15/mm-fix-race-between-__split_huge_pmd_locked-and-gup-.patch
[thirdparty/kernel/stable-queue.git] / releases / 4.16.4 / nfit-address-range-scrub-fix-scrub-in-progress-reporting.patch
1 From 78727137fdf49edf9f731bde79d7189067b4047a Mon Sep 17 00:00:00 2001
2 From: Dan Williams <dan.j.williams@intel.com>
3 Date: Mon, 2 Apr 2018 16:40:04 -0700
4 Subject: nfit, address-range-scrub: fix scrub in-progress reporting
5
6 From: Dan Williams <dan.j.williams@intel.com>
7
8 commit 78727137fdf49edf9f731bde79d7189067b4047a upstream.
9
10 There is a small window whereby ARS scan requests can schedule work that
11 userspace will miss when polling scrub_show. Hold the init_mutex lock
12 over calls to report the status to close this potential escape. Also,
13 make sure that requests to cancel the ARS workqueue are treated as an
14 idle event.
15
16 Cc: <stable@vger.kernel.org>
17 Cc: Vishal Verma <vishal.l.verma@intel.com>
18 Fixes: 37b137ff8c83 ("nfit, libnvdimm: allow an ARS scrub...")
19 Reviewed-by: Dave Jiang <dave.jiang@intel.com>
20 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 drivers/acpi/nfit/core.c | 5 ++++-
25 1 file changed, 4 insertions(+), 1 deletion(-)
26
27 --- a/drivers/acpi/nfit/core.c
28 +++ b/drivers/acpi/nfit/core.c
29 @@ -1250,8 +1250,11 @@ static ssize_t scrub_show(struct device
30 if (nd_desc) {
31 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc);
32
33 + mutex_lock(&acpi_desc->init_mutex);
34 rc = sprintf(buf, "%d%s", acpi_desc->scrub_count,
35 - (work_busy(&acpi_desc->work)) ? "+\n" : "\n");
36 + work_busy(&acpi_desc->work)
37 + && !acpi_desc->cancel ? "+\n" : "\n");
38 + mutex_unlock(&acpi_desc->init_mutex);
39 }
40 device_unlock(dev);
41 return rc;