Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2422099rdh; Sun, 29 Oct 2023 15:55:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMiaxQ+hQ19cOhzlvKnhNblfh7U+FLqPI2u0n6TDwmMfLJBSVf/0J9pc2hi71F8UjVQDYW X-Received: by 2002:a05:6870:2328:b0:1ea:14eb:b741 with SMTP id w40-20020a056870232800b001ea14ebb741mr11285351oao.54.1698620114262; Sun, 29 Oct 2023 15:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698620114; cv=none; d=google.com; s=arc-20160816; b=syS3veOki25t5JJMBudiAtafpSxGR7mUstlDL5rT8rdAcxdzqnJhvqLl0K1oC1O1Rm 5dtwNMlPu9KpdssPRktr9xGW9Kfa/Zi+OzA8aSf2SpKmfK4vU4Qyn9iGv1pTlK7VI1r9 yzg4zksmi165olRXxwGLs8GzqIno0D+Qs2fjNroHqmCVCF9Spm2eLeeUo6mJzbb1HydE 4rwtivwxVJ3I06xJMlXOhAHrGo7uxckJu7OpIlxAfZNoSrAw9Vv3vdPeKaS8ooaJo1RH Ic18dPo48q7s9hPjP4jWBHWVuXjz+MytOlLhcM/LTD5kQVQQi0zsVZPIeZ3EhspyuTrN PMdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z/QNDV8TUbSeWgG8Lbsd0SM1Lnm7ZBj/MWFgodTjrcs=; fh=V0eNv01MBtODZjk15GHG4l90Uu2jB9GtDb+f66NNc60=; b=OGwcSo8rrxbowYYSXRqvvqzqqnKLZj78c6np29U6OhTQ9iXbshvEJ2R4/sFQstwsmB Fuz7x/w4EmVTbBuz4FIVWgahtjDj8Gq4two1TKwdowF1NRnkQefxj6WvVqTdIZ0M2hwB wTW3Ohk08+8yq/J/xadOBcgvjjWY9QF2rooCnWW6HQCrwUi7uL/u8SnqiDNbnD2awzTX 9olN1OX9ytrEpwIcnU65GeH9cxYqV+ZPVLuX1vPx45AaxAGF94WEzA0SZigM5JM0waKa D8tyA3OJXd3FKqSAtQe9ylxawePIWEtcFXsMfJOEqPU0QzeIm59AIxNjQ8awYk4b+DUb 4N6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Uk2b7+T0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u185-20020a6385c2000000b005b902b61cbcsi2152560pgd.723.2023.10.29.15.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 15:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Uk2b7+T0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0F889804C6F9; Sun, 29 Oct 2023 15:55:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbjJ2WzI (ORCPT + 99 others); Sun, 29 Oct 2023 18:55:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbjJ2Wy5 (ORCPT ); Sun, 29 Oct 2023 18:54:57 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A10C8C2; Sun, 29 Oct 2023 15:54:54 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51A9EC433C7; Sun, 29 Oct 2023 22:54:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698620094; bh=JmAbRc2bNxm64mujRiq0keRT7xLH5Et6Oi008/fCrMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uk2b7+T0ZHuBUzg8n82ML5+LpQ+NP5wQWAto2jtDrC16lccXU8QCho1sOU4o8EF65 8yg6otrLkHz+zh0DYeYmz1zpxC2+MJ1Ll+v9Lxxiu8CwUNN7+yQXFp9FRUTmnDOIVh BunkXxhsAHceajUiQCEdfInMXgRCqJelRII15ExapHijjw7HTaCuPj2iSKdPsYyhF6 giIz6Q91aitFsiwH2pzvqm3UpQFoHLYaKk2L935QR+kUhAwdJxCUNm/niEZTz0HFgG iaIWyRS8zrxyuBlZ59rIOhcxyf7u+i3sQSdCLkAo4clQfogqHdaAO93iP7AU8/UF1N vFJylDSc8kF+g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Konstantin Komarov , syzbot+e94d98936a0ed08bde43@syzkaller.appspotmail.com, Sasha Levin , ntfs3@lists.linux.dev Subject: [PATCH AUTOSEL 6.5 06/52] fs/ntfs3: fix deadlock in mark_as_free_ex Date: Sun, 29 Oct 2023 18:52:53 -0400 Message-ID: <20231029225441.789781-6-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231029225441.789781-1-sashal@kernel.org> References: <20231029225441.789781-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.9 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 29 Oct 2023 15:55:13 -0700 (PDT) From: Konstantin Komarov [ Upstream commit bfbe5b31caa74ab97f1784fe9ade5f45e0d3de91 ] Reported-by: syzbot+e94d98936a0ed08bde43@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/fsntfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index edb51dc12f65f..fbfe21dbb4259 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; 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); } /* -- 2.42.0