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 D068B3A961B; Fri, 15 May 2026 16:13: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=1778861600; cv=none; b=dny2/ij6EPg2ChPF8WoxoSrjxzhRdJZ81f44oEQ4XzJjPNNtESl/0SV8vBa33VLR9Q7NILfDlVsLlNixk8PhxVuV73pj2zPZrgKh6jzH+ilLcwXDplorc7ccLNBVbnX4EOmJCWYdBzy7toRgqi5Tb15lxiuB7IBHnD6sTHigeWw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778861600; c=relaxed/simple; bh=qRx1Myc65XmuaIqFkw3Sc5fHKzm2axDy9dvG/KlABdM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FSsFR/JeBqUSQGtp0lpfp+hkl18wTP1ZwA8UM/iLEpL/bYvCGWP/x8zhlK9efy+kl5RTf8aqBcklbr4PUA4pBCW/MMjJwy5tnuwO3mXugL+wQiaETg7yHgGfoSn+Y2taWmRbGpdIX2jlxmMOhPJfTgd5Bos0c8hrlkTbkCZ/CxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EvAfb4b0; 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="EvAfb4b0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67901C2BCB0; Fri, 15 May 2026 16:13:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778861600; bh=qRx1Myc65XmuaIqFkw3Sc5fHKzm2axDy9dvG/KlABdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EvAfb4b0E6qPndQA6LTondi3Q0GpIC8AO4eHSQI0rKkQcT2UImiWmIcsPgi5C5iQR fWpesgo3BSl54xT4ctSQCRnQNcRdD7WNk99sXYkwZ4lqP+9MW6MdC3hUrV3iIkGKMe A8+FksUNBi4yl3JtNNs+j2Dli+0MNTPbinjH+Vcw= 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.6 392/474] net: qrtr: ns: Limit the total number of nodes Date: Fri, 15 May 2026 17:48:21 +0200 Message-ID: <20260515154723.524991597@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154715.053014143@linuxfoundation.org> References: <20260515154715.053014143@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.6-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; } @@ -406,6 +420,7 @@ static int ctrl_cmd_bye(struct sockaddr_ delete_node: xa_erase(&nodes, from->sq_node); kfree(node); + node_count--; return ret; }