From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (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 034073BB12D for ; Fri, 15 May 2026 16:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778862841; cv=none; b=Madyjg5feSmKE7T8C1QHymePiwXcAL+qY9ZfgtZO29hu1/Z1lXa9o3FwXdOPins+qQvmZC+9rmvQ4XeMA7/ZaptaKo3HHkmJ/oODfaDJnJQFpy6etkqlXPTGyCxw8lTUWhR10DNdgjr9V90VTewPOckgr+mAABWcxMS3XnPi3wI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778862841; c=relaxed/simple; bh=3FlUiIkq8nNfO4gEt6qM3i6l+lwaCE8lbOgVEylPzeM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hWa945RMOhcRES4sNrdQwPqzQt7+efpg3I4HL+HnHewL1R7mtubDoQtwxavYdrJZzWop19fQ4AJtfePP47HhwQyW8hO+M7UnNJiRu7WlzF3pDcGhhIDy/UwuLmXdOSg2D/JcRzOICQSMWFP60iNmUXIAiXMKnJL6UQ3wMy5WY7E= 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=hMoZjGjZ; arc=none smtp.client-ip=209.85.219.54 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="hMoZjGjZ" Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-8b74b460d77so93089016d6.3 for ; Fri, 15 May 2026 09:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778862839; x=1779467639; 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=o3vUVjM/dzC2z0GaCVAFpFXQRqsDU20UVZqnjmL8hhQ=; b=hMoZjGjZIKR+vAnV60/kNb2odjlLcx062PUD6vqMepsFqnP0s0Svzr1fvtEN5iCcNA KhtLf4rFs6OU4ElzNRW9aPnJUbUG+rC6BoJ0eLRVLRlqclOVWho05UxsM5ACXUK01OTi QT42ZrT1PsXbQx6+m1SiRZIIJVf4VZbGmNBoUGm4c+ySKWOuwKK85jWAOQIXscjImkva H49smTmcBLJU/P/HpZ4WKpOfFpnr3atlyxUdsPAx+0Z8IC4/loo66jst1xxFd8nESAUN ukjk5KEFJLHhX4DHQCuu86SK7gQOZbsr8bA61Jh/Oc/JBbfOpP3bL2WA2b5fji0gEeeQ Jhww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778862839; x=1779467639; 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=o3vUVjM/dzC2z0GaCVAFpFXQRqsDU20UVZqnjmL8hhQ=; b=SF3JTk+WdvdM1G/SWty+nZQGK8epMHPuZhT9tTNIPVIeAuAX6HaSB2KkAsHy/d45Y4 gh5uQXiD+kmQe20kDH2ZK4Ozmfsxpi0iE6Uj1sXporv7v4j/tG+zP534CaHMEfAqnvYa o7YslRR+JKCRUqwb1RUVkMpc8LPE99lGC+pQgH4rwG/IZ6xO+IDoBrBXWZytw4WckQIs qgm4LzIKhxUuQSoYcAyY18Uq7HRQ192PN3d5XIHkD/lGRvClkOHua/VLkenxA8GoxdJr B43zgQxrxQ3U37pL8MM19JfkwfzeHYr1rnuMA4U+/aojMwmNrHRL1nQdO8hgCKRMqe4/ lsAQ== X-Forwarded-Encrypted: i=1; AFNElJ/Lv2VqCgqvIB9nF4xJJ/Yv6wztJMbiSjIF8njJcrKh2Fv9z+TbZ14axjWuiET1sEgPfpAMvCYme3r0kn4=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5lox8koGtI/8RLtcfWsE1JKcVpOb3NJ8f7SvNxS3rwZq4Pu/a CW4Nu44095LbcWS+/B7DK64/IM3WfzQKU68OkvuC/nIRZRyvrpnGVdxm X-Gm-Gg: Acq92OERGjcpOSMx1CVIqmO+ZkRSyKEvfQkFROYX1r7AuxUC4dFwwPnOeKZPDScc2Wh 6Hp7CFwOO0QoebfUHzBB4DTSoESQdqvSWLOmlmvuFNgryKvv54TnM7ThCzcULg5Tm0OhluNa1D7 sAevoGlxm0lkcS1QEDoiJhdEHSMK8H3/6bsNqjvrXlngXS9jwPQqW40rbE6n4aqLvCtCvnsg29Q NTiPUjTdPPQSK+btII1bSbQonTyNp/5RCw8vLm1FheXpC1V+qPMr1GpDydM0T7hjDYoaAVBKbgd E7Yl5Vml3j4xFhthgiimtAyJV89fi6ja6p5bQDoh3RVcIdgNZ1Jh+5fOqoJYhaJXRJkm3Z7D8lp FAQL0G2lRMb2+7dYXFBD1wpE+dyyEmz1wyc/l/pA1j6SymY8kK7tT+E8ehUceCt9sbVL8hmYck0 VcfkHk1Sc/BaaOHVSMqh2rU5P9mDsvH4UhUfQ6C0tUYN+JDTwS6l6tEQHbsJfAjODuKiQMoU9Zo Qo0p/Lc5Ht3HrEBGIpH8hssote3Df8RRh1W8LzAWvcmAOitTA0meA== X-Received: by 2002:a0c:f08f:0:b0:8ac:a6bd:503b with SMTP id 6a1803df08f44-8ca0f5f704fmr67820876d6.15.1778862838975; Fri, 15 May 2026 09:33:58 -0700 (PDT) Received: from server0.tail6e7dd.ts.net (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8c90c37bc64sm54721256d6.48.2026.05.15.09.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2026 09:33:58 -0700 (PDT) From: Michael Bommarito To: Konstantin Komarov Cc: ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH] fs/ntfs3: bound attr_off in UpdateResidentValue against data_off Date: Fri, 15 May 2026 12:33:54 -0400 Message-ID: <20260515163355.1574086-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit In do_action()'s UpdateResidentValue case (fslog.c:3307), lrh->attr_off and lrh->redo_len come from the on-disk LRH. When they satisfy aoff + dlen < attr->res.data_off, the assignment attr->res.data_size = cpu_to_le32(aoff + dlen - data_off); underflows to ~4 GiB (e.g. 0xFFFFFFF9 when aoff=0x10, dlen=1, data_off=0x18). Subsequent code that reads attr->res.data_size to walk the resident attribute payload would then read up to 4 GiB past the 1024-byte MFT record allocation. The existing mi_enum_attr() defense in fs/ntfs3/record.c:287 catches the corrupted data_size on the next attribute walk and fails the mount, but only on the path that walks all attributes. A read site that picks an attribute by name and reads its data_size without re-validating is not covered. Validate aoff against data_off and asize at the source. Reproduced under UML+KASAN on mainline 8d90b09e6741 via pr_warn-only probe: with aoff=0x10 and data_off=0x18, the post-assignment data_size is 0xfffffff9 (mount then fails at -22 from mi_enum_attr). 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index acfa18b84401e..4977ac1f62027 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -3325,6 +3325,17 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe, nsize = ALIGN(nsize, 8); data_off = le16_to_cpu(attr->res.data_off); + /* + * aoff comes from the on-disk lrh->attr_off. Forbid + * writes that begin below the resident attribute's + * data_off (which would overwrite the resident header), + * and forbid aoff + dlen < data_off, which would make + * the data_size assignment below underflow to ~4 GiB. + */ + if (aoff < data_off || aoff + dlen < data_off || + aoff + dlen > asize) + goto dirty_vol; + if (nsize < asize) { memmove(Add2Ptr(attr, aoff), data, dlen); data = NULL; // To skip below memmove(). -- 2.53.0