Received: by 10.192.165.148 with SMTP id m20csp2486720imm; Sun, 22 Apr 2018 08:02:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/m1iYqcYDHvahedUBa5F90hrwg2S6nvIaYfWS+jZKrR/Sb33PYotPDg3flabmzFzDm1Qs5 X-Received: by 10.98.139.146 with SMTP id e18mr16260466pfl.60.1524409375858; Sun, 22 Apr 2018 08:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409375; cv=none; d=google.com; s=arc-20160816; b=YK8SV5qQ2DP4emqHLHQQZlzBTBzEzqeOiL6B4WtDFTHDGoubXnC0Am20CKfydPKt25 ero49FMWOMSp7Xw78HHJMoWx4tF7ugZDvsYqTdtzaoKCWVj7Vnm0ALJjY0f20a2dBDM8 t+q6KR6E+f83djv83PQySiOaTaV5yrYShOf6yBbhfa5rblqG9myRSOzfVnkOQu6BbeSl zylB3yIookXG08y7HR6pKIzDV+NA+/dvzRwIBTzLlLBKqqk13cLKIylrBdm6MkJBrrr7 1Qik//NieEvi9nnvlEmET6ygnowH4ZUoc+d3ehlBxieYhlaEcu2nKWmED7rfmL67StDJ aXFA== 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=o3u3S0WNkzGvqwFqYaZE3f8mvbkwHB3h7kDRXwZtK5E=; b=ZVh9869X4VCRBfF4wjJnTz1/U2V13NWHqQ4a3TCgwG3kuAOQlHqaziqPjmuMTKrg6/ WTHH1zu8Qij7/zsQOEpxGxyocL4Ei+qOveALn1ZHPD38qNGuK3zCt54a5BO12hFteyGy kQX1Jr8aqDbF09bk3I/pZLnDaXjfXR4HtSXK73+tEaEMcqlvfbmxIb36Zfj0lESp45mE q1UBmTMgkeWDZd7cxULz3aiMa3P18EZPgkW67eCxg7ua6BQhMuKk9m/6kTBsavputma0 4PEyQDqvuo1LYfMPPwIwoAy97Z2kiLmwsrT00P2eKjOWlO1RgGnX3r8rEzyZmqFNDmrZ 3fkQ== 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 g3-v6si10194666pld.309.2018.04.22.08.02.42; Sun, 22 Apr 2018 08:02:55 -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 S1754160AbeDVPAa (ORCPT + 99 others); Sun, 22 Apr 2018 11:00:30 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55302 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755657AbeDVOMu (ORCPT ); Sun, 22 Apr 2018 10:12:50 -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 D6303CC6; Sun, 22 Apr 2018 14:12:49 +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.9 46/95] nfit, address-range-scrub: fix scrub in-progress reporting Date: Sun, 22 Apr 2018 15:53:15 +0200 Message-Id: <20180422135212.303990436@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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.9-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 @@ -967,8 +967,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;