From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46]) (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 AA7CA3C3450 for ; Tue, 23 Jun 2026 06:23:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782195784; cv=none; b=BzEigBZD2dHqavthShOwelLsmPPo/M951rjJYzq22PM/A/neJ6BChYzvhcZlyyHGNBtdzGeSTyBnv43YJUFU/rmllYd0vl2tk3vKzHUVw0zpDGMS6LkAjMpNbZ5zjgn01U6NOIaEZhNuThxwgpj7CZlC4ChudB43affjFrAS6N0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782195784; c=relaxed/simple; bh=h2GiLVpsi59JQOStQBTzHQuFKkm/p6zC/3WNnykOkas=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pjM7oOEgxS1/vMMPEgjhhymT62DCMMpDUDWJHjZUrokfWBsl9tJDFoT7Iror6TWM3p4Vextjh79W62qDHb0OcbwNaxN10Qc78U9W2Apqe31fL6s+giIxw1R+a/YkGaiR8mUeiMLh8jmknkR+ZWTDG7vsVtgUcFegN2iRO4IC2Z8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EgV5yEKt; arc=none smtp.client-ip=74.125.82.46 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.b="EgV5yEKt" Received: by mail-dl1-f46.google.com with SMTP id a92af1059eb24-1384ebe7a10so4937621c88.1 for ; Mon, 22 Jun 2026 23:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782195781; x=1782800581; 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=DcONxe5c96Wykb/9Kuf+4ZAJsC3OiG9uaaEBTU56N3k=; b=EgV5yEKtCPAc8jTRqjlut06T3r9Y4zn3C6lH+4HwkMc0l8/GnELuEmGlKlhLy44+bh aPj6kDPdYdAMEK4ACr0Lxg6iHmL5ns41euE0q4TjtvTarJicnPJjprJIq+vH6HCwLnTD xzisaa4LsHhkHkyQqgCfFJLLssfJmzF3h9zG/N5n31NPNlwUpjlgOc2PV8YDuKrHB3ND OU7NVkplplFX0Z84xUcVLcYExQLSTedwVXDI0INC2VyqpqnPdGD0OVK+Cw9E+Pc6OXL6 nDAq0Gutbu8b/NzO8W0tLnOdoa321At2swAAFtdXn+7obmV2RJx/kGPtS3aEsl/6Fj6e 7wRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782195781; x=1782800581; 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=DcONxe5c96Wykb/9Kuf+4ZAJsC3OiG9uaaEBTU56N3k=; b=YxDcefzcvIQMNnr56VBLzQUnsUYYFRQGrw6VaGFGIlvywBfYvNlvJGkiypK4sofLBg /WIpU6hOTkSulEi2MMdpuDuvMp3PIv7cHo72VYjgTwJ7FT+g0R+9m+CTeCP6QnUihoXb jxDL4TJEMje9ZTAGeEM7SwEcaE6grvMxcx7AMxHN1OrNREGuCEwZssgD2DCCpaW5LGRQ 7qsFnjt20CEJ2Bq5IPo+qn8EqSGlLFoLO/UqJEXM8MslihKR/va0NX6TaEKQMHiJlPSn d9E0/zK77orf6rRLpchVi8clogT66gf2nMXD8EMnyaI0/5Vlz0oqhTjSgTEr1n4LIv4A 3qtA== X-Gm-Message-State: AOJu0YxOUkZT/6uJWT8vi1IETAZwrgWlJRDYbAlmegdtttEtFtjslx4z XFzBtZBvWMssgXPqYuGJ5jcJqoTMj2TeYF9NFIwFr0+GMp5/rUItO6Uq X-Gm-Gg: AfdE7cmAQgBHLiREBemm7/XDb/NqrrA0RZ53zUzwc8r5sSNvZsMObvwQ3VKTdAX7EAe 09p85yGPoPKBg0T0QD+yLqKsKPDrbAyL+vN0yPvIiC7HD36WWoZvO8ZvBb74TysOILMZlcEPp+x dZW4P3tV9pZex71++xMJNF+elwtKLyYvbkXqAuvsgrruhsN1SCdjrnhPBXGYQodm/SVXs2y05+7 TFYQo+pJdxMTpdvKNk2ss6lqwugVVZ81hfDeX57Rswe/2O+Du28aHGKZ4zkzy/YIWSwtzO0xApM sTTqsK8uhZMo1sVE3Z8D8o68grBG/Yyl5ZMvXFOHkx1wRWIo0qXpnP+9a0e0a0m1BH0cPlKwonU OdbRO26i9mBYKfafSdojriuEMbFBcrj0/jg4i9hVBVPLM5P43AJyaAflRiTCbD2uW0/dlzasQoc q3kljwP2tXp8h0bHzZz1zc8Ln+SEQn9FuejrwHHJBKFAQJoI+slLWqA9txxA== X-Received: by 2002:a05:7022:609d:b0:12d:b993:c68f with SMTP id a92af1059eb24-139c5ce08c3mr1053598c88.4.1782195780581; Mon, 22 Jun 2026 23:23:00 -0700 (PDT) Received: from fx.tailc0aff1.ts.net ([206.206.192.132]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-139adcb7a94sm11091538c88.4.2026.06.22.23.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 23:23:00 -0700 (PDT) From: Weiming Shi To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Xiang Mei , Weiming Shi Subject: [PATCH] fs/ntfs3: fix out-of-bounds read in read_log_rec_buf() Date: Mon, 22 Jun 2026 23:22:31 -0700 Message-ID: <20260623062230.1236506-2-bestswngs@gmail.com> X-Mailer: git-send-email 2.43.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 read_log_rec_buf() copies a log record into a caller buffer starting at u32 off = lsn_to_page_off(log, lsn) + log->record_header_len; log->record_header_len (and log->data_off, used for the following pages) comes verbatim from the on-disk restart area and is only checked for 8-byte alignment in is_rst_area_valid(), so off can exceed log->page_size. "tail = log->page_size - off" then underflows and memcpy() reads past the page_size-sized buffer returned by read_log_page(), spilling adjacent slab memory into the replay buffer. This is reachable by mounting a crafted NTFS image: BUG: KASAN: slab-out-of-bounds in read_log_rec_buf+0x216/0x580 Read of size 64 at addr ffff88800a877ff8 by task exploit/127 read_log_rec_buf fs/ntfs3/fslog.c:2299 log_replay fs/ntfs3/fslog.c:4216 ntfs_loadlog_and_replay fs/ntfs3/fsntfs.c:324 ntfs_fill_super fs/ntfs3/super.c:1392 get_tree_bdev_flags fs/super.c:1694 __x64_sys_mount fs/namespace.c:4360 The buggy address is located 4088 bytes to the right of the 4096-byte region [ffff88800a876000, ffff88800a877000) Reject an in-page offset outside the current page before the copy. Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal") Assisted-by: Claude:claude-opus-4-8 Reported-by: Xiang Mei Signed-off-by: Weiming Shi --- fs/ntfs3/fslog.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index f038c799e7ac..ee413dc80d3a 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -2276,7 +2276,15 @@ static int read_log_rec_buf(struct ntfs_log *log, */ for (;;) { bool usa_error; - u32 tail = log->page_size - off; + u32 tail; + + /* off comes from the on-disk restart area; bound it. */ + if (off >= log->page_size) { + err = -EINVAL; + goto out; + } + + tail = log->page_size - off; if (tail >= data_len) tail = data_len; -- 2.43.0