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 E80FE1DD0C7; Mon, 23 Jun 2025 21:49:53 +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=1750715394; cv=none; b=avopuTSsJSte/xDg5ZY+5V+t3fwPEV+PEGSq0dlRUU9heN85KiGEbwN6cOwb8aEsVmLUhZvSbJqKn8jd+kcmQXU6y2DCYJ1hU0dPvtkgA7QCUITJJ5iw4timkzq5f1/xOOB7CEMVOaCej8JsJibQNXu/Uzdg1oMEAh2pYH5TvuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750715394; c=relaxed/simple; bh=IkQ2BmF9iFtYMGcsi7EsWwzkJ6p24F3S6D6tXcqjc7s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cvXx2sDCxHyQsm4fXdi2Ig/tKmK7ztlIGsUOGI2fqLHUjj12NtnKABohuMeyJJ+CfvMelPaMsjQ84OryLPSGDMgWwu57onjtVDuENzlf8dRZEq3e43cECyLP5fr7RLaAGvHH73ZkZzE3+0tabR9qHILNPfNm4QvMhBxQkbw8gWM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=t9rc3k7b; 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="t9rc3k7b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E91FC4CEEA; Mon, 23 Jun 2025 21:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750715393; bh=IkQ2BmF9iFtYMGcsi7EsWwzkJ6p24F3S6D6tXcqjc7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t9rc3k7b8qCKH+2dFuH/lLGgmF0kp+KTNrPa/8q/JBF9AwOdI46XkJXbny/QIf+jX HbFB499d0/nc8YmaGgpafktr8fvnvj1BzGImFdBxzjGUkSmOI0VICt0J292kXrPf8P oBgqVZElM1JcApQK1Tc0OiSUAKu8SthPrTavuJq4= 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 5.10 272/355] sock: Correct error checking condition for (assign|release)_proto_idx() Date: Mon, 23 Jun 2025 15:07:53 +0200 Message-ID: <20250623130634.949619670@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130626.716971725@linuxfoundation.org> References: <20250623130626.716971725@linuxfoundation.org> User-Agent: quilt/0.68 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.10-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 d5818a5a86fdd..3c8b263d2cf21 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3433,7 +3433,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; } @@ -3444,7 +3444,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