From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 655972F872 for ; Mon, 8 Jun 2026 02:01:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.167.42 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780884111; cv=pass; b=UX+ZeEKGK8YkRjBgLthG8fh/4YasqQd/l17+ZhWzunpog5Ko45gCWTSdVe3AxcDj+4a4Gb2cVqHTiuKe34OLjyQhCQFv/EQq44L2iHApegYjnhdVYSIha3zU3pplo+5QXO/OdIpfRr6NwljWRE6IAo0MqvapBs4d8X8rTIfHOgg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780884111; c=relaxed/simple; bh=2AqziK+qsyowJ2tzEBehA0XQh0T9AiwqQCYEVrUIktg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XqigeS3to/+87Am4RsZxm7w7Ez7DrXpLOUEJb+5fiT0qSkoKB2AHag4+9vuV8QoID5yQ2O4xihqIZlJrwmqeZqeDk4tHo6H/MQoqIWkad4luHf2YVYT2GlTu7zp/7jXaCZTFHLQ6qQI3Hf3l3RsSlnrcODMzLE1UtVda9I05mMc= ARC-Authentication-Results:i=2; 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=rM2+yu9N; arc=pass smtp.client-ip=209.85.167.42 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="rM2+yu9N" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5aa5e0d57e5so2634243e87.1 for ; Sun, 07 Jun 2026 19:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780884109; cv=none; d=google.com; s=arc-20240605; b=SkHRAl34HysBW1KTjjzbHRE4Xtidw/MMoATJg6XSrh1sjP3bNlcJdzP3YovBSGtSWR 5QFEhoyqsTK/eAYBP3w5VsXxBDawXCy0YSL5fWFqcdGj1zt4cWoz5eJl+aXmLIRNTt7T d71uzrPWYOaI+L8NKARQATLlxmxZJrjY5YS1OGp61wvhqMPJ1SNxievaOroik/9Ed0zm +IfVV2F4PeKeffyc20qoaZtufmrvlxcQiefGSGBeWJLbdww+rnBVW9qh4rN/NOy9qk74 mMDiynGtOkBXkEeh2vnY5glJSZXq7O5xrdrPWtubkzIZcUyKXxwvpVgkyXCb0OqHr+PP L4vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SuXv0YXVfzFo1MawAMc5QnyJByAh5bon2yTSSj4xZdo=; fh=/2yDuFlL1PoyuHDsne33268tu8JYYzUmirRC0sDkqdk=; b=fc70FGAYLyg/iHTSpxGLKCvYrEw3pL2mkuiskxYdhn9FR6oFymxaw9Ctg4wHzyf6cE apgxaqLgEMQjuVatbhpcTsMFGQlQr2+17zaWgQhUuwZIDREGhuOWfwhfDhNnp3d+9/JO nAYzAEO8lbOJIPy0XNODZq6cJ4PM5aG1Zh8xCOuvBVHKl+THQ7o6B2s0d/nVi/O9G/ti xTwefc3PfglzrbMd8LSQyG3j0X2hXmvOUJnOZ/iZx7919ieMz9ofpLht6EiKATyp0f1t KZNfcBVJe03oqMOfsafmM6mQgj8HS+jZUqIR/Aqa+PTSzh0eAqabnQmiLL3jiTO8GsLQ 1odw==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780884109; x=1781488909; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SuXv0YXVfzFo1MawAMc5QnyJByAh5bon2yTSSj4xZdo=; b=rM2+yu9NitVuTlGANyqS6fUFv1nXfcxdy3mxEw99rxhgV6eXofX9VDFIQWgY6zI8D0 qq9oZ4GRDO9w71lnMvWcLJTO9uEIi/ZsiUbnJx7lTAbIFwrIFXHolieykRXdiddmOjtG EGG2gJ4JYqGUJZBV1/5Lo+ch9LzdWAxP3qCIXXkA/46fnd/Vo5dUhzR+XP3IRHhLmZLI oFbVfnzcbQLlK2Zu717luyAn7ExOwq2IybQF4xB7DYPgkrYuCpM6y2bubtBFipIul6vI HtAJSznC5gkA1MZquKSXalsmTWJpVQVyp7GYWrB4urMNCBLcXXJ9S+hzhv/9Qj9xANOt M3DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780884109; x=1781488909; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SuXv0YXVfzFo1MawAMc5QnyJByAh5bon2yTSSj4xZdo=; b=cBxsVOmiBdfsnZQSQX6mp+TcxbVIuGuu+UCpiVsWNNVNn+AP/8DBn6QZwHjG0Lgr9G vLk1zGpNjrLmr7pokXscVpWRdqIEOyy8sFTf/ebjwWGRpctUFGm++NqotXWXWjNXTv2D DD23nOeMKR//UO30NP9PDu003+PVfw3PEwunMQOf6GiNehAG/F8Hu43mq+bMgJe7v0Ig qmd3NRVNu8lKsqjfPkSEAogG4zxMigrKA1WgFZmZCWHCsckqlRwXDKgBDIy90YRjlIRt 6e1Jf9JhNaYqhiewCuQ3NGpD4iL59UMAzOv++EBxrurgQvfKsYh/uX/dLkx4tfGCETbB GZpA== X-Forwarded-Encrypted: i=1; AFNElJ9sHabMXgSyhY3OVtAtzET5EZYeVqq79vmqxxVjEadEC49U43rePFYnZ+MEFrNrc5P3EsKkmOn4N1jOYro=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3q16zcFmXVgBGerF1Gf5EcIze8avOaWkdA6/B6DYgxsFv8H3e wsywfRF62yHBfnORm/Xy6TWkTdKGzoix3gQoASYFB2mP5h4h9Kh1Vxhk3SpjDTE1tsTYi1Q7TN0 q2sN5p421eebFI49V5YopSJiTABYOVPU= X-Gm-Gg: Acq92OE0+EDN5wcR0qa9/MKjbrpzAz/gROtL+YRvj9tQ99EBrnBTw8A/aZH5WMoqUAA hcTbpOEYmxghRWAf97AxDLvJW+hcQjElsmwBex5kFi/GgYiYuzXt18GCu0BCNQCzlMKvBdeZtC3 Mk1MbM7uqyV8BGX189WruV8wbHNek+NppxDsBoKkPJ14Qj+Oap976x3gCTQOg6PmHHLBuHhoLuC NV94ww6Zel8319rjYRcAHr2ZSmC6VYT8s0oSM3g0VfD+1acoOIZr/Dwt2nuaOaDQeA3C3JRs959 47+IwISJIad6cmHXGMJsho2TNw4b X-Received: by 2002:a05:651c:210a:b0:396:70ac:840d with SMTP id 38308e7fff4ca-396d0a66d0bmr34723311fa.29.1780884108239; Sun, 07 Jun 2026 19:01:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260607203000.700100-1-hexlabsecurity@proton.me> <20260607203000.700100-3-hexlabsecurity@proton.me> In-Reply-To: <20260607203000.700100-3-hexlabsecurity@proton.me> From: Hyunchul Lee Date: Mon, 8 Jun 2026 11:01:36 +0900 X-Gm-Features: AVVi8Ceu2qSLUX9X_djoocxfd08_0wBfnxZEw3Dtacr0CvF9SxEj0t_AnpAeMws Message-ID: Subject: Re: [PATCH v4 3/3] ntfs: bound the attribute-list entry in ntfs_read_inode_mount() To: Bryam Vargas Cc: Namjae Jeon , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2026=EB=85=84 6=EC=9B=94 8=EC=9D=BC (=EC=9B=94) =EC=98=A4=EC=A0=84 10:51, B= ryam Vargas =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1= : > > The $MFT attribute-list walk in ntfs_read_inode_mount() validates each > entry only with "(u8 *)al_entry + 6 > al_end" and > "(u8 *)al_entry + le16_to_cpu(al_entry->length) > al_end", but then reads > al_entry->lowest_vcn (an __le64 at offset 8) and al_entry->mft_reference > (offset 16) -- fields beyond the 6 bytes proven in range. al_entry->lengt= h > is attacker-controlled and only required non-zero, so a short entry (e.g. > length 8) placed at the tail passes both checks while the lowest_vcn / > mft_reference reads fall past al_end. > > al_end is ni->attr_list + attr_list_size (the on-disk size); the buffer i= s > kvzalloc(round_up(attr_list_size, SECTOR_SIZE)), so the sector rounding > usually absorbs the over-read -- but when attr_list_size is a multiple of > SECTOR_SIZE there is no slack and a crafted $MFT attribute list produces = an > out-of-bounds read at mount time. > > Validate the entry with ntfs_attr_list_entry_is_valid() (added in patch > 1/3) before dereferencing it, matching the bound the other attribute-list > walks now use. The validator already requires the length to cover the fix= ed > header, which makes the separate "!al_entry->length" check redundant, so > drop it too. > > Fixes: 1e9ea7e04472 ("Revert "fs: Remove NTFS classic"") > Signed-off-by: Bryam Vargas Looks good to me. Reviewed-by: Hyunchul Lee > --- > v4: also drop the now-redundant "if (!al_entry->length)" check, per > Hyunchul's review -- ntfs_attr_list_entry_is_valid() forces > name_offset =3D=3D sizeof(struct attr_list_entry) and requires > name_offset + name_length * sizeof(__le16) <=3D length, so length =3D= =3D 0 is > already rejected there (and length is a multiple of 8, so a valid ent= ry > is at least 32 bytes and next_al_entry still advances -- no > zero-length loop). Rebased onto the "ntfs: validate attribute values = on > lookup" series (0001-0004) now applied to ntfs-next; added the Fixes: > tag. Compile-tested on ntfs-next. > v3 (Hyunchul Lee review): validate with the extracted > ntfs_attr_list_entry_is_valid() helper rather than an open-coded boun= d, > matching the other attribute-list walks. > v2: dropped the redundant Reported-by; reproducer omitted on the public > list (available to the maintainers on request). > > Sibling of the ntfs_external_attr_find() look-ahead OOB (2/3): the same > struct attr_list_entry fixed fields (lowest_vcn at 8, mft_reference at 16= ) > are read here with a weaker bound. Geometry is arch-independent (identica= l > -m32/-m64). > > fs/ntfs/inode.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c > index 8a7798d7f5fc..2f2634baa285 100644 > --- a/fs/ntfs/inode.c > +++ b/fs/ntfs/inode.c > @@ -1997,10 +1997,7 @@ int ntfs_read_inode_mount(struct inode *vi) > /* Catch the end of the attribute list. */ > if ((u8 *)al_entry =3D=3D al_end) > goto em_put_err_out; > - if (!al_entry->length) > - goto em_put_err_out; > - if ((u8 *)al_entry + 6 > al_end || > - (u8 *)al_entry + le16_to_cpu(al_entry->length= ) > al_end) > + if (!ntfs_attr_list_entry_is_valid(al_entry, al_e= nd)) > goto em_put_err_out; > next_al_entry =3D (struct attr_list_entry *)((u8 = *)al_entry + > le16_to_cpu(al_entry->length)); > -- > 2.43.0 > --=20 Thanks, Hyunchul