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 D8EC7378D8C; Mon, 4 May 2026 14:01:15 +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=1777903275; cv=none; b=GjGCz5+63NCN3PE58OdxjjgFm+qu7AkSSPjBQCQqYNZDJ3jppaCNuSRVnX4VtHfwEGntLSc0yHCwXVq+/ffAQx5nZHsLlC3BUGRRPuYspjSPNjgrxaTZHemDhcH0yVfPvYLVg7Gnwe/z48EPeFdR8ekO1D25AdcnycYW9bPdqps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903275; c=relaxed/simple; bh=R+9bURJwPJBgvN3+r/mse82cIR97nPPaQa9XKhGo9P0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OP2+kpIURDg0WiZ5Y+/QJNIke2qNAk1QOsaQHbEZOXYLAfcptc0+jb1Dbx0ZdnKV6EUAAWsj+Cz1ukC2bY0Lt7zVTb/Vw4il2v5tVHNp5HitaSjGwSlHcS6mM1qOo07Z+7OLqxZ7Dr3ZgM5Jf+IZvmgVE0mVKy+C9u4o4IzupdA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2T8edrGf; 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="2T8edrGf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E76BC2BCB8; Mon, 4 May 2026 14:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777903275; bh=R+9bURJwPJBgvN3+r/mse82cIR97nPPaQa9XKhGo9P0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2T8edrGfVj8XA6gTOFSz3UAK1kcyG4YHEcSMwOK/W4I3tJNEujOS3ngi9UTDWiKup 30vBFCn6EYaUmwAzb4qEd+W3YdK2gpg70xc0L9TamwPS8pteoBbPH7IAnJeXXLpYtz BJJeCGVmIzeyPjrHcrDwWy3fXQ1Feo5TB28OyeJk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Manivannan Sadhasivam , Jakub Kicinski Subject: [PATCH 7.0 138/307] net: qrtr: ns: Limit the maximum number of lookups Date: Mon, 4 May 2026 15:50:23 +0200 Message-ID: <20260504135147.976978620@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135142.814938198@linuxfoundation.org> References: <20260504135142.814938198@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 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Manivannan Sadhasivam commit 5640227d9a21c6a8be249a10677b832e7f40dc55 upstream. Current code does no bound checking on the number of lookups a client can perform. Though the code restricts the lookups to local clients, there is still a possibility of a malicious local client sending a flood of NEW_LOOKUP messages over the same socket. Fix this issue by limiting the maximum number of lookups to 64 globally. Since the nameserver allows only atmost one local observer, this global lookup count will ensure that the lookups stay within the limit. 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-2-00a8a5ff2b51@oss.qualcomm.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/qrtr/ns.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/net/qrtr/ns.c +++ b/net/qrtr/ns.c @@ -22,6 +22,7 @@ static struct { struct socket *sock; struct sockaddr_qrtr bcast_sq; struct list_head lookups; + u32 lookup_count; struct workqueue_struct *workqueue; struct work_struct work; void (*saved_data_ready)(struct sock *sk); @@ -71,10 +72,11 @@ struct qrtr_node { u32 server_count; }; -/* Max server limit is chosen based on the current platform requirements. If the - * requirement changes in the future, this value can be increased. +/* Max server, lookup limits are chosen based on the current platform requirements. + * If the requirement changes in the future, these values can be increased. */ #define QRTR_NS_MAX_SERVERS 256 +#define QRTR_NS_MAX_LOOKUPS 64 static struct qrtr_node *node_get(unsigned int node_id) { @@ -434,6 +436,7 @@ static int ctrl_cmd_del_client(struct so list_del(&lookup->li); kfree(lookup); + qrtr_ns.lookup_count--; } /* Remove the server belonging to this port but don't broadcast @@ -551,6 +554,11 @@ static int ctrl_cmd_new_lookup(struct so if (from->sq_node != qrtr_ns.local_node) return -EINVAL; + if (qrtr_ns.lookup_count >= QRTR_NS_MAX_LOOKUPS) { + pr_err_ratelimited("QRTR client node exceeds max lookup limit!\n"); + return -ENOSPC; + } + lookup = kzalloc_obj(*lookup); if (!lookup) return -ENOMEM; @@ -559,6 +567,7 @@ static int ctrl_cmd_new_lookup(struct so lookup->service = service; lookup->instance = instance; list_add_tail(&lookup->li, &qrtr_ns.lookups); + qrtr_ns.lookup_count++; memset(&filter, 0, sizeof(filter)); filter.service = service; @@ -599,6 +608,7 @@ static void ctrl_cmd_del_lookup(struct s list_del(&lookup->li); kfree(lookup); + qrtr_ns.lookup_count--; } }