Received: by 10.192.165.148 with SMTP id m20csp2434145imm; Sun, 22 Apr 2018 07:03:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+dMMlVrBfJiYgS0R7IhDpugEQNC47azgCvTEwGvVYYkqJX6GlbbqfHyd+R+cbMByK2sRI7 X-Received: by 10.99.163.77 with SMTP id v13mr9950488pgn.224.1524405782173; Sun, 22 Apr 2018 07:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405782; cv=none; d=google.com; s=arc-20160816; b=nU3piJIfiNmIRbWtv/bpfh2cZ68qnBo4oD5HKKbUdrTbz1JaniVeTX25h+wx1Y093D a5Pk/uzGVBMBDKAwHg3HGvatNzo5sMo4AZ9IiFFd2hu5PMR+/iCO0H0P/+seetGssJy7 VwPtxBgquZKumLRQHRHGzYxLCuCGZ5g6fU2ZvRF0u6hZ3JQ06YjzBSAds2Kd+3xOgvwQ ElmznBNlIVRhZi7NfRrFTPHRVNhndQsUsjY8KDzNu3/uDzpSHmoGuuNbGnPTfoD7n0uR 2OXoe4H3mjCpscZ7B8Ng8RyYJadk70slCjqnJJMDagypSz5n5bsh4tudPFLz+C3XjRyb lBdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wRYzQQl5MLQ8vYo0OGvc/zPXNfb7tOB22JF1lxKOZx8=; b=o3vWPjSkKPoAM2YqD0Ax8a5UVwJ5GBejvhZNYFMEGGOoh6xb+b9achusxdk4tZkXS7 fh7tgopy5lp3XcZxzlEMi0vXY/FD9xH3ETy0ZK5fMRtB4uLCr7jVt4OUa9jAgUBFqc/Y W3gxo1562e5rdVu8LexOdivWDB1vC7fF+aH7sqlOm+esWzcYa1YWH34CF2D0ppw/oEmz hPWIpcQ1IPJ1HXPndxe7P/by6T3EEBbx1hOYeMdST3w+i/1BBTCV07qeahz7V3Vhv/uw eKdpBFi/VSYKSSWEnfD1KgIfV1ejPVDGVoO7Rgl9CcWWkKSrAJGOHoNKd6/Y+MqME5Kn nkPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13-v6si9990671pll.416.2018.04.22.07.02.48; Sun, 22 Apr 2018 07:03:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754750AbeDVOBo (ORCPT + 99 others); Sun, 22 Apr 2018 10:01:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48002 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754729AbeDVOBe (ORCPT ); Sun, 22 Apr 2018 10:01:34 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 23C2DC98; Sun, 22 Apr 2018 14:01:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vishal Verma , Dave Jiang , Dan Williams Subject: [PATCH 4.16 125/196] nfit, address-range-scrub: fix scrub in-progress reporting Date: Sun, 22 Apr 2018 15:52:25 +0200 Message-Id: <20180422135110.720196794@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams commit 78727137fdf49edf9f731bde79d7189067b4047a upstream. There is a small window whereby ARS scan requests can schedule work that userspace will miss when polling scrub_show. Hold the init_mutex lock over calls to report the status to close this potential escape. Also, make sure that requests to cancel the ARS workqueue are treated as an idle event. Cc: Cc: Vishal Verma Fixes: 37b137ff8c83 ("nfit, libnvdimm: allow an ARS scrub...") Reviewed-by: Dave Jiang Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/nfit/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1250,8 +1250,11 @@ static ssize_t scrub_show(struct device if (nd_desc) { struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); + mutex_lock(&acpi_desc->init_mutex); rc = sprintf(buf, "%d%s", acpi_desc->scrub_count, - (work_busy(&acpi_desc->work)) ? "+\n" : "\n"); + work_busy(&acpi_desc->work) + && !acpi_desc->cancel ? "+\n" : "\n"); + mutex_unlock(&acpi_desc->init_mutex); } device_unlock(dev); return rc;