From nobody Fri Dec 19 21:14:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5F9515B122; Wed, 29 May 2024 06:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716964885; cv=none; b=CNBmiSGO/p51HyycJzSfmp9NZOKt9P2p+nxTFT1gsHBNp/N1DMMGBTgWrOep8fSZqeZhshpTfFLKDhvkZLFOpAo9z4c/BhvMfCpLV3tcjX/M3JJ+Bo0+3DiFw2YwzodPbmy2PCCv5xCpcqZ1L5w89SoTjrsDsNF0wcWG7+Itfwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716964885; c=relaxed/simple; bh=0r2mHDCnif4N/loTjLL5nW+YIJx3eDj/rTX/Zdpzf9E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nSRcMX4dr9ed1LeQBper8LjoG/CJPpgqnr8GvJM4LYQjZZxXzZgJoQui0CuZkScDUs7Wb47SFrZPlXJdBO+/6Gzehk+eko8SuxKclBaC1vG5pmIJMBhVb3+DdTBSNvtVjx46s/imE0fCdq+GxohQ9hZXnZJq96NoN6eE2tE2NrI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B7C0C2BD10; Wed, 29 May 2024 06:41:23 +0000 (UTC) From: Huacai Chen To: Konstantin Komarov Cc: Huacai Chen , ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, Huacai Chen , stable@vger.kernel.org Subject: [PATCH 1/2] fs/ntfs3: Update log->page_{mask,bits} if log->page_size changed Date: Wed, 29 May 2024 14:40:52 +0800 Message-ID: <20240529064053.2741996-2-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529064053.2741996-1-chenhuacai@loongson.cn> References: <20240529064053.2741996-1-chenhuacai@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If an NTFS file system is mounted to another system with different PAGE_SIZE from the original system, log->page_size will change in log_replay(), but log->page_{mask,bits} don't change correspondingly. This will cause a panic because "u32 bytes =3D log->page_size - page_off" will get a negative value in the later read_log_page(). Cc: stable@vger.kernel.org Fixes: b46acd6a6a627d876898e ("fs/ntfs3: Add NTFS journal") Signed-off-by: Huacai Chen --- fs/ntfs3/fslog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index 855519713bf7..19c448093df7 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -3914,6 +3914,9 @@ int log_replay(struct ntfs_inode *ni, bool *initializ= ed) goto out; } =20 + log->page_mask =3D log->page_size - 1; + log->page_bits =3D blksize_bits(log->page_size); + /* If the file size has shrunk then we won't mount it. */ if (log->l_size < le64_to_cpu(ra2->l_size)) { err =3D -EINVAL; --=20 2.43.0