From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 CC444481DD for ; Sun, 26 Jul 2026 06:25:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785047122; cv=none; b=g0LN1ShKeKk/o8iMeRt3kPSuEL/CPDIkVgQ5eCL23LwxkLGzsL/IZguEPrAa9HAvkVsMBLMsiSNaqlQqOBReXdCkvnyM2HCWHo85dh0HzKtT5Y90kRKNeiGHKWSt68XNQ7hpiVmxOtwHBt7E4LsuUPefM81i9dNk/X/0aXtPCqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785047122; c=relaxed/simple; bh=Hszg99Fhnt/WRuDbGMmPk8WSIMvY26tREE486XMnpmc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FaJdJ+vWeevYeVp1yWNBIrKHi+4WrrFkdvuS0OTOnQQQcNStvxd4W6P4hjYqYqxAH8fTv+ioJIeJZLyotoGn9xzM9AoavIdCd/kWpfc8XFTru7+43uW0q5oadK35G2TKyaQ0AAePMxgIvTUy8QA8KklfImMNwK/ww7zWNQESwoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xbow.com; spf=pass smtp.mailfrom=xbow.com; dkim=pass (2048-bit key) header.d=xbow.com header.i=@xbow.com header.b=QZ1kpC72; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xbow.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xbow.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=xbow.com header.i=@xbow.com header.b="QZ1kpC72" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-84e3007a2b7so1479657b3a.0 for ; Sat, 25 Jul 2026 23:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xbow.com; s=google; t=1785047120; x=1785651920; 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:content-type; bh=8eyy01gUZcTypOwXF2vr3vGTrQtX1X17k4pOsofiCGY=; b=QZ1kpC722EVZFG0/AWQbNnb9tbfSYtiZ8Il1avooyCNydGPXn45jo9i+HSiljCOeK9 FihD6kRr68xLC+lyxW9h+wr5q1k3otBdjvEDXVUpXnerF/BAJjOlJMFP0V40NTIhui7y zrKXrO99Koh+CRr86sya4+hY41yfto3IsgaLbeMklZIMKEuWScRInsyIkNCL86264s18 zwDxBJ8/mLxZhNQ29xUfDadxc241+pItcHZYw5Qlf8UDvAOWXA3ATQu177Xt+YB1y68o zjY4EygESmlep36ISa99Xthi5Jg67ZkndQ+QBprIbQi7R3M8Z3BS6u7NRMuWuFAbtmkm NUpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785047120; x=1785651920; 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:content-type; bh=8eyy01gUZcTypOwXF2vr3vGTrQtX1X17k4pOsofiCGY=; b=MHihx3o4C0LuHxHixLeyDIK/iCIaKQiXIO+g7c8RnRMj39Tp1S+1hms97aH45wGoFH OIntA4mMOYrG3Wx5QS6EbKe1+02aXZDQQvUmaOsdzsxIaMC7bIt2v5lZEM8Wu/M4gyRV OuLsLiZRnVhGAxVPqHOqcnS44m14kxCYIbxrS/6Iqe2vTDrzm5A5wiQFtc9NbMc9J149 MM3RblF28NWSpwPrtQ4pFj3RpSZa0dFGj6GR7hUgE4EKTagjmBRMI3qE4hJCjGOtkzuL pJxrxkLuwOsulMUlzJzBzfBXI+1b9knrzltZAH9gOQNxXFbm76dmXcGWNOPEYfxZAKNQ x1dQ== X-Forwarded-Encrypted: i=1; AHgh+RrNDHq+gif+GgcRXgpxWuUgOZ0KPruLnJR5b0ILeCUfJgeCKSAzFF8Tk40ODoqa1YKICjoarKYl+PPM9h4=@vger.kernel.org X-Gm-Message-State: AOJu0YykTECH55IMPV1JGrWgsXESwfYlrCCZLsaN5ZdyXt49vsjfGNLt BjT1gndBs2Gm1RjBQCF8npK8fl3cLFVwKOG11r41yYSlt2xCYKaJV05H9MuYG0Qxpu0= X-Gm-Gg: AR+sD11hCqU2KVu8998M3VdWYL7qAeCk/lnt6+K5F0g5K7pOrfGuJ3on1oZjBY9WfrL Hf2sHSrTkg1X7bZq2UaDtCHbBoXmCB/eQo8lm2DeryUiAUMAaUjN2SN8ViQkCv4XoqJ9sFYEZiJ JPAje3yMqyVIHGZ97mBY36i8I4s8oPWw6tvWIImi4SgkSY6PpgL2rz7eQxJZAvDk7bJfyoIMZuu HLKjqnFJUoDncKpSbbaiMKo0TwPClKZgz0bpXE7lcHM0r4F95qosA5ldTRsWNA8VYstVonP7yHn uzlQC/OKxn67cEXoLCuIiE5OCFWVIvm7RPMCf0Y+r0RHc54tFeTK3RBCswrOrcFddhp8ydtaufI AbCoyDkXDtZgOhcM0iAj9AyZpfO5BEHxqqvRAgm7mxAORqm07/p9AgURIvEZLAVqw5h1YJGGX7K bfsuHe5BQJK6GezDfL6v/7Q8wHr5DMnSrrtcKYvz4N/HrRzFLSVU+9VRrVMZ2q X-Received: by 2002:a05:6a00:4c9a:b0:845:dbdc:8652 with SMTP id d2e1a72fcca58-84e5942bcacmr3501122b3a.2.1785047120125; Sat, 25 Jul 2026 23:25:20 -0700 (PDT) Received: from localhost.localdomain ([125.128.148.126]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cbbb66dcd38sm1841236a12.29.2026.07.25.23.25.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 25 Jul 2026 23:25:19 -0700 (PDT) From: Baul Lee To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: hch@infradead.org, federico.kirschbaum@xbow.com, Baul Lee , stable@vger.kernel.org Subject: [PATCH] freevxfs: fix off-page read on a crafted dirblock Date: Sun, 26 Jul 2026 15:25:14 +0900 Message-ID: <20260726062514.43756-1-baul.lee@xbow.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit vxfs_readdir() and vxfs_find_entry() both advance the intra-page offset pg_ofs by VXFS_DIRBLKOV(sbi, dbp) at each dirblock boundary and then dereference de = (struct vxfs_direct *)(kaddr + pg_ofs); without re-checking pg_ofs against PAGE_SIZE in between. The enclosing while (pg_ofs < PAGE_SIZE && pos < limit) test only gates loop re-entry, not the deref that follows the addition in the same iteration. VXFS_DIRBLKOV() is 2 * d_nhash + 4, and d_nhash is an unvalidated on-disk __fs16, so the overhead is attacker arithmetic of up to roughly 32 pages. kaddr is page_address() of the single order-0 page-cache page returned by vxfs_get_page(), so nothing else bounds the addition and the de->d_reclen load lands off the mapped page. Directory pages are consumed unvalidated: vxfs_check_page() was never implemented, only a commented-out call survives. Both sites are reachable on any mounted crafted freevxfs image, the vxfs_readdir() one from an unprivileged getdents64(2) and the vxfs_find_entry() one from any path walk into the directory. When d_ino is non-zero vxfs_readdir() also feeds the off-page bytes to dir_emit(), so they reach userspace. KASAN reports a 2-byte out-of-bounds read in vxfs_readdir(). Re-check pg_ofs against PAGE_SIZE right after the addition and before the deref in both loops, restoring the invariant they already assume. The added break leaves the page the same way the existing zero-d_reclen break does. Well-formed directories, whose overhead never pushes pg_ofs past a single dirblock, are unaffected. Discovered by XBOW, triaged by Baul Lee Fixes: 12495ea3ac47 ("freevxfs: refactor readdir and lookup code") Reported-by: Federico Kirschbaum Reported-by: Baul Lee Cc: stable@vger.kernel.org Signed-off-by: Baul Lee --- fs/freevxfs/vxfs_lookup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c index 138e08de976e..b068f93359fb 100644 --- a/fs/freevxfs/vxfs_lookup.c +++ b/fs/freevxfs/vxfs_lookup.c @@ -87,6 +87,8 @@ vxfs_find_entry(struct inode *ip, struct dentry *dp, struct page **ppp) pos += overhead; pg_ofs += overhead; + if (pg_ofs >= PAGE_SIZE) + break; } de = (struct vxfs_direct *)(kaddr + pg_ofs); @@ -237,6 +239,8 @@ vxfs_readdir(struct file *fp, struct dir_context *ctx) pos += overhead; pg_ofs += overhead; + if (pg_ofs >= PAGE_SIZE) + break; } de = (struct vxfs_direct *)(kaddr + pg_ofs); -- 2.50.1 (Apple Git-155)