From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) (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 04D7313E02A for ; Sat, 16 May 2026 04:44:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.217.43 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778906675; cv=pass; b=iiJrK007FZ+qEKjUdDksQs0Pxc1+cLMS07QKdm2C9QL5djnrGpB+Oxi9sLp6WQ7jldn0So90hXCDpbDZrQvi2t9kM2Lxhx/RE3u+WoGh76XCynCKCOdBR4LwXXHNo4kLDQZvzWzcm/n+ZvUb8aDh4Vkb4fKRH1GVvVgTpHhKjrE= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778906675; c=relaxed/simple; bh=4QBQXNc/n+kRCp4DXOoFL6yVIhrRoM0TndDU3LEXdII=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=AKuCRiKomCzCabw4jdlZ7RExyLHzcl3AYcy58OuMBG1Kv0/LZVbcNawCMW8xNtkoMeL6zDK30xzEwRSNsjqIVswmGINRLYAPgpZCC8aal4bOnbyrPXpnLA0nKmB7FAzlJwGdrtrgRMIBDvPtA2jGWMXiHItCzVUdVcuwqTJ7qbc= 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=JAUpbl/7; arc=pass smtp.client-ip=209.85.217.43 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="JAUpbl/7" Received: by mail-vs1-f43.google.com with SMTP id ada2fe7eead31-6313493a866so16779137.0 for ; Fri, 15 May 2026 21:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778906672; cv=none; d=google.com; s=arc-20240605; b=bmpCeQD7DeJ/0wUCTW938wFyocH2d0nhHgY1fwxfF/4qFdGsv2XpfeHhTxxfGOXQi7 vPVHhkopcauFTNUDbjUeLTOrgXZqFoOSptD/bgTFbWW+Z0n5gT+Nmwa8/CRiLZ7ATZUa /YW3qPvgD+i4euKagpxLYqTnKSOSGo5BRbMV0PlZ/LbQfzZHhtC9bEaCREuJ4PDQFESw fVe6vY0goVpKF66YkuSnE1TLlm1GLS7/x5hknWWmLtgMn2SiB7gAQBHTxJI7lCxrAPFT dmHHwOe1FoVt3PlQ1J2j3PaEDG1HZPjGeHogfl9wlYdAFZRacB68StaPpzNwB5sZeM2L /PKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=DYDSXLhOHj1s+deQAJ+TXvpGa9Fd2DyDL2SVrwFSgpM=; fh=kRsNZM6L11JtvP3T/mrmnGH5W0rhUjDPuoY06ryIuEs=; b=YJNsDgELLphKvh4Pwj1D2qjsdRmPhpR8OMkCt3IhfiFbOtm/A518uUWug7qAe9zizM n/uu+Y8ZaaFSE+R8PXboKDBY2Ment/aiL+eOC5SPTGFQQp1be3oo8YkvN/nqlnf2Aaid poJE5fEmeKzRJeQNMLsxV7GugE6ZIBmblmoP0n/8lFYZnRzwPmh1DboNH7+7oDHAvk16 mgiLfiCDKujHGe5A29gaz+rNGYpTzgJfa+Ykh0P1GrX7KpSBetvteDYMVhiuj5P04nsi Ogycvq3mT63ybVAAv/sG/6tpMd9t+y2uwJQDiR8o8ayCgZDRt/Of48kIph//dFJWTAT8 bD0A==; 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=1778906672; x=1779511472; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=DYDSXLhOHj1s+deQAJ+TXvpGa9Fd2DyDL2SVrwFSgpM=; b=JAUpbl/7SjYYqHaDjLj9F9ecmG8kbt+1LBc8oyF9bd3ZgSDZO7/DGGmc6SmASCneB3 3X2OwY2Lmlmn5QZmf5fT9Qt69n/CNg9zhEeLgKaRMdExDlbPtP8MJoCZhaPHrPLWKmGj IuUU4BvY2LwLF25r3q7RPYINY5/e/EZaz5xmnkyUX3kSIPR/3dVMD95vokmcsSAo/usk xPsAR6+fYo8jda4zG7VY9es65cRuqoLkb7pQlACWJ4nZ/ERr+cPsTcMCxY+zgiGacnYo LsHIM3VUnT9wDbLkJCYqX78Zn22iTPqY3fEL5egoVZ9t7Z4AU4J+OAPiwhAEE+eVHUA6 rXzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778906672; x=1779511472; h=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=DYDSXLhOHj1s+deQAJ+TXvpGa9Fd2DyDL2SVrwFSgpM=; b=qP9rkP55iyUQAgSy+yjA28chcijmLE2uO2T0LtJYlFlGNd4i/BEhxXTj39Le4goDgF lP0xN2S7zXiIQ5ABTON2LyFRraDB20jR63u1BXZM37Qez9zvvHXC9MguauAxQG/+Z7M+ Eyn5/0teMmPvLNbEhmp14+0cFrMUWGnERQl3wgKu44/XJo5o7VAxA0fHsP3Ib2zq/rnK TmlZraB1XpOFdDkp+BPO2xTeZXKp7tD8C8mwEl8uAd4kKn8HV5QN5kA3Ln0NgtBHoZ9B J/kiNJlZVjlgcBpDRqB6nSEPvC5rMla64svMUViBZWrgEXzw92gp0sVqlGPNRtylhahj m5NQ== X-Forwarded-Encrypted: i=1; AFNElJ/NPHpgNOpkhmmiQTsdK6E+B35AHbChX7t8Dkc7IvN9sl8NcsZt0V3eE4/Vlad3bX3QKRYYS4xrIQ1YK78=@vger.kernel.org X-Gm-Message-State: AOJu0Ywf2DGYb5fJXqD0wFhWG/+nIhbBpEy3s3hKir1lv5AXAEqv1e+t 6IVdxNY4QRD/n2vqUT2Qm7JPbXjlAiFtOHRrScw3nW3chi34ylPnzkhRS8jSSEsl5sHOBieIN/Z mNAvayQxsHJGS+iFlC7IJ1qUBCd/gfcE= X-Gm-Gg: Acq92OE1ZRycmVP1hp9myA5PXVs7G/Tc62SwAxeY6Vq53xqv0qGx5F6OCWZ4uQEtNzG Xmt5t7us3C6L3CHYkNozpzMH9sH0l9e78Ua3srNYWlHQUVYVhISELaid1fwcCRYMdhJlxpiajpc o/C4AWkNveLbfclQUxdjP/A6uXFSXmFHB248TvtUDv1rK3CAMUipZQfLKyGSDwk/c4gXe2ZKu+C y1ogQM0b7he4XMd2GrAaRMfA8k4j4hPkINhA5hpbVPeeA755pD21RMpC60yuP69VG8sYZSLLts8 8B0zE3oSHlzRf+0LhfrHGJ8tK9PJ/xUZvBeZikc= X-Received: by 2002:a05:6102:116d:b0:631:267d:157b with SMTP id ada2fe7eead31-63a3f58f189mr1179218137.5.1778906671586; Fri, 15 May 2026 21:44:31 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260515163424.1575298-1-michael.bommarito@gmail.com> In-Reply-To: <20260515163424.1575298-1-michael.bommarito@gmail.com> From: Pavitra Jha Date: Sat, 16 May 2026 10:14:19 +0530 X-Gm-Features: AVHnY4JGJwyaJDa6wW1v8xk-c24D-8fldPvZ3sXcfC8Z3PVJ2ubMA72oRNfxato Message-ID: Subject: Re: [PATCH] fs/ntfs3: bound NTFS_DE view.data_off in UpdateRecordData{Root,Allocation} To: Michael Bommarito Cc: Konstantin Komarov , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Thanks for fixing this. Since you cited my original report as the basis, would you mind adding: Reported-by: Pavitra Jha to the patch tags? On Fri, 15 May 2026 at 22:04, Michael Bommarito wrote: > > In do_action()'s UpdateRecordDataRoot (fslog.c:3489) and > UpdateRecordDataAllocation (fslog.c:3697) cases, the memmove > destination is `Add2Ptr(e, le16_to_cpu(e->view.data_off))`, > where e->view.data_off comes from an on-disk NTFS_DE inside > an INDEX_ROOT or INDEX_BUFFER. Neither case validates > view.data_off + dlen against e->size; the existing > check_if_index_root / check_if_alloc_index helpers walk the > entry chain and validate the entry's offset, but not its > internal view fields. > > The neighbouring read sites (e.g., fs/ntfs3/index.c when > iterating view entries) check view.data_off + view.data_size > <= e->size. Apply the same bound at the two memmove sites. > > Reproduced under UML+KASAN on mainline 8d90b09e6741 via > pr_warn-only probe instrumentation: with view.data_off forced > to 0xFFFC, the memmove writes 32 bytes past the end of the > NTFS_DE. > > This is similar in shape to Pavitra Jha's 2026-05-02 patch > "fs/ntfs3: prevent oob in case UpdateRecordDataRoot" > (<20260502105008.21827-1-jhapavitra98@gmail.com>) which > proposes calling ntfs3_bad_de_range(); that helper does not > exist in mainline. This patch uses inline checks. > > Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal") > Cc: stable@vger.kernel.org > Assisted-by: Claude:claude-opus-4-7 > Signed-off-by: Michael Bommarito > --- > fs/ntfs3/fslog.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c > index acfa18b84401e..127860fd2ab50 100644 > --- a/fs/ntfs3/fslog.c > +++ b/fs/ntfs3/fslog.c > @@ -3497,6 +3497,18 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe, > > e = Add2Ptr(attr, le16_to_cpu(lrh->attr_off)); > > + /* > + * e->view.data_off and dlen come from the on-disk > + * INDEX_ROOT entry / LRH. The neighbouring read sites > + * (e.g. fs/ntfs3/index.c) check that > + * view.data_off + view.data_size <= e->size; mirror that > + * bound here so the memmove cannot reach past the entry. > + */ > + if (le16_to_cpu(e->view.data_off) > le16_to_cpu(e->size) || > + le16_to_cpu(e->view.data_off) + dlen > > + le16_to_cpu(e->size)) > + goto dirty_vol; > + > memmove(Add2Ptr(e, le16_to_cpu(e->view.data_off)), data, dlen); > > mi->dirty = true; > @@ -3689,6 +3701,12 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe, > goto dirty_vol; > } > > + /* See UpdateRecordDataRoot for the rationale. */ > + if (le16_to_cpu(e->view.data_off) > le16_to_cpu(e->size) || > + le16_to_cpu(e->view.data_off) + dlen > > + le16_to_cpu(e->size)) > + goto dirty_vol; > + > memmove(Add2Ptr(e, le16_to_cpu(e->view.data_off)), data, dlen); > > a_dirty = true; > -- > 2.53.0 >