Received: by 10.192.165.148 with SMTP id m20csp824739imm; Fri, 20 Apr 2018 17:05:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/5zxCuO3NAml5GcMCvLLB+AxhJQ4Fy0ff1OL+kPZLqGd3RT8XQTDrPGcrjIpjnx9Du8dr3 X-Received: by 2002:a17:902:5a46:: with SMTP id f6-v6mr6702067plm.85.1524269122561; Fri, 20 Apr 2018 17:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524269122; cv=none; d=google.com; s=arc-20160816; b=u9zVmLpSyRrLpqKs8KiNYmFpQcA5dsPmamoN36XmTeNjJ0eTPv8AueCPVNplfZmIvt efUGLwiU5LoyNDRcoWnDcaYJrkBWWYfM3oR1j+rpycrG/J/Gr2czp3AbzpPwjq86gYQF rqwgpqTGiU51MtTIeixYnknoUnnF9GBWkygMd3w/C1jyp5mgZVHHXP2JZLmDO0yES54w X7UasMhomD5+x08/Hj3oq9l8jUPgPUET0LfLXznU7LknRBDTMGOwi6iIsczqPopzWY93 iBM1qrS6Hqm4gH9bv4XE82v8BE0RVe1Mz9zDwyI12xnEDEUoyFJfN0QgnPq/o45aDQ3k 6LWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=p7cBRYssqc7ippvbfgxR3xsZ7R/zacnQ0ru0H1GWMmc=; b=UYhiVy9TiQrHFBW6a5kjRD0a6DFm6kg+b0AXkf4Es5nEhkSWYCkmbYHN+MKUtouJrL 8Dt8EKrNBxhba75qvMPt6Bmjsc/KJOcSQKadmL4kvfVkvMY8j+N493HcKnTjz4LEexY6 v+gB2mJmIODGdgRiBK94QoArySwMtc5knOLyc4ZLtKEXcFK5ste3RltaxNo5Jt5MUqHK kEvdq6sHyvJwnQJWalTvgL2QIk3OS3ELUpodl8Pyc7o6amz3FSTSIDtPG0fNelJPyWxq s+p6/5qNxqlnJGBnKDbpuLLe2HSQ880bJUB6mptqxQ/zblcZL8RFu/dnon7bm/FvrLF7 MXiA== 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 f59-v6si6806071plf.38.2018.04.20.17.04.45; Fri, 20 Apr 2018 17:05:22 -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 S1753130AbeDTX7q (ORCPT + 99 others); Fri, 20 Apr 2018 19:59:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:47246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752778AbeDTX7M (ORCPT ); Fri, 20 Apr 2018 19:59:12 -0400 Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 38C5821838; Fri, 20 Apr 2018 23:59:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38C5821838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mcgrof@kernel.org From: "Luis R. Rodriguez" To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org Cc: jack@suse.cz, bart.vanassche@wdc.com, ming.lei@redhat.com, rjw@rjwysocki.net, mguzik@redhat.com, linux-pm@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH 3/3] fs: fix corner case race on freeze_bdev() when sb disappears Date: Fri, 20 Apr 2018 16:59:04 -0700 Message-Id: <20180420235904.27496-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20180420235904.27496-1-mcgrof@kernel.org> References: <20180420235904.27496-1-mcgrof@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org freeze_bdev() will bail but leave the bd_fsfreeze_count incremented if the get_active_super() does not find the superblock on our super_blocks list to match. This issue has been present since v2.6.29 during the introduction of the ioctl_fsfreeze() and ioctl_fsthaw() via commit fcccf502540e3 ("filesystem freeze: implement generic freeze feature"). I am not aware of any existing races which have triggered this situation, however, if it does trigger it could mean leaving a superblock with bd_fsfreeze_count always positive. Fixes: fcccf502540e3 ("filesystem freeze: implement generic freeze feature") Signed-off-by: Luis R. Rodriguez --- fs/block_dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index b54966679833..7a532aa58c07 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -507,8 +507,10 @@ struct super_block *freeze_bdev(struct block_device *bdev) } sb = get_active_super(bdev); - if (!sb) + if (!sb) { + bdev->bd_fsfreeze_count--; goto out; + } if (sb->s_op->freeze_super) error = sb->s_op->freeze_super(sb); else -- 2.16.3