From nobody Mon Apr 6 14:57:32 2026 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.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 03C09277818 for ; Thu, 19 Mar 2026 07:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773906355; cv=none; b=sG0XBjFtb29TtIVkU//Fz3AOkmMyzZkWsUnpFPQfM88t0MWkV5XVaTtENzpokkhhDFX4eRuIlcHFv/IxsMP7la8xtWAJUjeynnUEPRAR/XGlUqrgAALQxzXrvlJiFNJvb+ly9bXbqa9YzPFovjhDP1M7dety0KFLcGKFewpbW/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773906355; c=relaxed/simple; bh=m5zxzx1Q1dodJcrmXSaZ0da3wEIPfCjTqIUZL4EbOfs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kYM1XeizaBP4dnHLz0wEk0k2hODCaVXCvQecvT8Sw28Z+t25SeZTIGMw0cxsTzv0FIc46n1ASp4MmTtuhS1ap5o8PobL8CZgYJQAYYXpstnY56jnVH0AF+h80fkjJxNerlWtmcngWntn/M1Ag3aF0kYX+FYLzlojsIqOHREdpNQ= 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=UdgM/yh6; arc=none smtp.client-ip=209.85.216.51 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="UdgM/yh6" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-35691a231a7so437411a91.3 for ; Thu, 19 Mar 2026 00:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773906353; x=1774511153; 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=BgkktIwZcoieTkoYehpJq/teLEqXNGiFmKYcoE3ZX6Q=; b=UdgM/yh6mPHLSye5qXj0Ocn8FkxZ4DvCLiII7Y9EM3wX6VmF4IRWcIiw9ZsnoHbku4 PhpS94n5eJts/zudJ6SlpEsMmPocc1bsgmUtjMN0SmN93UFDrYlU6cg99UxQePXJTyvR P2BX6T0nsV8H8yrqXhnc9dOm6wmW1dCx0vOZSkD8D4YlbFmV1/K+Pol3ogedfJXx+hQw /OH2rcWecgTpuDhmrnRodAdEKOWbfYAN2pni1YRsAdwL+WNE7y9s60bFBqYsCLQW9hML zujt34SgXo9aA18C1JNig+HTWpy47kMSGcgUY15gh194Aafgx1kQqgr/dffC/a73U0gD X9XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773906353; x=1774511153; 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=BgkktIwZcoieTkoYehpJq/teLEqXNGiFmKYcoE3ZX6Q=; b=oB0yb/dd9hkCch5pheEPkztnJLnNTUveAQHrbItcXJ0MKq5SW/zbjj4QeeOqFqKxXw 6Dfz5pOufGJo8FtkUGmo7MEt2Afz3123KT9pP4kzySsZEXweyogRfDKLzzek8E8IYB9Q xye9brAHkNlB0EfpCTulozQaPEoU8APfjxQfRXHFHOXQqnAeLNkay1O6bTPmFc0XgZkV apPx0Y3drn2pW5t/F38ZyR0f5OVWfA6uyMgAmK+QZykge+hbDLei51R/jJw4YVS/xUqB rNtrY0fXK6EDe3khoSwmo6MrCv7yH1qaRM+379e06AuYm4uQFv5ecdY5Y3yTrffu9Gko btnA== X-Forwarded-Encrypted: i=1; AJvYcCWbR5XLZqNzp9xU54NJ0UKvFhn31JB9zGLIcDqohKxUF0Mpu0HJgxG0sDW+9Qqfx6v/uAgiQVjcZxy005Y=@vger.kernel.org X-Gm-Message-State: AOJu0YwVytVt4VRjSP+hSKQHxSdy0UBh+gClWXOXVOghvGt8pD48yiD4 vNVQ900IPVIRO0bvp5G6x/+BOLhy0sslIboLG58UBXxmY5TZX4XbUhO+ X-Gm-Gg: ATEYQzxVkOYun8UpXUy3IKf4lufam5fbXtM91N/SY2td/6psTj/35/2Bn/zdD3RmV7L F6OqhEl/vOsnT8XBz7LWgmzDQg5mRb2V8/GahKCPtDtOx3DjM+a86sTMwWo/jjuSPaE4oZrB3iN wcPsBSUzrsMGs5n33vLhyjv4mV9q9HGLuQVI4Y2rd4rE/WJtmOYEHkndt3n8G3Z5kDhy9VL0Xtd yH+U5hTkcbf+/o9eZUaQCdri/gGlI1SbtlHAgOCFjuUKMIdFJyiUkOjjNmdpO6oxgj551oiXgTK 959uAn69L4xOZSZSwxbVy4KN2HA4TPDydZo/zSfMLLSCyPvrOlgeBrX0UGOnIkhHYTOcq/IuNsD qX8Ug2gwKgA1MoGiZNygovKU77aKrqlVl9oKWiUt7k4ws9sU4wNkRvTpVH1Z7vBsDe5tkimINF2 HQnumrlb+pGqXA9Arjz0OqB2HnER7VYOLRquBsUJsZ8hrNoz/NIkZZTP8ZALhH0Fu10+EbqPHeZ jU+KEA= X-Received: by 2002:a17:90b:2687:b0:35b:90e7:c451 with SMTP id 98e67ed59e1d1-35bb9e8cfa7mr5292796a91.3.1773906353304; Thu, 19 Mar 2026 00:45:53 -0700 (PDT) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:2136:a371:9567:156f]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35bc5ff6789sm1893232a91.1.2026.03.19.00.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2026 00:45:52 -0700 (PDT) From: Deepanshu Kartikey To: almaz.alexandrovich@paragon-software.com Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, Deepanshu Kartikey , syzbot+c1e9aedbd913fadad617@syzkaller.appspotmail.com, Deepanshu Kartikey Subject: [PATCH] fs/ntfs3: fix missing run load for vcn0 in attr_data_get_block_locked() Date: Thu, 19 Mar 2026 13:15:46 +0530 Message-ID: <20260319074546.1085187-1-kartikey406@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: quoted-printable Content-Type: text/plain; charset="utf-8" When a compressed or sparse attribute has its clusters frame-aligned, vcn is rounded down to the frame start using cmask, which can result in vcn !=3D vcn0. In this case, vcn and vcn0 may reside in different attribute segments. The code already handles the case where vcn is in a different segment by loading its runs before allocation. However, it fails to load runs for vcn0 when vcn0 resides in a different segment than vcn. This causes run_lookup_entry() to return SPARSE_LCN for vcn0 since its segment was never loaded into the in-memory run list, triggering the WARN_ON(1). Fix this by adding a missing check for vcn0 after the existing vcn segment check. If vcn0 falls outside the current segment range [svcn, evcn1), find and load the attribute segment containing vcn0 before performing the run lookup. The following scenario triggers the bug: attr_data_get_block_locked() vcn =3D vcn0 & cmask <- vcn !=3D vcn0 after frame alignment load runs for vcn segment <- vcn0 segment not loaded! attr_allocate_clusters() <- allocation succeeds run_lookup_entry(vcn0) <- vcn0 not in run -> SPARSE_LCN WARN_ON(1) <- bug fires here! Reported-by: syzbot+c1e9aedbd913fadad617@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dc1e9aedbd913fadad617 Fixes: c380b52f6c57 ("fs/ntfs3: Change new sparse cluster processing") Signed-off-by: Deepanshu Kartikey --- fs/ntfs3/attrib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 6cb9bc5d605c..6ef7db82a35d 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -1152,6 +1152,21 @@ int attr_data_get_block_locked(struct ntfs_inode *ni= , CLST vcn, CLST clen, if (err) goto out; } + + if (vcn0 < svcn || evcn1 <=3D vcn0) { + struct ATTRIB *attr2; + + attr2 =3D ni_find_attr(ni, attr_b, &le_b, ATTR_DATA, NULL, + 0, &vcn0, &mi); + if (!attr2) { + err =3D -EINVAL; + goto out; + } + err =3D attr_load_runs(attr2, ni, run, NULL); + if (err) + goto out; + } + da =3D false; /* no delalloc for compressed file. */ } =20 --=20 2.43.0