Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp739209yba; Sat, 4 May 2019 11:41:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh/PRdR3xTFKceH53zVIpKclw1uE3igZwFI/ytwWqxTKjwEbksFHo+d7KDqx8bnYETNxrX X-Received: by 2002:a63:e406:: with SMTP id a6mr20961720pgi.132.1556995262048; Sat, 04 May 2019 11:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556995262; cv=none; d=google.com; s=arc-20160816; b=Ik31ovua3PopGpyaEevOGkHq1Z8n4dhDa6CjYSz1D6qqWF6WmdklM4mkZ2lguXd0Og o0CIot+LK0PxEpoaVtgL4x8mlszZxt+ocAHlC0U8M+WoKWIphtGp7zVRxPsY4f/VuwF6 o5Wp55S3YybQU1T/CUwUD0GDeQFrmPELpAlSXQpm2MqmB7La9Xh+4jNf1Zftl75oBS5g 0hmd+dQGYdYt1PS+smRejDu2+YDQ3VzGie+oaj3zGzG3+L1wI/PRa0Cny1aySDT/GM/e Yr+7EuDppKsqnPupQbJ1pN5oq3Hn+Z7IBZ9gOYDUGizmWIIOG4m75NYVyWPNCUPhmtSD 3cNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5O6MLyuJzTZCFkCSq5yloQt0fdGoVw3zgENohA8hO08=; b=ATpSE9B8gniuF6UFLSmbFPM/ZWs0qIL1jJ1dJJwKfHkX+d0XhtYdE0XaGvvg7PTI3R u/2kFqRr7kawBiiMEvglukwk63lrjrz4p3eo6UpOjR1hv9p45Z5twlHJe4pAL1URMK6o 9v8ipQy6XYcGJYcBOHRz9Am/lWeFk3BX3DiZLyup1XJON7OEvNPTFHxvnel1PBwPKlNY LxbMT03lNHPEJqMomLH2FD6RYXIdlaU0r7ZC+QGdJyx+b716Bbp0lpPO07kTUXsgCfj9 Czn5kxGn1m7IeqWr4dA4sm+5HMhnqiDIPz7AYxhN7L462cQL5kb3vJLjWRTiRE13JGiv kmwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=Nbwf3XKw; 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 j10si8418597plb.346.2019.05.04.11.40.47; Sat, 04 May 2019 11:41: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; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=Nbwf3XKw; 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 S1727512AbfEDSiv (ORCPT + 99 others); Sat, 4 May 2019 14:38:51 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40304 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727244AbfEDSik (ORCPT ); Sat, 4 May 2019 14:38:40 -0400 Received: by mail-lj1-f195.google.com with SMTP id d15so7847814ljc.7 for ; Sat, 04 May 2019 11:38:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5O6MLyuJzTZCFkCSq5yloQt0fdGoVw3zgENohA8hO08=; b=Nbwf3XKwBmJoTj14dk59ALfYH+iU3xwyWgEGC+X7Ci+hsaGlkaVIlZgpOcGhqqR8xe C+fkUeJAEeOWFsrtujSTwNLkxdcZOdeffxyPNAtHHdTGfsudMB7xVpkaiacGaaaUP/ZO f2/jpfMkyv/FjymZbTk3WMj96GfndLQGfKeGP+8Ke5sWPPlEYOW6JpGouslht/hImfm+ NExUJyFd7A06vSvOQ9YbxDUUfwzSYNTTnCsRebIZG3/xrqbT6sjH3rgDUNwMHdVCJwUT bMDyeudN8TEfx5hebgcy+N1SgFwBIYoGSkneT/D5YnwyXW59mPDdfAtn5eMEt0pwU+Cz SU1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5O6MLyuJzTZCFkCSq5yloQt0fdGoVw3zgENohA8hO08=; b=aMy1yrmO9Bnzpz+akERuAYCjHqQ08SA8lfxSkvOOlT1kqPHBqCT00m1D++oXmWSN+u hQ5lkrPbrSetFdAaGTilldJ0JfO17Mu8cJNe5XQ1bGl2Na8C0FMuoxlfVlb12Hmkpcj0 juJxl6q0vqCVE68j9xDXdZgFq0AyNIeyV2liOucldzBMEcocc23+Fu8I2Ce05EI2g/sA 9cxViNOD8IB+X1h56HSWs/1HtVzbulqkaSXvbBGAvDbMpA+XKrrBuhcOPBpMIY5sYEhH zycyYO7puJll980EwL/7C2ykdNiN/yn0YbpQySQtMVSPqpz0d7pC1CZCtDDj7X+StObG GXmg== X-Gm-Message-State: APjAAAX/UM9ojl/eUlW0Aa2sezvseWJSOaSVX0pHRTQ8r/8ArehkYQIu uV4JQtSxZ0ZSeAhcs+mCBI4AEg== X-Received: by 2002:a2e:97c1:: with SMTP id m1mr2669190ljj.59.1556995118365; Sat, 04 May 2019 11:38:38 -0700 (PDT) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id q21sm1050260lfa.84.2019.05.04.11.38.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 May 2019 11:38:37 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Marcin Dziegielewski , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 13/26] lightnvm: prevent race condition on pblk remove Date: Sat, 4 May 2019 20:37:58 +0200 Message-Id: <20190504183811.18725-14-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190504183811.18725-1-mb@lightnvm.io> References: <20190504183811.18725-1-mb@lightnvm.io> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marcin Dziegielewski When we trigger nvm target remove during device hot unplug, there is a probability to hit a general protection fault. This is caused by use of nvm_dev thay may be freed from another (hot unplug) thread (in the nvm_unregister function). Introduce lock in nvme_ioctl_dev_remove function to prevent this situation. Signed-off-by: Marcin Dziegielewski Reviewed-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index c01f83b8fbaf..e2abe88a139c 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -1340,11 +1340,13 @@ static long nvm_ioctl_dev_remove(struct file *file, void __user *arg) return -EINVAL; } + down_read(&nvm_lock); list_for_each_entry(dev, &nvm_devices, devices) { ret = nvm_remove_tgt(dev, &remove); if (!ret) break; } + up_read(&nvm_lock); return ret; } -- 2.19.1