From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 570972874E6 for ; Sun, 7 Jun 2026 05:17:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780809460; cv=none; b=Lyb1PkClBw8PNkjKlpAyi5iuqQSjiiEjDyYtgtiBjv3OcL1nGdmvFRFKObusQuzcfL/OdbQkGNEiyHjnf1F9CMV8/vKSVPoDiTg6b5pUZWfimn3L/q94Ye9z/DHgR1ypuu4tyq5/JLR2mdgm++Wbe+0Mc6xEelSscDbPplhsvlY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780809460; c=relaxed/simple; bh=v0FBSHIKiW9lnEit+UkePQ6b37Ht1w5NjycqmlL3Ptw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ck1fYC9gjujryw/rwssey4pBigGLdZDVfptmJQ3vlDuX3TIq7ZUKA5U39/sI+0Bx0sIINrYtM4GVi2Y5s1f4QvxS7o2S1u3vKKx3Au+II/sSW9mgMCx2+hpHJNjal/yvNJAEcvXgRAyrKArQcH24JdAM/j6Vg/hDpuHGISydspU= 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=p2/UeL0z; arc=none smtp.client-ip=209.85.214.179 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="p2/UeL0z" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2bf22eab320so2964675ad.2 for ; Sat, 06 Jun 2026 22:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780809458; x=1781414258; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CI8yVfevv6ra0nY4MhczUOj4WKWNeHenXaOHU4XUI8g=; b=p2/UeL0zu6eBClSIiHJrtcajGocM4iUBmoa7boWEZhSOYSGUO4BFRqa5YkCTGxdVGX mnUH+62WNZnA+wG8U1ruadPImaM4qlvjnSSoiH9VxJMIIFZwYZv3ZeUokArwO8tkBqq0 FBWQKBpe5VytlbIYjPFVG3ueggCID/6fKZVH5FvftFB8pOMMo2gJ/0TfVg3vG9Nb8Ugm xd8LL3ZB8NzhmZzpT2p6I81F841/PRazUeAEYk0Fgj9cewv4GTOxPL2vlFZDra30lz2H i0WxoF5Z4+/sJI2VQ04xwqsMNRFO02BKVkdJ2+vlwO5fTy+ySyUeJ0KARBhlIEWM68P+ SHwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780809458; x=1781414258; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CI8yVfevv6ra0nY4MhczUOj4WKWNeHenXaOHU4XUI8g=; b=L04Y66S1WNy1nGXfNf6aqCLbQP4c4I0uIu9qgGvU60C7PQqTb9HlmwZ7SRQDVZ7v/K EXXaw5gSFUouBRuK+9D6W44FBrO67dwyq45h1kvA3IOmlYBuhntZHyovFmXvmzhrYryj /+lUCCqWWMUOxuWFdggRRmlObeU3MMi3w9dTfF+1nPhzNKGIw7KZhLXWJyghFcJ2AtxC +r4ZmsdfFK4oNzBytT4Kc5g5hVDZJxZYCBENEs4Hvstny7gCpG7tRK4LKbF+wMwEUYpj 23swXnVZLqWK6pJmViYTzFdW4Q65iRXToyqkRPTX2BeE65AQgF6dHdJu0mfGXcnkoNow 6dAw== X-Forwarded-Encrypted: i=1; AFNElJ+Y1I5enMkDtqcp8sSSrR5UJ2odL1XzugOysDs2LTgVP8pS7rNnULfIjaqiAaLbOWxWfXGP8Yi0LMFhBoQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyXySWYf7l9j2/5iJz0GPTslSG6hvmwZc3oGucr+NMbwwptBgxc giiXmA5kyQg7pNfN6PC2RAtH5T4w4/4x0swO0VfY3tIZwrU171kCYsWd X-Gm-Gg: Acq92OGeHQXX4HAD0bBJF1486vZwFtf2wKlnlUnW4KT7I/CsgDb6r2SBfDJlMFEHFmW km4T8+sKdHEdZ15q/5g+J8S4ZFvwbSay34hJFEVVmegGalmWTzP/SktZvgL2psPqmiCBmd87tco DGqvuAK6VO5xVokdf0/G0xQrfrmgfxHwYQkZeLrsGb8OI1EWLgEIHJr9fFueiLBIMazvUArPjwn 8v8VDykbRyiTHyrEolzbrKOs6lx0CAF/yuHRd8fJbSq4dszr8I6t0sW0MJjtC7w4QTNOJPI3XvT ZW/me2FOBy5oymzl2Qn/QUJaTFJlZ61Chebmr0H7Omv5fp2C1lc4RaEHpBUkQuU4Pbhlukm3aun Uids3O6HH41MzP8k0ZieRu6QX5xJMqe5TFe/xqjHkjKMAdSdISCJ5/TViYfssMapVdg9Xl2o4h/ NdZJ8S5lYPK59+e767w626pwPGtgyUWXs5JEYQKQ== X-Received: by 2002:a17:90b:538b:b0:36d:f28a:c5e2 with SMTP id 98e67ed59e1d1-370f1eec20amr5843761a91.8.1780809458553; Sat, 06 Jun 2026 22:17:38 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-842828e5638sm14494648b3a.50.2026.06.06.22.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jun 2026 22:17:38 -0700 (PDT) From: DaeMyung Kang To: Namjae Jeon , Hyunchul Lee Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH v5 4/4] ntfs: validate index root allocated_size on lookup Date: Sun, 7 Jun 2026 14:17:23 +0900 Message-ID: <20260607051723.1499833-5-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260607051723.1499833-1-charsyam@gmail.com> References: <20260607051723.1499833-1-charsyam@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The resident $INDEX_ROOT validator already checks the index root header fields, but it still does not bound index_length through allocated_size or ensure allocated_size stays within the resident index area. Callers consume index.allocated_size as the resident root capacity. ntfs_ie_add() uses it to decide whether an insertion can be done in place, and ntfs_ie_insert() then updates the root without re-checking the resident value boundary. Read allocated_size in the resident $INDEX_ROOT validator, require it to be 8-byte aligned, require index_length <= allocated_size, and require allocated_size <= the resident index area. Valid slack remains allowed. Signed-off-by: DaeMyung Kang --- fs/ntfs/attrib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index cf49eade6b22..49c8f1f3b9dd 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -657,15 +657,19 @@ static bool ntfs_index_root_attr_value_is_valid(const u8 *value, const u32 value u32 index_size; u32 entries_offset; u32 index_length; + u32 allocated_size; ir = (const struct index_root *)value; index_size = value_length - offsetof(struct index_root, index); entries_offset = le32_to_cpu(ir->index.entries_offset); index_length = le32_to_cpu(ir->index.index_length); + allocated_size = le32_to_cpu(ir->index.allocated_size); - if ((entries_offset | index_length) & 7 || + if ((entries_offset | index_length | allocated_size) & 7 || entries_offset < sizeof(struct index_header) || entries_offset > index_length || + index_length > allocated_size || + allocated_size > index_size || index_length - entries_offset < sizeof(struct index_entry_header)) return false; -- 2.43.0