From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796363715; b=JKFzVDR+aAbH05P5uQJlQKXXYy0qorFSZztV3zQhyjTu5bIRY8RVFaml0bp9EPrd7eoq Z+oAIrweX+YrKKD9pyanGAAweqEmJqQMfCM930AJ7WgPxhRv/wZxjCABYP1ZbFZcsr4h0 wRtB9Mw8N+h7Q6clWALIHltwIy8l7MyGIu3Xw/czY8ZrWd47/dQfWTkeKUmMMPQ4/JM7O P7h16AHk2gqnTRUMw7yGDM56ySowvKZ7HUpOGyZHzmLw0npZ3x0xFYOFjcogzmS9rsaZt wmFudQeGtR/74gvsyfu944BFtvgoTyrFXinzZATnh0h1Mj9TUnFH+dyJHv792LI1FWw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796363715; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=CdKD52Tji8NKNvh/ye2izToehYW4tXxsr+fKelJWwkg=; b=IhCHIuiHwDbRynpWzHa3UI1QEYmaQIMBAqI5pVckg+b9deiCZT6radEnIprcnieoAIIv 2sC8E93wBworwmgDaiBiXlXgF8vHIS8OoYm93vNgwynHCjx+d0G2bXWfVETTP2SB3IH5P tdC1WEPjdPh7uU7InFdRyafoRBjlIOqgGAgR/UaXSR2LLLlYJyC8PQ4LyuX+pnGpfcJ9H b76vOlBLkxuuSPwhA5PHXwO9I7x3TT1JayM02QWgW2VG50dHHvr56pLwa/mARpp4aaGF8 4D9YVwD2S4sgTg+9s1obPSmHAAZ4dLrYUnPONs8dqAJyOKs8yqI6uJvj10GXtrOEClQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tpflKLYG; arc=none smtp.remote-ip=209.85.216.52 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0C9B606A32C for ; Fri, 4 Dec 2026 05:55:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F0C9B606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tpflKLYG Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-3b3a42a4bcdso310431a91.0 for ; Thu, 03 Dec 2026 21:55:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796363714; x=1796968514; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=CdKD52Tji8NKNvh/ye2izToehYW4tXxsr+fKelJWwkg=; b=tpflKLYG1LzJqUHjWPMEyERkGWHdDxw3lK3i0MMFEaeub4xQXV9BKevqNQXjngNENt FnbpMso1dsEivTx+h9i3gwLB68dx3qkbnQV7A8+TueDY+fjlvrR7qnDAiosLwmf1UHDI 5OU+3uxNk4DOwUbQ5FURgd0A+TVwt81wIwylCrDNanbf+QEtKBtxCFaZ54mdzI9zRf2x bmk4xxyhUlZ+pXZ7nP7NgaQKdF3RwfQGfhWfSBCZLYYKORHkDXhVzB8x3SNBr8F+JScT UMIzVvHF0MnWx4uLHXyUcf22PcQF9aw9YrLPNdfatLRLwAbJYWgmninSO4oA6hSNjskR 7hHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796363714; x=1796968514; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CdKD52Tji8NKNvh/ye2izToehYW4tXxsr+fKelJWwkg=; b=AyLb6HLINSztnPkAliE730gfSP8ky3ZKFkgg7hZRAdyi3G+11cLbHA94MmB3WB/ygV FYbUp5Sa9s689qL1eNMkxGH0Qrz6Xn6ZmSgn85ya+FlqMBoz9dw+8eZ+u6JQ7ONKVga0 dOJEle6Sn410g5cntRyh3jvg+GFoOYzrSr0R/NkmdOEgiBi7d3FUZn/nWE+3hdsQrIIH xK5pyCuSCEoTDsIOAtK7bBrjKnkXgEdyGxI4BAFzSKNVwgPQnli9biyk5S03NSVo1SzA Tfr+jlFs1wZy4wJYuxcmRZWkm0qSporO32B+992qGSnr7nbo+5tVj5/epKdPUu54m/uB HfzQ== X-Forwarded-Encrypted: i=1; AL+hErEiAw63+w9xd/oa5vHm9RW2ygtpdA0FMd5/8HexD2OI1LR8wsCHyCLGkPzw+6/+fWbPakbmOpQ=@vger.kernel.org X-Gm-Message-State: APuU4Z/fu4SjZ8DucsGQFeDvncPwr9f3aaPECWN0rMxsezkZ46/6HPBX 07iUbADx67sP7E7kEIHATmXqvHazKTVv/+F7hgkh5oRcKyq4yV/HXSpH X-Gm-Gg: AZFdTZcjt905OtTwo/goQeYLuR2Y3x5m3DxWfXVKmrfCEN/Aj15SeIOSZag0QO+offP yEM/xFnWfsDK0NtuUiviFFjiD04SCJVYsIZKyHR/tMO9gcKphSwXg+NOda61GXqbwgtArqbbXmZ 4/0IOA+nRiO9kbHgNJGPYRStIuL0UzRxlUMAVZF5s7wQjdGtji/aWkzbzbnJAhrupiYUWJlDuvL Fw7N8+6EQfMryNN3w+ofAzkT0byhr0EPzzqplJVRMHPsbI30+NLu6jgqwgSq5pU+PL/I+ydyGYP EaDEryB67SL2OW9Qez9pTOanc1JXTHoldavmUY4NsupY1gHDaYdAId/2++1X1F/5T0oehOoCjLx WAmUczX0c34UoSnkaXQ7M9CeqWfoXt/Q3SX/TAACZeLxD6Hw/UJlyeGzYfLJN5rrGxkQJc1y1Ug lhIi5fI2qk5F+lNFHe/avCbVPSSmOl6XJ1tXnGgRF3QVcVSYnZPYzenUeRferbHUxEsa5UieqGP QiolXbZgZXJtglGiZDzDZvbHdxYFO5+z6QuQudWXPDXCgKHUY5PJ3GlZvMkFWRd8zts3j3R3b5R nf+te4KofRBOfg4Rb81MxCQUyJkpNnK6O4tl44Hv0/ezAlQ/qcnGUKzCfpV01XPAMstte+bvQF7 nvU1nS8Bz6YG0wUn+ X-Received: by 2002:a17:90b:28cd:b0:3b4:f23:43f8 with SMTP id 98e67ed59e1d1-3b5e063db66mr703104a91.20.1796363714250; Thu, 03 Dec 2026 21:55:14 -0800 (PST) Received: from hyunchul-PC02.lge.net ([27.122.242.71]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5ddc16c86sm2094802a91.4.2026.12.03.21.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 21:55:13 -0800 (PST) From: Hyunchul Lee To: Namjae Jeon Cc: Hyunchul Lee , Baolin Liu , ntfs@lists.linux.dev, stable@vger.kernel.org Subject: [PATCH 1/4] ntfs: validate phrase output before advancing Date: Fri, 4 Dec 2026 14:54:39 +0900 Message-ID: <20261204055442.3619912-1-hyc.lee@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The LZNT1 phrase-token path advanced *dest_ofs before checking that the result fit in the current sub-block. On malformed input, ntfs_decompress() therefore returned with the caller's cur_ofs beyond the failed sub-block even though no phrase bytes had been copied. Check the phrase length against the sub-block bound first, copy it, and update *dest_ofs only after the copy succeeds, so a failure never leaves the destination position past the failed sub-block. Fixes: 1e9ea7e04472 ("Revert "fs: Remove NTFS classic"") Cc: stable@vger.kernel.org Signed-off-by: Hyunchul Lee --- fs/ntfs/compress.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c index 2f11206b7428..86381ca2b878 100644 --- a/fs/ntfs/compress.c +++ b/fs/ntfs/compress.c @@ -408,9 +408,8 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[], /* Now calculate the length of the byte sequence. */ length = (pt & (0xfff >> lg)) + 3; - /* Advance destination position and verify it is in range. */ - *dest_ofs += length; - if (*dest_ofs > do_sb_end) + /* Verify destination is in range. */ + if (*dest_ofs + length > do_sb_end) goto return_overflow; /* The number of non-overlapping bytes. */ @@ -432,11 +431,14 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[], memcpy(dp_addr, dp_back_addr, max_non_overlap); dp_addr += max_non_overlap; dp_back_addr += max_non_overlap; - length -= max_non_overlap; - while (length--) + i = length - max_non_overlap; + while (i--) *dp_addr++ = *dp_back_addr++; } + /* Advance destination offset after the copy succeeds. */ + *dest_ofs += length; + /* Advance source position and continue with the next token. */ cb += 2; } -- 2.43.0