From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (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 198D434252C for ; Tue, 23 Jun 2026 10:14:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782209695; cv=none; b=I71PtR7H3l9eNberinK/fz114Up21bOPvysxeGztABZgke0T15w5HmlQKw81OirQGK3UCkToK2ELybZNs+y44lIYQjM+c6uSeZDHef3LOLClh+haNGipQXfGn6UvnYu0z5Y3a1V/vbxerd6dv82hKSbIc0y/11wop8oPq8V4Djs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782209695; c=relaxed/simple; bh=Q7d5IICTvnzfMseKwelv4deozHwF+eOxcRD2Mr1z6Fg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gZWbGGAzYagx9zOuaQbOk/YOMW3opvOll2PyL0CNq31t45qeSEv29JPSTH4lSJkYtc6qcJfvFKcEy4XWnO4WLMPgvbSGvpKs0clK24cANw/l5XHU4tf3vclWnFHAZQXj212hSDH0dS/uyavph4K3pCQKcNuleQiYynkBKIWXx6I= 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=f7L9oJBz; arc=none smtp.client-ip=74.125.82.170 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="f7L9oJBz" Received: by mail-dy1-f170.google.com with SMTP id 5a478bee46e88-30bf854d5feso10914434eec.0 for ; Tue, 23 Jun 2026 03:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782209693; x=1782814493; 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=ti3rFFJLDIQUrNppgFMKlOzusnp+Nk94zj1B91S2Nf8=; b=f7L9oJBzmeVfsRIOXFzXd59wDpdssnkpTBdT6ltrcrq2KRypTGOU6U+ow1zLh+n01d MiXIK3H6TjrbUHIVssS5lJMoQoAnLSDi3jlGetRPWorc8o8oo1M9ZvNaL5bl2q3P09p3 p/QeCxWWry4lPKoU893omJOIs73N+hYpPDAcM2agoECnnYIyS4dQx4HIoGX8z/i1V8sr ZDWos04xRdB8qZ9xXWse9WuLyTpgInfqWRFm+MaeygqgoE58ahIgUHCtYtaXHcldAbfl 27n18iLVhV1+D3lpMt5JLTUQbW6V+1u/UfRsPMMPvE5z9X0Yt6f1wlvoID8XIkC/x4eI dRrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782209693; x=1782814493; 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=ti3rFFJLDIQUrNppgFMKlOzusnp+Nk94zj1B91S2Nf8=; b=R5n6qhtv6ArpJ96p+C3+2KahDFj8oV1SFRdBw+kPzlJLRwFfMSFqENytlG2Mz0Cf4z uLiYrJhwoyz6t59Y5k5Sb4uDiqmaOSO2o/Z7tI0h3r8wHC6hingk5Uk+iH7US8sRa5YU CtrY/AHdCqAmq/NsjE8QZbJcDPn2yHNinz1wC6r4hljc+jGZ+uyxnNQaCux/HQ2HyZET SRtcPr/kLXrPdMVGXy2aAcFgpy5CGP8ViwYMZtbvXC/DRwktGWeoEQw5Qr6WRkShxCiB QvYNZ+ELwuo81agDQPGwRlxb6yHGFwHqC7LQDo3eKSkjVIdx923ZO+zYdkeCV7uPjq2+ vkPA== X-Forwarded-Encrypted: i=1; AHgh+Rp1Nnqax8oA0jj3Ub+kITS8ovF4tJ1VXk9cL8rdPUKY15k5HyNGoSZz40s9h+sAB1MuCJuILexmWAO1qzs=@vger.kernel.org X-Gm-Message-State: AOJu0Ywzskpc5l6BYGuSOwUsLe/Uw3qBcbo1NxubaB+Xc9jlkCldFVug 6eQdBBLMXLuBmzJ5gApD1TmP5C6vt7AFwQjsE4Nt5HBHqY2DEIfPXgU7 X-Gm-Gg: AfdE7clZw2EE9xZpMPKZCt79jluDz2zrdEZq8rJntbfY0dvWLXPnIu0DfqpFbjtAaqP IED9MZ4uAnQi3VfvmU5k5tzSdvubuc1aZWm6Is2qfS61vbwaJwOCXwLN0VOoNljpKpopNyUUY5F DOMQSrFwPWgbxsufn8fqo3eALMUfdafheInGXbF5McANUENWk5ukedLsYXPZrQF8oXF4mdqdoZ5 LnZhLhNROQl1UCuGhUjsY/oTw0HLRG3+M3oezvlbL6jhHCbFIj2FRokfs8ufdxO7XUneTWHz53n g9fNk3TA4etahHNRH/4U/O6AKYOdcsO2bLa5c2Q7f+p7Er2mLOClcmD1R44ecsac20I4W3YIleo aCXirgVAFU/GFMBQmo+/7aSjoBuACGhhZFtMpUaW7u8VGCnjRTY74+RfRPioFJ8qSZH7xO6RpZl PuIjMeCvG8d4mTD2M/i7PQIkL7vyBRiYnmfbPoVKH6u/7ePFmvCm5BKPEwOw== X-Received: by 2002:a05:7300:730c:b0:2f1:496c:94bf with SMTP id 5a478bee46e88-30c5b8d36c3mr1160460eec.16.1782209693019; Tue, 23 Jun 2026 03:14:53 -0700 (PDT) Received: from fx.tailc0aff1.ts.net ([206.206.192.132]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30c44ec51b9sm7862755eec.29.2026.06.23.03.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2026 03:14:52 -0700 (PDT) From: Weiming Shi To: ntfs3@lists.linux.dev Cc: Konstantin Komarov , Xiang Mei , linux-kernel@vger.kernel.org, Weiming Shi Subject: [PATCH] fs/ntfs3: reject restart table growth beyond U16_MAX entries Date: Tue, 23 Jun 2026 03:14:35 -0700 Message-ID: <20260623101434.1321291-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 During $LogFile replay, log_replay() indexes the transaction table by the transact_id taken from the log record header. check_log_rec() only verifies that transact_id is non-zero and properly aligned, not its magnitude, so a crafted image can request an arbitrarily large index. alloc_rsttbl_from_idx() grows the table to cover that index via extend_rsttbl(), which passes the new entry count to init_rsttbl(): rt = init_rsttbl(esize, used + add); used + add is computed as u32 but init_rsttbl() takes a u16, and the count is stored in struct RESTART_TABLE as a __le16. When used + add exceeds U16_MAX it is truncated, init_rsttbl() allocates a table far smaller than the index requires, and alloc_rsttbl_from_idx() then dereferences and writes at the original, untruncated offset -- an out-of-bounds access past the allocation, reachable by mounting a crafted NTFS image. BUG: KASAN: use-after-free in alloc_rsttbl_from_idx (fs/ntfs3/fslog.c:950) Read of size 4 at addr ffff8880327ffff8 by task exploit alloc_rsttbl_from_idx (fs/ntfs3/fslog.c:950) log_replay (fs/ntfs3/fslog.c:4562) ntfs_loadlog_and_replay (fs/ntfs3/fsntfs.c:324) ntfs_fill_super (fs/ntfs3/super.c:1393) get_tree_bdev_flags vfs_get_tree path_mount __x64_sys_mount A restart table is limited to U16_MAX entries by its __le16 count, so a larger growth request is invalid input. Reject it in extend_rsttbl(); all callers already handle a NULL return. Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal") Reported-by: Xiang Mei Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Weiming Shi --- fs/ntfs3/fslog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index f038c799e7ac..78f34442aaaa 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -853,6 +853,9 @@ static inline struct RESTART_TABLE *extend_rsttbl(struct RESTART_TABLE *tbl, u32 used = le16_to_cpu(tbl->used); struct RESTART_TABLE *rt; + if (used + add > U16_MAX) + return NULL; + rt = init_rsttbl(esize, used + add); if (!rt) return NULL; -- 2.43.0