From patchwork Mon Jul 3 07:27:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 115209 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp353844vqx; Mon, 3 Jul 2023 00:56:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlGA/Kbx4gYAcceRD/PkPRQLn95jJTjz24pK728KinjNR5RFAnd6umVMqswRROVPQbe7LonY X-Received: by 2002:a17:902:c9c5:b0:1b8:50a9:6874 with SMTP id q5-20020a170902c9c500b001b850a96874mr9618721pld.5.1688370965782; Mon, 03 Jul 2023 00:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688370965; cv=none; d=google.com; s=arc-20160816; b=hv1rMy8M7VUbeWorVg16yaaqkJ2cpQ9yQctHTwo1cgRcASeQFHFwp1x19IZ0wxOo7/ CMyFBqtdL/ielCAZ0fM+uN9uv/0riM+U0zKJVQtk8AzjM6zkoxvADNVYaK22JEQ+zVhm VF+LiidPewZ50OZzPSQBOJroyzX02ZkCqar3ahKMn3y7P9u6UcA3bZT065bkkxa4eBQ3 JfQAu43iHoon9yZTOgrfhM6IXFg2mUjpSZy/EiQeiLYvpuFKUy9uPyKeg5KJTPj+Vuxk eVLEMDve0OVj3UdmdCNEOqifI6yMb9CvhnrM7Qi7T2GReJoJXvm1HsLFqM8Zk5CxIKBU NSdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=q5eMVDMl8OohS/5+a1OTXjwPDE7CVMtEf2hDSqPpYdc=; fh=+YFVdCJq57+piIgB3kUO3LUIuYykw/jnC0zhAUs0Z14=; b=OYIBzYOMoke1ei+BDipE7M0dCDxROtqASctUNgby0K9iep4k7FaKw83VZI+Mdeqtcs V5UrG/QYsG6iRWoNkKybKfWosFlF6wCyCFb4hGcAOIBra57mjtcCvY9HS7ixsEDP7WIz TKmj/0mCyhOajHQvOLX9FLoHC8jNg3nw6+NGT0GNsIWEk52C+P9rjDrNHl6hLBDyjcWK s9rEoDbDiffpQkX4ldR9vmpuuAOlnc08Oped4ejqvCoQCSWDoQNrJwJEpFgNLwk2T8tc cNvBOnbMzJa3L+sInd66O3QTJS11Z4GSxwlxUgi7e0TKuHWTsGNnsCW+GQYItKIN/Zcr HabA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=RjkVAo7N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id im16-20020a170902bb1000b001b03bacdc9dsi5322107plb.343.2023.07.03.00.55.52; Mon, 03 Jul 2023 00:56:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=RjkVAo7N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229854AbjGCH2C (ORCPT + 99 others); Mon, 3 Jul 2023 03:28:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230476AbjGCH17 (ORCPT ); Mon, 3 Jul 2023 03:27:59 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3A58E58; Mon, 3 Jul 2023 00:27:55 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 3066D1D21; Mon, 3 Jul 2023 07:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1688368962; bh=q5eMVDMl8OohS/5+a1OTXjwPDE7CVMtEf2hDSqPpYdc=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=RjkVAo7NwjKBmWEMvIlJsB79izFMwGHGw2m5t2MLac2t2fLRc9GuLr0ri2b88NDIf hH8hwrRf88DIOVYe57oacRxXKLbO4OITZPNsbEmre3dkirQEhKAP3ewdj6gXk1mvGs 1W4Yk/9Wnnl1BzrR4wVnCieGQvtG1qTiiZLXRwIg= Received: from [192.168.211.138] (192.168.211.138) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 3 Jul 2023 10:27:53 +0300 Message-ID: <23596b4e-1a38-d944-3bba-de7d528c7bf6@paragon-software.com> Date: Mon, 3 Jul 2023 11:27:52 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: [PATCH 7/8] fs/ntfs3: fix deadlock in mark_as_free_ex Content-Language: en-US From: Konstantin Komarov To: CC: Linux Kernel Mailing List , References: In-Reply-To: X-Originating-IP: [192.168.211.138] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770385273690131416?= X-GMAIL-MSGID: =?utf-8?q?1770385273690131416?= Reported-by: syzbot+e94d98936a0ed08bde43@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov ---  fs/ntfs3/fsntfs.c | 6 +++++-  1 file changed, 5 insertions(+), 1 deletion(-)          len = 0; @@ -2511,6 +2513,8 @@ void mark_as_free_ex(struct ntfs_sb_info *sbi, CLST lcn, CLST len, bool trim)  out:      up_write(&wnd->rw_lock); +    if (dirty) +        ntfs_set_state(sbi, NTFS_DIRTY_ERROR);  }  /* diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index edb51dc12f65..fbfe21dbb425 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -2454,10 +2454,12 @@ void mark_as_free_ex(struct ntfs_sb_info *sbi, CLST lcn, CLST len, bool trim)  {      CLST end, i, zone_len, zlen;      struct wnd_bitmap *wnd = &sbi->used.bitmap; +    bool dirty = false;      down_write_nested(&wnd->rw_lock, BITMAP_MUTEX_CLUSTERS);      if (!wnd_is_used(wnd, lcn, len)) { -        ntfs_set_state(sbi, NTFS_DIRTY_ERROR); +        /* mark volume as dirty out of wnd->rw_lock */ +        dirty = true;          end = lcn + len;