Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 604073346A6; Tue, 21 Jul 2026 18:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784659344; cv=none; b=tPdO6PodC4btAtRC2stq/9hkuAePFRc7FZnIAChxrpXQui4/mv2HbEidaZoZJ2nJYMmXaEvo/D3i/prnsGnJhJWFjCDJGaQ/OeVLnRpefIP/ArpgXjhmgkzD3L/Bf2+uYcBBR8x/9s/rkbBjwWKCQ9pzyTwziIPJmhdEi9VHqKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784659344; c=relaxed/simple; bh=Js8ypaKiXCUIxxAtFEF7aXGTnxfdIiHIW2ed6JgH/AA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RlJUZbo1kqj1vT9MixK3uWo6E2Vf9W8XGtSVFHxnw13gvo8OOQQ8sUgRZS/EV5XkA/HjN4suNh21gv/SZI+E/OTjWKcug4AWlb00UbOuhM2hpNWqxWQogH/lbvol3AWHDdkkdMCXJsJ6K2Iqtg0ShLLP1/ggQHZWxmHRBe3csh4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DYzxP6xo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DYzxP6xo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C100D1F000E9; Tue, 21 Jul 2026 18:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784659343; bh=EFv0waVZWMlxJn0aj8dHJkZO4SowLTLpZsYIfdlPpqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DYzxP6xo9Lt3edsyZteqKvaMVlYvQax9ex5fr/HhWnkvHw+zGTcQLSqzyis9dGQ6U +UuCGepz//UyiwUAOLQJ75b3IrhRyiUTKU2EaU419E6xLGcDJaRAKlVEssIzuCSUMS O9Xu1eEwPOFBswL02KgCOZ07i+N5Q7ocXaKb629k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bryam Vargas , "Christian Brauner (Amutable)" Subject: [PATCH 6.18 1442/1611] orangefs: keep the readdir entry size 64-bit in fill_from_part() Date: Tue, 21 Jul 2026 17:25:58 +0200 Message-ID: <20260721152547.882895441@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryam Vargas commit 18227a6bc98bd0ba96ed3ce9d5b28776a5a28dfc upstream. fill_from_part() computes the size of a directory entry in size_t but stores it in a __u32. An entry length near U32_MAX wraps it to a small value, bypasses the bounds check, and is then used to index the entry, reading far past the directory part -- an out-of-bounds read that oopses the kernel. Compute the size as a u64 so it cannot truncate; the bounds check then rejects the entry. The trailer is supplied by the userspace client. Fixes: 480e3e532e31 ("orangefs: support very large directories") Cc: stable@vger.kernel.org Signed-off-by: Bryam Vargas Link: https://patch.msgid.link/20260619-b4-disp-50d2bd59-v1-1-ce332969b4a2@proton.me Signed-off-by: Christian Brauner (Amutable) Signed-off-by: Greg Kroah-Hartman --- fs/orangefs/dir.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/fs/orangefs/dir.c +++ b/fs/orangefs/dir.c @@ -190,7 +190,8 @@ static int fill_from_part(struct orangef { const int offset = sizeof(struct orangefs_readdir_response_s); struct orangefs_khandle *khandle; - __u32 *len, padlen; + __u32 *len; + u64 padlen; loff_t i; char *s; i = ctx->pos & ~PART_MASK; @@ -214,8 +215,8 @@ static int fill_from_part(struct orangef * len is the size of the string itself. padlen is the * total size of the encoded string. */ - padlen = (sizeof *len + *len + 1) + - (8 - (sizeof *len + *len + 1)%8)%8; + padlen = (u64)sizeof *len + *len + 1; + padlen += (8 - padlen % 8) % 8; if (part->len < i + padlen + sizeof *khandle) goto next; s = (void *)part + offset + i + sizeof *len;