From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.72]) (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 1BAC83AF654 for ; Fri, 17 Apr 2026 10:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776420731; cv=none; b=uc3dpJKeCQ9cp2A5a1iR1Zyxa5K6VUOnEtXqhbKciJnnFYLGx6eJ0W/OHkFjoDOCG7LxMC6DnC9Ia4Yyf5fU52TMa/qNuMYpWET8DskKQiwGAe3HnoBkstwqSHEGtCI0Vz+V9KKIwSQFfce51ddSYf6CqPLdafjVkYY6UGUdP6Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776420731; c=relaxed/simple; bh=eZhx8553h3s+1Q6Fw1xVmu9IGK+RyUVmZ3VoFqXpGRo=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=AdxINJ4lD4amLuX3LKcD8j6EiaKVMDIZKJFeEx+QcI21nrppZOF2TSzBh5341HL4/nhLZ1jnkMdbIi5EL9kcINChvACzsHMlMR1WaEUoMeaPBv6M1nqO68pzdZI/DYwcsi2dzGkG5S2kD7WpnGLXa+pzUtaPvYVAyQaeB3MH5VM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.160.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-4240a9f9375so1058628fac.1 for ; Fri, 17 Apr 2026 03:12:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776420729; x=1777025529; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lrqXh6OWIHl5rEnAOc+2hXKEDIL8wvNbS9dgnBvQmKw=; b=mYpcFfHKDa2Bj98fDAjY9716tFcGKT4AoNAWgBVJ4n/CvRnYV60Q2w4TK/aLXseH2o q1TmjB8Fyd2OGDe6sCS4RVjgmxgstX7L7rPw4R2j1ZI+VLx2K33IY6Ds4CsRs+QeOjlA cSH49KvHj61kkUqcu12dDYZkw+sK4JfWMf/e8HbDYlYx39jrYgQ4LVqvtwo6qHa/Ol+M KEiuXOUQ7r8d1p7r9Fe/Tp96Wq5tuYtmj5v30zqpUmUXgQt+EY68J9u49ISUJxpimqDh e7kpCWYNZCKrTNTA2a537hkPK7GDGf5IcOBDcQR2QFMfANkEH2I6XNOJzlgu9gBIiWvm PwaA== X-Gm-Message-State: AOJu0Yyeqth2bAQqtmyvUZ+coJpHodbgN1++LZjmiqCDtkWrvo1qYzUS Gok2C33AnjIwkm85RydavCBOvYrL6lxgkqJQfLCOhU3FFOizwjGwH3SwIYrn0FmFDkIcaIWv3HV r6IQVLj2GIqV8hVOys5moUO2RDCzSuWbiRYUHgZ2LWZRffvrnp8RTPVp0A8M= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:99b:b0:68b:6c1d:2258 with SMTP id 006d021491bc7-69462eb9a9fmr1053791eaf.31.1776420729153; Fri, 17 Apr 2026 03:12:09 -0700 (PDT) Date: Fri, 17 Apr 2026 03:12:09 -0700 In-Reply-To: <00000000000077d29606186c5e99@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69e20779.a00a0220.1cdc.0009.GAE@google.com> Subject: Forwarded: [PATCH] ntfs3: fix array-index-out-of-bounds in decompress_lznt From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] ntfs3: fix array-index-out-of-bounds in decompress_lznt Author: tristmd@gmail.com From: Tristan Madani #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master The index correction loop in decompress_chunk() increments the index variable without checking against the s_max_off[] array size: while (unc + s_max_off[index] < up) index += 1; When a crafted NTFS image causes the decompressed output pointer (up) to advance beyond unc + s_max_off[8] (0x1000), the loop reads s_max_off[9] which is past the end of the 9-element array, triggering UBSAN: UBSAN: array-index-out-of-bounds in fs/ntfs3/lznt.c:243:16 index 9 is out of range for type 'const size_t[9]' Commit 9931122d04c6 ("fs/ntfs3: Check if more than chunk-size bytes are written") partially addressed this by adding a check for up - unc > LZNT_CHUNK_SIZE before the loop. However, this relies on the implicit invariant that LZNT_CHUNK_SIZE equals s_max_off[ARRAY_SIZE(s_max_off)-1], and the check uses strict greater-than which still allows index to reach the boundary value in edge cases with concurrent modifications to the unc_end bound. Add a direct bounds check on index within the while loop condition to make the code robust regardless of the relationship between LZNT_CHUNK_SIZE and s_max_off[] values. If index reaches the maximum, break out of the correction loop -- the entry at s_max_off[8] (0x1000) already covers the full chunk range. Found by syzbot. Reported-by: syzbot+39b2fb0f2638669008ec@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=39b2fb0f2638669008ec Fixes: 522e010b5837 ("fs/ntfs3: Add compression") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- fs/ntfs3/lznt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/lznt.c b/fs/ntfs3/lznt.c index XXXXXXX..XXXXXXX 100644 --- a/fs/ntfs3/lznt.c +++ b/fs/ntfs3/lznt.c @@ -240,7 +240,7 @@ static inline ssize_t decompress_chunk(u8 *unc, u8 *unc_end, const u8 *cmpr, if (up - unc > LZNT_CHUNK_SIZE) return -EINVAL; /* Correct index */ - while (unc + s_max_off[index] < up) + while (index < ARRAY_SIZE(s_max_off) - 1 && unc + s_max_off[index] < up) index += 1; /* Check the current flag for zero. */ -- 2.39.5