From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A0BD5285068; Mon, 23 Mar 2026 16:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774282202; cv=none; b=tP8wFR7nyEBYYj5WIZWalkFkmoUGQqaANV6gOIPcoZ2Pffj0dpYCDr+hjxWu5lPuWL2a6zSLL8g3yPZ3b+3w9gRJNyBnVK1ltN/lmNeavxb6kjm9T3HnnXY2DZcTgLGe27PP0c2UioUQETSL93KKUqK58o++ZY9lOmGpxYxY6ek= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774282202; c=relaxed/simple; bh=n0KhDbU8gJ/QY0q76aS+7fUtCVBHmNOVgsTkoC6A96E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SSqaCs5CKpbpK6jD+GfHX3hp+WBI7lRJDe7U5/LLHGe7Gx/rfMljWhEQfDiVBYJaArSurhnxPaM3AsCu2KTptBqkDYKRcW2Zk0GaDZlYB0mkG4N9UeT3JwiIZZu0DAC4Kww8C3GjQZRv6i+6NQntkWw6JV87RTHs0Gz/r1hfK+A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M4vxikC0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="M4vxikC0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6288C4CEF7; Mon, 23 Mar 2026 16:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774282202; bh=n0KhDbU8gJ/QY0q76aS+7fUtCVBHmNOVgsTkoC6A96E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M4vxikC0CNa3y/Uj+cXkiUN9iAvxqv1CpMNhLz1u0r5ySc73OAbMz77kqNHk38PGT AmJZIuqiVRVAmYMwgCFmBnFDvQiSH6aK+yGGm5YQz1qVn7M+Qo6I20iHGR+OMMsLd2 bJjEqHSOo0wNC+fgPt4qN4IzeT2y77DaewliZptQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guenter Roeck , Jann Horn , Christian Brauner Subject: [PATCH 6.1 069/481] eventpoll: Fix integer overflow in ep_loop_check_proc() Date: Mon, 23 Mar 2026 14:40:51 +0100 Message-ID: <20260323134526.912736035@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134525.256603107@linuxfoundation.org> References: <20260323134525.256603107@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Jann Horn commit fdcfce93073d990ed4b71752e31ad1c1d6e9d58b upstream. If a recursive call to ep_loop_check_proc() hits the `result = INT_MAX`, an integer overflow will occur in the calling ep_loop_check_proc() at `result = max(result, ep_loop_check_proc(ep_tovisit, depth + 1) + 1)`, breaking the recursion depth check. Fix it by using a different placeholder value that can't lead to an overflow. Reported-by: Guenter Roeck Fixes: f2e467a48287 ("eventpoll: Fix semi-unbounded recursion") Cc: stable@vger.kernel.org Signed-off-by: Jann Horn Link: https://patch.msgid.link/20260223-epoll-int-overflow-v1-1-452f35132224@google.com Signed-off-by: Christian Brauner Signed-off-by: Greg Kroah-Hartman --- fs/eventpoll.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1872,7 +1872,8 @@ static int ep_poll(struct eventpoll *ep, * @ep: the &struct eventpoll to be currently checked. * @depth: Current depth of the path being checked. * - * Return: depth of the subtree, or INT_MAX if we found a loop or went too deep. + * Return: depth of the subtree, or a value bigger than EP_MAX_NESTS if we found + * a loop or went too deep. */ static int ep_loop_check_proc(struct eventpoll *ep, int depth) { @@ -1891,7 +1892,7 @@ static int ep_loop_check_proc(struct eve struct eventpoll *ep_tovisit; ep_tovisit = epi->ffd.file->private_data; if (ep_tovisit == inserting_into || depth > EP_MAX_NESTS) - result = INT_MAX; + result = EP_MAX_NESTS+1; else result = max(result, ep_loop_check_proc(ep_tovisit, depth + 1) + 1); if (result > EP_MAX_NESTS)