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 49D1A3101CE for ; Mon, 4 May 2026 07:59:25 +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=1777881565; cv=none; b=ZFKFgp73fk+Jv+xnzRXDrUBmk9LQBZj/ouJDobeP02SL2S5UO0zS3kMUhWX3J+gwOZiZR4bRKYPGdo+MNe5ORvBuufUGg7QB3Txe+iOkOQI2utWd9H71X2i877/i5H0U2fH5UEUURz02fLTHZMbmz2z/Ete2JLbjsGASYvOmo04= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777881565; c=relaxed/simple; bh=YwKzZ3hsrpIYkQts1JCSz/KBpRmwBX3YeC2nkET2p8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UTmDUk2JVPva5yfMPTY40HUdADvdXic+rw4NBMhMj7LVi+a4rHltJRMn3zDcx48dvmL/ItHCzmVUJG3aV9gKI4WJH9UKhkZ9ZdbZq8hjjGq98fVjsq1229jp9Efo6P57NnhU0Wduv01orFe1HTZzNLaW6hYl4z5t/YN1btmJi/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IVXdxKdF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IVXdxKdF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F32CAC2BCB9; Mon, 4 May 2026 07:59:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777881565; bh=YwKzZ3hsrpIYkQts1JCSz/KBpRmwBX3YeC2nkET2p8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IVXdxKdFCxT9wKLKSmSsftJqesPVqu32qOZFWRnf/tdkyA2MXkooKHYBPgbhGe/TN uydRHxSFV+6pbW+N52iJl6N0/yLu3/xKIOkKoPqZ+J1RWblMLU0H7OqGNf9wH8krUu h+3Jhg723o85dMKDXzyFkLTdcedIdeXdmzET3PDP7HzZHIO2uWAouJnfgslQ7dOTI+ p+01VfIgi38goBtbQDlPbP95wNcDIGVjnU2Y1iaxnGUGo3GhlYzgIwEtR6ZutsJYCx wBsEpUHvrQoruBANYGYNpJC16T9SWNH11/3RsNc4pEC/GPdp285zR8LK+3vv90VBSG a8kDUGZeHQhhQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Manivannan Sadhasivam , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12.y 2/2] net: qrtr: ns: Limit the total number of nodes Date: Mon, 4 May 2026 03:59:19 -0400 Message-ID: <20260504075919.1865941-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260504075919.1865941-1-sashal@kernel.org> References: <2026050151-baked-tipper-7f00@gregkh> <20260504075919.1865941-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Manivannan Sadhasivam [ Upstream commit 27d5e84e810b0849d08b9aec68e48570461ce313 ] Currently, the nameserver doesn't limit the number of nodes it handles. This can be an attack vector if a malicious client starts registering random nodes, leading to memory exhaustion. Hence, limit the maximum number of nodes to 64. Note that, limit of 64 is chosen based on the current platform requirements. If requirement changes in the future, this limit can be increased. Cc: stable@vger.kernel.org Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace") Signed-off-by: Manivannan Sadhasivam Link: https://patch.msgid.link/20260409-qrtr-fix-v3-4-00a8a5ff2b51@oss.qualcomm.com Signed-off-by: Jakub Kicinski [ dropped comment/define changes for missing QRTR_NS_MAX_SERVERS/LOOKUPS prereqs and kept plain kzalloc instead of kzalloc_obj ] Signed-off-by: Sasha Levin --- net/qrtr/ns.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c index e1f27464279cf..adb6a4ba093db 100644 --- a/net/qrtr/ns.c +++ b/net/qrtr/ns.c @@ -69,6 +69,13 @@ struct qrtr_node { struct xarray servers; }; +/* Max nodes limit is chosen based on the current platform requirements. + * If the requirement changes in the future, this value can be increased. + */ +#define QRTR_NS_MAX_NODES 64 + +static u8 node_count; + static struct qrtr_node *node_get(unsigned int node_id) { struct qrtr_node *node; @@ -77,6 +84,11 @@ static struct qrtr_node *node_get(unsigned int node_id) if (node) return node; + if (node_count >= QRTR_NS_MAX_NODES) { + pr_err_ratelimited("QRTR clients exceed max node limit!\n"); + return NULL; + } + /* If node didn't exist, allocate and insert it to the tree */ node = kzalloc(sizeof(*node), GFP_KERNEL); if (!node) @@ -90,6 +102,8 @@ static struct qrtr_node *node_get(unsigned int node_id) return NULL; } + node_count++; + return node; } @@ -386,6 +400,7 @@ static int ctrl_cmd_bye(struct sockaddr_qrtr *from) delete_node: xa_erase(&nodes, from->sq_node); kfree(node); + node_count--; return ret; } -- 2.53.0