Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp448499lqb; Tue, 28 May 2024 23:41:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9kTUyaO6FlGTu7OrQrEEmTYczJfKfJ65pWfSMmYGbU3pAIPJAEGNtWGEnyph525V8Icdh1pil+PZOOvv7W/IKt0Xh82zt7A2xjuLqmg== X-Google-Smtp-Source: AGHT+IF7J8OC5cptk3eAZIpba36TlJYUFG4IS62v8FGUsrzrJMhUlRnkh+VPCb8IKeSs4ofLaW9V X-Received: by 2002:ac8:5701:0:b0:437:7a3f:d392 with SMTP id d75a77b69052e-43fb0e70af1mr163055941cf.46.1716964900684; Tue, 28 May 2024 23:41:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716964900; cv=pass; d=google.com; s=arc-20160816; b=mbMrUwoq9gwAqgQ7d86sxPWBGuJ3AQR0jXmTdlPCHocypSAQFs19GE1jKPTbMe8Qct 4nf75WFbxFDwZF5XRdbTDI85Jsyq2vTp8qC07QJlnYImoxcmZKCRpjHsvZGX12zdCJl6 L5SXPl4lhORa0h2mExoLNq247MR6KHoQF89bshEB4P+xNwy2iJAq2AUxG8+juHgZxhI2 t1QGV2Wc4vCXjjAVkQ/0ArsY80JEU6VKCZbFa+ppJWndyfkaKYr4kjvJhqJ4p5viVCd9 Om2vw7FlvpGcmz90F1RXdcxqxY7t85WlNpCHhWdzEZE2rhqinkNBNo1Q8eXu70+B3tni SIkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=By4scENBXorQPH5T9XMAhbM4gB4lhOTAGCd5SESFLNs=; fh=QwPBkqWIYNznrk2nTKRUty9zUE+QmuYN857+KMFcYLk=; b=psoHbWhFArsCHL2JSg3xIc1zlyELE31KgMG4tucRKqtpPN4jhDkxlDUfEM0GSDhQ9+ eHPmsOgEe40I/EPIkHx0tGUI8zMd1W8lJhf6hwDQOlCEGAKkDYATh+KNkO91U49oxCsP CE/V1dQVb/stvUAyVdIIT4brmhNIIwtAS1raF+wKjiDhT247BcBVKouLLko8jNRaFqUC 8lRlPJ80wyyaKNPcL36BexIurKPhRkVorKBGO+TR9KbtSkw9+wVhSPL71KyP+ySFWLHd TUEsyVtg36k05LyXMcKWjZTFN+5DvfqnjO76AZjwZQ2j9+xKNVuDLyzuDrOTs+KgXrJp Hg7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-193528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193528-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43fb18eaacdsi132803711cf.776.2024.05.28.23.41.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 23:41:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-193528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193528-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6E0E91C256B2 for ; Wed, 29 May 2024 06:41:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50DD9161307; Wed, 29 May 2024 06:41:26 +0000 (UTC) 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: 8bit 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 = 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 *initialized) goto out; } + log->page_mask = log->page_size - 1; + log->page_bits = 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 = -EINVAL; -- 2.43.0