From nobody Tue Apr 7 13:55:58 2026 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 9AC253C9EF7; Fri, 3 Apr 2026 16:06:20 +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=1775232380; cv=none; b=ALTG+xdNxdIJrW0bnu5MaYhe+hKKiddNFyfnybrh1wEu07b7dFqx0qx140LFMXVIbWPtx2V15Rr7V4VVXO88ocLbR6qtP4FkeeT7tFJS6xyOQXm1R4glZ/4FDR4ZmMzDxmPQwF11s81dL0xAUEiUu1JENuIG5JOCozVyrrAOx1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775232380; c=relaxed/simple; bh=+IreoY8ybxDW/7yXddV+9PeSVyOUT80MAS4QP+12A3c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BzctCkjgRC/JjVFMMEqUQ8JpJUGvwD1pF23vuMN6f8eKghXK+ZIyCVtC1ht5u18uA1lZAO+3BFqHxTPFFcRYUnT+NSWmfC3A/qGsx15YmKlLhGf65u1cW4joWpQ5aDPZvNKf9F5hCDRn3xjg7SGLL2nY4+XhHgT88A+gDOZm5q0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gXxhTLMH; 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="gXxhTLMH" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7C526C4CEF7; Fri, 3 Apr 2026 16:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775232380; bh=+IreoY8ybxDW/7yXddV+9PeSVyOUT80MAS4QP+12A3c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=gXxhTLMHLxIN4e6PrEEUAylzc/yjNi5kUHkH8HkvOI5+g1tDM/88afxZelbYObUYJ 7mffASG8su8DVcsr2sbHD/mQNzWTrkbuBTCqV7VDPqCZ5IsHNprUyOVsT/c+BN29Fh hGCRuOxYQEHN16m/deTECLdE4j8ca4G3EVMYSmn3RFTfnmINxWkhimXiUHAMRXqkdF qb8Jp8exhZmdRWQ/R2wNHG8zeYGtcpAlhdyR+X+cJUA2xva9c3FSwFIyanRUBx1F/I 8pBDa8usoBRg1qzcrPPbvxamKiqEiTo5XLJFcv6kS7fUhv6yEh3A0aliTFBuelzdtd 0iKQrmIm74p0g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7246CE85371; Fri, 3 Apr 2026 16:06:20 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Fri, 03 Apr 2026 21:36:07 +0530 Subject: [PATCH v2 4/5] net: qrtr: ns: Limit the total number of nodes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260403-qrtr-fix-v2-4-f88a14859c63@oss.qualcomm.com> References: <20260403-qrtr-fix-v2-0-f88a14859c63@oss.qualcomm.com> In-Reply-To: <20260403-qrtr-fix-v2-0-f88a14859c63@oss.qualcomm.com> To: Manivannan Sadhasivam , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Manivannan Sadhasivam X-Mailer: b4 0.15.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2122; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=8L5m2aoKXkyeJv+ghcGBYXrQ5c+E3LaZMPU6xmIYTgM=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpz+V5uTT45q8F9iGETlriRibWydTqxwbT0kUTd h2ndpUVMAiJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCac/leQAKCRBVnxHm/pHO 9ZJoB/9bB8AF7kRMXLBnfps7v/P6Wt4RbCQjgGtv3WTb3y6IiMejy1SWtaZG1SPDh/8kVZZpbKR UildFw4+/tjG9orpzv4ZatzCSBzbtMYdwJb/yrYdNO/+MXhIntsN9ftncYoocSfucrrcOj9aQ0x /hSBrHVkRoa40UR+xrRG6VzwUj595J7QnbPpKqrNyT9o2KwWbh8luOU95eVYleGXwnvk3b8MsRx nv/uqnJcyPsF8bX802BafzasOwqQutSGqvXIMtuUQ4voBTxG43wFh/0nJ6EvTJHO+lBwLCvaIQc nVj7F8J3FnhiusAgokQBtGIMvXygTVeLGGLdpAp4Xwu7IHf1 X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam 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 userspa= ce") Signed-off-by: Manivannan Sadhasivam --- net/qrtr/ns.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c index c95014673135..dfb5dad9473c 100644 --- a/net/qrtr/ns.c +++ b/net/qrtr/ns.c @@ -71,12 +71,16 @@ struct qrtr_node { u32 server_count; }; =20 -/* Max server, lookup limits are chosen based on the current platform requ= irements. - * If the requirement changes in the future, these values can be increased. +/* Max nodes, server, lookup limits are chosen based on the current platfo= rm + * requirements. If the requirement changes in the future, these values ca= n be + * increased. */ +#define QRTR_NS_MAX_NODES 64 #define QRTR_NS_MAX_SERVERS 256 #define QRTR_NS_MAX_LOOKUPS 64 =20 +static u8 node_count; + static struct qrtr_node *node_get(unsigned int node_id) { struct qrtr_node *node; @@ -85,6 +89,11 @@ static struct qrtr_node *node_get(unsigned int node_id) if (node) return node; =20 + if (node_count >=3D 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 =3D kzalloc_obj(*node); if (!node) @@ -98,6 +107,8 @@ static struct qrtr_node *node_get(unsigned int node_id) return NULL; } =20 + node_count++; + return node; } =20 @@ -401,6 +412,7 @@ static int ctrl_cmd_bye(struct sockaddr_qrtr *from) delete_node: xa_erase(&nodes, from->sq_node); kfree(node); + node_count--; =20 return ret; } --=20 2.51.0