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 E207D1E22E6; Mon, 23 Jun 2025 21:40:06 +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=1750714807; cv=none; b=bxmCMMjtVsQWFlWELX6s2rCxJoVh6xpntxuuxGKcxfMzbakf4W/zMlX58swK3CfwCmIgjWXd3ORpkXamTlPNXjJjnne0IC1ZquEJGFzFTgU6Csx7F4hRVM7FPLCUjytPBm/6vJ6oLUFjycfhM19EtMmRR70fQLdKNONli8ZrNHE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750714807; c=relaxed/simple; bh=Hw5JI/cFVMcZd2yIKdfcARsja+GQZLqaUg+DGBLWPio=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nFv8ejvQkcp6w9j3QQeukTT8bA3RrPAkkbyZ/r8mFZM92rovkEL2BKCf2W6jvVdd5li8HsbHgx6cKNOYud6lP2btKR3EhW/yx+2nAy8tcMxUh3Uh4E1Op+9MI/BIS2SIcAZSW8KPHVohzlVYVcI84GevITltKNxx4LoY6nUprD0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GHJTYqgL; 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="GHJTYqgL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A4E1C4CEEA; Mon, 23 Jun 2025 21:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750714806; bh=Hw5JI/cFVMcZd2yIKdfcARsja+GQZLqaUg+DGBLWPio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GHJTYqgLD46/mK6idgWag45gJGyXQUfs2uWG0SyVg3vQrhWmGnbs/jR+c75B86mh5 v1AERz6c4CbqQeuMYda6PwOrzhW2ogIj6o9g6cguXYTfRsk5yWvyK484zpepm61TTJ 4+B1Nbr4r43M1uWaNAjlfjX9EqweeOppZaxf5x9Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zijun Hu , Kuniyuki Iwashima , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 182/290] sock: Correct error checking condition for (assign|release)_proto_idx() Date: Mon, 23 Jun 2025 15:07:23 +0200 Message-ID: <20250623130632.348929577@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130626.910356556@linuxfoundation.org> References: <20250623130626.910356556@linuxfoundation.org> User-Agent: quilt/0.68 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zijun Hu [ Upstream commit faeefc173be40512341b102cf1568aa0b6571acd ] (assign|release)_proto_idx() wrongly check find_first_zero_bit() failure by condition '(prot->inuse_idx == PROTO_INUSE_NR - 1)' obviously. Fix by correcting the condition to '(prot->inuse_idx == PROTO_INUSE_NR)' Signed-off-by: Zijun Hu Reviewed-by: Kuniyuki Iwashima Link: https://patch.msgid.link/20250410-fix_net-v2-1-d69e7c5739a4@quicinc.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/core/sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 84ba3f67bca97..ec48690b5174e 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3817,7 +3817,7 @@ static int assign_proto_idx(struct proto *prot) { prot->inuse_idx = find_first_zero_bit(proto_inuse_idx, PROTO_INUSE_NR); - if (unlikely(prot->inuse_idx == PROTO_INUSE_NR - 1)) { + if (unlikely(prot->inuse_idx == PROTO_INUSE_NR)) { pr_err("PROTO_INUSE_NR exhausted\n"); return -ENOSPC; } @@ -3828,7 +3828,7 @@ static int assign_proto_idx(struct proto *prot) static void release_proto_idx(struct proto *prot) { - if (prot->inuse_idx != PROTO_INUSE_NR - 1) + if (prot->inuse_idx != PROTO_INUSE_NR) clear_bit(prot->inuse_idx, proto_inuse_idx); } #else -- 2.39.5