From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 390102D1907 for ; Tue, 23 Jun 2026 19:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782241285; cv=none; b=eF5v8xxODyD9j5t6F/DQS89YtkEleoouTNhiCHnsnh5pfVc3st3Yp9vtwJut6B+SyJzaJldhUhoE90mNbzQbdIpWY9pGfXmm5knhknEkt+jDor4Yu2c6Kvf6IXTwAyNAX/6h79gZ2hX/p25RAOP7iuuZYQ6acCpNbuDDvOyGX6s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782241285; c=relaxed/simple; bh=4yrM/lNVgM5LIoBfkpB20Vgsf3QetxdGNQ5Zx0bQu3A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=s1svhJA7amojr4RwTzmJ+biWZUXawQFlwbssNOwCV9/lG1URhspgQIOZ5GSWpaUSy5FAhNHGpMNtvJYCf6VjlvlEFgp5w2wO58/LQiOoTUZlNrqz/tjxL82eoi44p9lINhhtbIY+K6FkHm+0vK50StPzMclFV8tUqgLPmkMjE7c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bynar.io; spf=pass smtp.mailfrom=bynar.io; dkim=pass (2048-bit key) header.d=bynar.io header.i=@bynar.io header.b=NP4U21g6; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bynar.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bynar.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bynar.io header.i=@bynar.io header.b="NP4U21g6" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-697cd68d7adso252918a12.1 for ; Tue, 23 Jun 2026 12:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bynar.io; s=google; t=1782241283; x=1782846083; 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; bh=UzaFu7BlwLWbtc/9j40eBRy8RDI637d1HOGn/0S/MlI=; b=NP4U21g6WF+birdanU8MV/opaqsYClfgP+7IFTkBAI0E2tGpXnAIuhISOZETVTOBNm pidITYATFXYU3LcAgkbCUR9Bh+IjqDl9+44Cw0tFYgYWQupj+IOW30hcdFQOER65hxlQ 4UNl41Oc/1jf1NWnVZNUOsW9kYPM9V0k/ynSMuragSj9fCBNIjVsvkxHfOQgsCcsvhS2 wNmU6vC+02wDEaahyeaV+Xh7vy7s5B9lNUv2QsDFfUG+FpCDxHHveqXeXP9JkltjAdnQ NdhWbwj4NrOTJqHXrd5CI33gX2qGdx9KvfYiLwysiBNRWCr36pmjoKYBIpxwbAv0seMR djhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782241283; x=1782846083; 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; bh=UzaFu7BlwLWbtc/9j40eBRy8RDI637d1HOGn/0S/MlI=; b=KY7rGiarORr8QsuWCsX1jIaPcgk/8//P3Udy881mk3qIyTMlr/+xiLAi8sjpZMY5eG E12arw6991XWfi3fIVSCdbmHe6CKnp1HnKZJZrBwgEQc5oex8oml4sX1UZhaIhJ08SSl 62aXZDR5vxllKYHvp1ci8vy6VmaW/x/aYvsg7SBHIXtNHn3rq9DILMun5NfFnSUJl4hv 3wX24YYphbkJrE8OFOM61WFDY4x4yRS203qB5gxEKQjGbopQEjcdKDc5awybScylVcd0 8xVyx3BAhoR8J80iRsaUENwaC2MidXW5Fpo9oLA33VgZGPb4eydupwFCMOYj3DU+DcIN 8MkA== X-Forwarded-Encrypted: i=1; AFNElJ/hFdDnxSNJ/F6HqKWnTbUpBkTi5a4LVzLkd60q82Cl/EJI3JdXymoWA76l0V3szPVRo5+KNZQ4baLaFLI=@vger.kernel.org X-Gm-Message-State: AOJu0YxL7KvbnY+PIxgI5yz2XA73uVr4K2xBJKk7BMwB5Qc/nT8d+6IH uUCrzlNv8KqjxeYvICSe3RRdxnUBhk4TcQR+p/Dv/VfM4vg8fVa270fBILodGR2cDQco1g69YiK OYPEX+Q== X-Gm-Gg: AfdE7ckGHEa27d7WDePM9oKPS9QylnWAY329SJxJHIJ3sZDnrL6yDs/+EGXR01i9f+l c5zsMHcb9SxSHEkailEx6E9u1q7fjPvPwX4dyaHrIwtBSBT2PSDDbYVo8TNlV5+Jjx/PJHRMMjR OiRXzAyM0F7v2Z4LjXuRU9MZTk7XqctZWM0L3cV4dVRQBJ89lWTQcHgz5wj12LMXt5HgvrMX5hZ cpCHyvKgyX5Fz2Vo0o19oCL5d6m8707V2X1QLDHDegB2QWE3gUGuwMvUDR2znuEpvj6CZ3hGe5w f0EKP3N+KpKo4NfNqCVMgfXKBU2ig3I37//NYAF4I7YUmG3yos1u5SZsCsOvA+TMkJj2dL5F6MS zIMofivViKdXGqPbiQ4IZcSslaQnoS8oOVXoF0YvfIuYer2Tu+ekxvcMXTlH0JTB/p+1+Jn5KP1 g34PEY84nhKxI= X-Received: by 2002:a05:6402:a50b:10b0:697:decc:7f87 with SMTP id 4fb4d7f45d1cf-697decc81a5mr1341344a12.9.1782241282426; Tue, 23 Jun 2026 12:01:22 -0700 (PDT) Received: from localhost ([2a06:61c2:d427:0:b321:1c7a:b072:326e]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-697eff91889sm20475a12.6.2026.06.23.12.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2026 12:01:21 -0700 (PDT) From: Samuel Page To: Konstantin Komarov Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] fs/ntfs3: fix info-leak on partial LZNT decompress in ni_read_frame() Date: Tue, 23 Jun 2026 21:00:57 +0200 Message-ID: <20260623190057.12351-1-sam@bynar.io> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ni_read_frame() decompresses an LZNT $DATA frame into the vmapped target pages and then trusts decompress_lznt()'s return value: unc_size = decompress_lznt(frame_ondisk, ondisk_size, frame_mem, frame_size); if ((ssize_t)unc_size < 0) err = unc_size; else if (!unc_size || unc_size > frame_size) err = -EINVAL; decompress_lznt() stops as soon as the compressed stream is exhausted (e.g. a zero chunk header) and returns the number of bytes it actually wrote, which may be far less than frame_size. The bytes between unc_size and frame_size are never written. The only memset() that follows zeroes the region beyond i_valid; when the frame lies entirely within the file's valid size that memset() does not run, so the gap retains whatever was in the just-vmapped pages. All pages are then marked uptodate and returned to userspace, disclosing uninitialized (recently-freed) kernel page memory. A crafted compressed file whose stream decompresses to only a few bytes leaks the remainder of every frame on a plain read(2), which is enough to recover kernel pointers and defeat KASLR. Zero the [unc_size, frame_size) tail immediately after a successful LZNT decompress so the remainder reads back as zero. Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") Cc: stable@vger.kernel.org Assisted-by: Bynario AI Signed-off-by: Samuel Page --- Reproduced on a non-KASAN, KASLR-enabled arm64 guest: a crafted file whose 64 KiB LZNT frames each decompress to 8 bytes leaks the [8, 65536) tail of every frame on a plain read(2) - up to ~3.3 MiB of uninitialized page memory, including kernel-text return addresses from freed VMAP_STACK pages, from which the KASLR base was recovered and verified vs /proc/kallsyms. With the patch the same read returns zeroes; a zeroed control image (valid_size truncated so the existing memset runs) leaks nothing, isolating the cause. fs/ntfs3/frecord.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 7b035da63c12..cd11df75bdbc 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -2443,6 +2443,15 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, err = unc_size; else if (!unc_size || unc_size > frame_size) err = -EINVAL; + else if (unc_size < frame_size) { + /* + * Partial decompress: zero the [unc_size, frame_size) + * tail. decompress_lznt() leaves it untouched, so + * without this the freshly vmapped pages would expose + * uninitialized kernel memory to userspace. + */ + memset(frame_mem + unc_size, 0, frame_size - unc_size); + } } if (!err && valid_size < frame_vbo + frame_size) { size_t ok = valid_size - frame_vbo; -- 2.54.0