Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2422438rdh; Sun, 29 Oct 2023 15:56:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSHxwxMQz0YUfrbk0PqqM+ZN+hc/FmGgb/353bRWA6x1eu6RA5f8pE8uA/q73J0vCjLqjk X-Received: by 2002:a05:6a00:248b:b0:68f:bb02:fdf with SMTP id c11-20020a056a00248b00b0068fbb020fdfmr12143941pfv.27.1698620204285; Sun, 29 Oct 2023 15:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698620204; cv=none; d=google.com; s=arc-20160816; b=SM7YoLOFkE4AieANHBC7safRFjltAAzKh+j36zej9KCqJP9FK/4ml0l4vkUKSe2GHO Ag2tghoXO4zqTA8QSKoE5BivJjRHHreaCmG+gQI3acZvztTbU0jBPVQ6tvigxo6G1cOK S+I2k3BzWsjXnI/yhN1bl70BFwxig27LpjQOc9GbYgMQ8/nM6qRkKvnK/YT6VrcPLDAy T9oG6t+e9c13D6x0LNd9TkryqAt/w1e6+1Le/W3tGsOv6TBvo3LTLw8FGnF5AtEH8s9A gzFyeZQcMx9x74/WKhEWlLO2CFggxS2arnsFbqsnSaTXpZcKlyLZHhJbudufUddILMiv ubXg== 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=CABOE3L+U41MQu12clbDOVBAWncdKuwPrI7it+KdSmg=; fh=IVcZYgopwke+Bc9cmwdOT5yAIhnLPNAsBqE9TuY8J+c=; b=pCCijXGMEJdbyuqWWO+zT4IZZdRufigcaHYNQ3/XeIb3D1rg5Tk89FIrQMZJF/aTDP qAduU0XwGa/cGHvqzziDiY1NsEJ2sr/5JD8RU+75qM9ar8U7/uNAcB3ZfIlGSMmMGusk eubIt3fx8oQ3WAyf1vN4v55kz5MyEYgamNf+VYXaTQZyYApZko4Uf+GoGymbSb2ZQifA nikE4qgVWESREOkU8dUx0589PLWWe8MnOs9QGUE9ai3LeF74tl0Q5U3gXTPhGlXNmtkx 9ZVFDQnmD9ZbHcQH8kRhZLQFHeR8rxtIWiRr0ynuJzZrianmAkPNoV/LK6bPe0ql88dD KUWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GqFjaY+H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l20-20020a056a00141400b006b9c3f8b912si4096366pfu.52.2023.10.29.15.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 15:56:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GqFjaY+H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 5366D8060501; Sun, 29 Oct 2023 15:56:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231248AbjJ2WzM (ORCPT + 99 others); Sun, 29 Oct 2023 18:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231143AbjJ2Wy7 (ORCPT ); Sun, 29 Oct 2023 18:54:59 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2263EE; Sun, 29 Oct 2023 15:54:56 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3CC2C433C8; Sun, 29 Oct 2023 22:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698620096; bh=LaarqzJZ+1g+WsV+LxIqOT4Rcludj6V/0oFfui1OCCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqFjaY+HI0yz7mAFQzuxiipHum9slGWoSglhicb9YZu8Px/HW8ZUKAPmIokA1tmmv ZZcCM0RCIkaRCpssPXCtwaXBMR+71rhMM3jKk1/Dej2IO9KaJ/wC7+Z9aWa9H03xqc 5jZT7SqYaQ1Tz53SL8HqgYaCXr1vT1fYoyptoexE1JsmeO/H02rzj3mIS0MCcQo0pW vaWhvMDAO/8m/jV9VpK7ds/QKxVRuCU/sHofzy32Ep3U/84tjlkjkakgtlECJ6NjB2 9HCrA934gDFSPvRNw6JAS8f4PYbXNaj1Su/ShIcC8KwsYvERuZwOjllU51aCwx/CSo D6FPYOA0KaPKQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Konstantin Komarov , Sasha Levin , ntfs3@lists.linux.dev Subject: [PATCH AUTOSEL 6.5 08/52] fs/ntfs3: Fix alternative boot searching Date: Sun, 29 Oct 2023 18:52:55 -0400 Message-ID: <20231029225441.789781-8-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=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Sun, 29 Oct 2023 15:56:33 -0700 (PDT) From: Konstantin Komarov [ Upstream commit dcc852e509a4cba0ac6ac734077cef260e4e0fe6 ] Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/super.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 18a8bc73b8e2d..98545060580ac 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -838,7 +838,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size, struct ntfs_sb_info *sbi = sb->s_fs_info; int err; u32 mb, gb, boot_sector_size, sct_per_clst, record_size; - u64 sectors, clusters, mlcn, mlcn2; + u64 sectors, clusters, mlcn, mlcn2, dev_size0; struct NTFS_BOOT *boot; struct buffer_head *bh; struct MFT_REC *rec; @@ -847,6 +847,9 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size, u32 boot_off = 0; const char *hint = "Primary boot"; + /* Save original dev_size. Used with alternative boot. */ + dev_size0 = dev_size; + sbi->volume.blocks = dev_size >> PAGE_SHIFT; bh = ntfs_bread(sb, 0); @@ -1079,9 +1082,9 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size, } out: - if (err == -EINVAL && !bh->b_blocknr && dev_size > PAGE_SHIFT) { + if (err == -EINVAL && !bh->b_blocknr && dev_size0 > PAGE_SHIFT) { u32 block_size = min_t(u32, sector_size, PAGE_SIZE); - u64 lbo = dev_size - sizeof(*boot); + u64 lbo = dev_size0 - sizeof(*boot); /* * Try alternative boot (last sector) @@ -1095,6 +1098,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size, boot_off = lbo & (block_size - 1); hint = "Alternative boot"; + dev_size = dev_size0; /* restore original size. */ goto check_boot; } brelse(bh); -- 2.42.0