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 D6385351C2F; Sat, 30 May 2026 17:45:45 +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=1780163146; cv=none; b=dwcBAeY8Qy/6AmgO1w/kd50j6Ivzrkj7sXwfMrDVPjp4WCnOg2b3db4OS1kKZf4Kdw116eBwC35qOPEqAAk4OZajtv2SzU5+XEfYfWmUEo6Yj6+KxQkHPqHfhbmb6LigUfFjtnlgCt6ZkLog3wQTvLfs76FT5g76erFJA7j7Hzg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780163146; c=relaxed/simple; bh=EWfl7XL0HPpDdJGaw6Xy/ucg04k9WVGM0R212CHCDFo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tq609HESLzqwgXpaDhXQjcGbiSfiawcVdBlE33pYofzv44q02aKBrPAC186b+Jkq6e7v7RdQKBRzz9aRreGqb95DdopXjSTR6AChGoOvxehdB9E863U3ply+qeCKDIlgK4TNaJrgcHWpRdhomEWWze50M5YssR/mrxZq8ikxUPg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hxSnpTTN; 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="hxSnpTTN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 273B91F00893; Sat, 30 May 2026 17:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780163145; bh=TSomb2lSvxWREjzWDmpm9aHaiZ0tAa4kyq8yeXbrkUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hxSnpTTNj2XDgCSURn1ONbkNlJjjrXsgllgzB9A0KFAsCSbmX/xSEaqrFqonfZYir DaoGJqv2StWiTqiHD0sn8ARCk7UPSJjc8y9U+CMSwp1Gk430q6B8u8PAfZiyj4vPxY M3kLYtCEJDMUmR/tWk0/1Gj5FBVCzixsHbcrbKIw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Samuel Page , Qi Tang , Zijun Hu , Miklos Szeredi , Christian Brauner Subject: [PATCH 5.15 171/776] fuse: reject oversized dirents in page cache Date: Sat, 30 May 2026 17:58:05 +0200 Message-ID: <20260530160244.914959325@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Samuel Page commit 51a8de6c50bf947c8f534cd73da4c8f0a13e7bed upstream. fuse_add_dirent_to_cache() computes a serialized dirent size from the server-controlled namelen field and copies the dirent into a single page-cache page. The existing logic only checks whether the dirent fits in the remaining space of the current page and advances to a fresh page if not. It never checks whether the dirent itself exceeds PAGE_SIZE. As a result, a malicious FUSE server can return a dirent with namelen=4095, producing a serialized record size of 4120 bytes. On 4 KiB page systems this causes memcpy() to overflow the cache page by 24 bytes into the following kernel page. Reject dirents that cannot fit in a single page before copying them into the readdir cache. Fixes: 69e34551152a ("fuse: allow caching readdir") Cc: stable@vger.kernel.org # v6.16+ Assisted-by: Bynario AI Signed-off-by: Samuel Page Reported-by: Qi Tang Reported-by: Zijun Hu Signed-off-by: Miklos Szeredi Link: https://patch.msgid.link/20260420090139.662772-1-mszeredi@redhat.com Signed-off-by: Christian Brauner Signed-off-by: Greg Kroah-Hartman --- fs/fuse/readdir.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -41,6 +41,10 @@ static void fuse_add_dirent_to_cache(str unsigned int offset; void *addr; + /* Dirent doesn't fit in readdir cache page? Skip caching. */ + if (reclen > PAGE_SIZE) + return; + spin_lock(&fi->rdc.lock); /* * Is cache already completed? Or this entry does not go at the end of