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 1EB4E1A6827; Mon, 4 May 2026 14:18:26 +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=1777904306; cv=none; b=DoDtAkUB+0u97CWrgipLpUoaVghp776+1y/+gYPUcQFNRd/OGPpJIuGZil/LJ8iRzUmlTnihcchMATXUzCCp6K1X9i+NShYCUX62Y2OBslH2WYu8/EeGtkRvxneed/qQUZNsjVPU2G5buC/KSwZR8ETSuZ8OX+rrjibSZlDJMJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777904306; c=relaxed/simple; bh=P8FbNLjKKkaoACFx4cX1Hx3WJIJcGnTWHu1pABGDw+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jChOcnAhWcTTB2fGb5xVL0kmLG0bECm+VsRB+J6pEVgeGXJC9+V5/5jQYMIrITSdXVEargRF3R1S1nj+WP10J/bhCJVu6A3f3iDn3HEhLqYKQ8oqRv4OmenOVxDmqUOpVWCjvr8Bh+E2UYbewMIaAYqQ93YK/CylHvqqvC2UD/0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FKNevAJX; 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="FKNevAJX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8DC6C2BCB8; Mon, 4 May 2026 14:18:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777904306; bh=P8FbNLjKKkaoACFx4cX1Hx3WJIJcGnTWHu1pABGDw+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FKNevAJXC4rfR370k0u56W7H9Ua1Dh/DMoBfcLVJ7higWGm7fnifVbQlUe0DeTl67 WoAC0Rd0qzJtcTXdTP43yzWg89jR79SQrj59Fiujvy6oTNVKHTfH8+lcud1zcLDJaA vX/CjTEfkwm4ozkVexgmTDKAq1dVeyHmQmF9+xyY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Manivannan Sadhasivam , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 262/275] net: qrtr: ns: Limit the total number of nodes Date: Mon, 4 May 2026 15:53:22 +0200 Message-ID: <20260504135152.775052733@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135142.929052779@linuxfoundation.org> References: <20260504135142.929052779@linuxfoundation.org> User-Agent: quilt/0.69 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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- net/qrtr/ns.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/net/qrtr/ns.c +++ b/net/qrtr/ns.c @@ -82,6 +82,13 @@ struct qrtr_node { */ #define QRTR_NS_MAX_LOOKUPS 64 +/* 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; @@ -90,6 +97,11 @@ static struct qrtr_node *node_get(unsign 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) @@ -103,6 +115,8 @@ static struct qrtr_node *node_get(unsign return NULL; } + node_count++; + return node; } @@ -409,6 +423,7 @@ static int ctrl_cmd_bye(struct sockaddr_ delete_node: xa_erase(&nodes, from->sq_node); kfree(node); + node_count--; return ret; }