From mboxrd@z Thu Jan 1 00:00:00 1970 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 906623BE641; Tue, 21 Jul 2026 21:46:02 +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=1784670363; cv=none; b=GdccSUdUNfvrVkaQftG4X2SeowT5kLJgPqpetFQ96fIaWnwN+yFyJm40xFl4j13tnzYUpfJ+Carq001n0gS7H1WiiEFf+RqqKefgEQg2Jn2cTHdNTBKKQeenZASOqgFjQufKj1wntCthNQycR/6jP2k/j3VtIJ4M2MFpFHeGW1Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670363; c=relaxed/simple; bh=O1mjyqkfYQHgFY6JImnKi1wLgQVpZwmTPAXPGJZ9yCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uf+WGpLVz0FcjmP+jHBQm3W9pV0Mz/blFpwOTJA14yLp3irDurT2C/K1qmPzKf16qtYKmLoscf3H4kt7gts9ANHX1un6RrzcTCFSHTKfDxUCpB8TJmFrHJSNM1lKw0hQf5oSHOGNZlA0JUXYjzylC6OVmr/gel3TWH8qE8CXK+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ly6LxWjw; 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="Ly6LxWjw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2682E1F000E9; Tue, 21 Jul 2026 21:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784670362; bh=/q8v72cs/MP/FlOKdJZLAAp+2QG1Drng4P2/giWugjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ly6LxWjwB3Y2XV2E3rhdf67blItc7w75t3/hkeEeGYgmOf6bBNHABfGi57UhlEFjO ieTT11QRcBAleuhbe8b/U5ImAkRrmLWCjKqP80ZA/lOCT0okyz9LNI0A4HQXhdssKR 6vsq9Ski5mjLD46DycE9PooLV1O32z0BHGERLsO4= 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.1 0904/1067] orangefs: keep the readdir entry size 64-bit in fill_from_part() Date: Tue, 21 Jul 2026 17:25:05 +0200 Message-ID: <20260721152444.759981340@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@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.1-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 @@ -191,7 +191,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; @@ -215,8 +216,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;