๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6688

Re: [PATCH 1/2] net: qrtr: ns: keep going when an announcement cannot be sent

#6688
From: netdev-bot+sashiko
Date: Fri, 23 Oct 2026 05:14
225 lines
15988 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 2 (1) ยท Low: 0 (1)

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] Several statements in the commit message do not match the
  code, and they overstate what the patch fixes and why.
- [Medium] announce_servers() (net/qrtr/ns.c:228-237) no longer stops at
  the first failed send.

Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but the patch
  leaves it next to the code it changes.
- [Low] This problem wasn't introduced by this patch, but it limits what
  the ctrl_cmd_new_server() change can achieve.

--

net: qrtr: ns: keep going when an announcement cannot be sent

This patch changes announce_servers() so it logs a failed announcement and
moves on to the next local server instead of returning. It also changes
ctrl_cmd_new_server() so a failed broadcast of a new local server no
longer skips the lookup_notify() loop.

> ctrl_cmd_new_server() returns
> before lookup_notify() when the broadcast of a new local server fails,
> so lookups already registered for that service, including the ones of
> remote nodes, are never told the server exists.
>
> A send failure to one node says nothing about the others. Log it and
> carry on in both places.

[Severity: Medium]
Can a remote node have a lookup in qrtr_ns.lookups at all? Lookups are
only added in ctrl_cmd_new_lookup(), and that function rejects
non-local senders:

net/qrtr/ns.c:ctrl_cmd_new_lookup() {
    ...
	/* Accept only local observers */
	if (from->sq_node != qrtr_ns.local_node)
		return -EINVAL;
    ...
}

So every lookup the patch now notifies seems to belong to a local
observer.

Does "a send failure to one node says nothing about the others" apply to
announce_servers()? Each service_announce_new(sq, srv) call in its
xa_for_each() loop goes to the same sq, the one node that sent HELLO. The
loop walks servers, not nodes.

The most likely failure there is the -EAGAIN that qrtr_node_enqueue()
returns before HELLO has gone out to that node:

net/qrtr/af_qrtr.c:qrtr_node_enqueue() {
    ...
	if (!node->hello_sent && type != QRTR_TYPE_HELLO) {
		mutex_unlock(&node->ep_lock);
		kfree_skb(skb);
		return -EAGAIN;
	}
    ...
}

In that case every later send fails the same way. With this patch alone,
would the node still learn about none of the servers?

For ctrl_cmd_new_server(), qrtr_bcast_enqueue() always returns 0. That
leaves errors raised in qrtr_sendmsg() before enqueue, which in practice
means -ENOMEM from sock_alloc_send_skb(). Could the commit message say
that this half of the change only matters under allocation failure?

The next patch in the series, "net: qrtr: hold control packets behind the
HELLO gate instead of dropping them", only touches af_qrtr.c and does not
change any of the above. Since this patch has a Fixes: tag, could the
description be made more accurate?

> diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c
> index bcb090ee79d49..dfc2cdad688f7 100644
> --- a/net/qrtr/ns.c
> +++ b/net/qrtr/ns.c
> @@ -232,7 +232,7 @@ static int announce_servers(struct sockaddr_qrtr *sq)
>  				continue;
>  
>  			pr_err("failed to announce new service\n");
> -			return ret;
> +			/* the remote needs the other servers no less */
>  		}
>  	}
>  	return 0;

[Severity: Medium]
With the return removed, announce_servers() walks every local server, up
to QRTR_NS_MAX_SERVERS (256). It calls the non-ratelimited pr_err() once
for each failed send. All sends go to the same sq, so a failure tied to
that destination happens again on every iteration.

Can one HELLO now produce up to 256 KERN_ERR lines, where before it
produced at most one?

An unprivileged local user in init_net seems able to trigger this.
qrtr_create() has no capability check. qrtr_ns_worker() dispatches on the
cmd in the payload, and ctrl_cmd_hello() checks neither origin nor
privilege before calling announce_servers().

Suppose a socket shrinks SO_RCVBUF, never reads, and sends a payload with
cmd QRTR_TYPE_HELLO to (local_node, QRTR_PORT_CTRL). Once its queue is
full, each reply is rejected in qrtr_local_enqueue():

net/qrtr/af_qrtr.c:qrtr_local_enqueue() {
    ...
	if (sock_queue_rcv_skb(&ipc->sk, skb)) {
		qrtr_port_put(ipc);
		kfree_skb(skb);
		return -ENOSPC;
	}
    ...
}

The -ENODEV check does not filter -ENOSPC, so every server logs a line.
The user can also raise the count by registering servers from other
sockets.

The same flood happens on the normal path when a remote HELLO arrives
before the local HELLO has gone out to that node, because
qrtr_node_enqueue() returns -EAGAIN for each announcement. The last patch
in the series turns that -EAGAIN into a backlog of at most 64 packets.
That narrows this path, but it still floods with more than 64 servers.
The -ENOSPC path is unchanged at the end of the series.

Would pr_err_ratelimited(), or a single message after the loop, work
better here?

[Severity: Medium]
This is a pre-existing issue, not one introduced by this patch.
ctrl_cmd_bye() and ctrl_cmd_del_client() still stop at the first error,
and in those loops each iteration goes to a different local port:

net/qrtr/ns.c:ctrl_cmd_bye() {
    ...
	xa_for_each(&local_node->servers, index, srv) {
		...
		ret = kernel_sendmsg(qrtr_ns.sock, &msg, &iv, 1, sizeof(pkt));
		if (ret < 0 && ret != -ENODEV) {
			pr_err("failed to send bye cmd\n");
			goto delete_node;
		}
	}
    ...
}

ctrl_cmd_del_client() does the same thing with "return ret".

qrtr_local_enqueue() returns -ENOSPC when a single receiver's queue is
full. Can one local server that never reads its socket then prevent every
server after it, in port order, from learning that a remote node or
client has gone away?

An unprivileged user can set this up, since anyone can bind ports
>= QRTR_MIN_EPH_SOCKET. The later patch in the series, "net: qrtr: hold
control packets behind the HELLO gate instead of dropping them", does not
change these loops.

Should these loops also log and continue?

> @@ -488,10 +488,12 @@ static int ctrl_cmd_new_server(struct sockaddr_qrtr *from,
>  
>  	if (srv->node == qrtr_ns.local_node) {
>  		ret = service_announce_new(&qrtr_ns.bcast_sq, srv);
> -		if (ret < 0) {
> +		/*
> +		 * A failed broadcast must not hide the server from the
> +		 * lookups already registered for it.
> +		 */
> +		if (ret < 0)
>  			pr_err("failed to announce new service\n");
> -			return ret;
> -		}
>  	}
>  
>  	/* Notify any potential lookups about the new server */

[Severity: Low]
This isn't a bug introduced by this patch, but qrtr_bcast_enqueue()
limits which errors this check can ever see:

net/qrtr/af_qrtr.c:qrtr_bcast_enqueue() {
    ...
	list_for_each_entry(node, &qrtr_all_nodes, item) {
		...
		skbn = pskb_copy(skb, GFP_KERNEL);
		if (!skbn)
			break;
		skb_set_owner_w(skbn, skb->sk);
		qrtr_node_enqueue(node, skbn, type, from, to);
	}
	mutex_unlock(&qrtr_node_lock);

	qrtr_local_enqueue(NULL, skb, type, from, to);

	return 0;
}

The per-node results from qrtr_node_enqueue() and qrtr_local_enqueue()
are ignored. A pskb_copy() failure skips all the remaining remote nodes,
and the function still returns 0.

That means the ret < 0 check here only sees errors from qrtr_sendmsg()
before enqueue, mainly -ENOMEM from sock_alloc_send_skb().

Under memory pressure, can the remote nodes after a failed pskb_copy()
miss this NEW_SERVER broadcast without ns.c ever finding out?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261019-upstream-qrtr-hello-gate-fix_b4-v1-0-bd420aec171b%40oss.qualcomm.com
Technical Details
Message-ID: <179273244795.3134.17153116106017337905@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350916-linux-kernel-netdev=dewy.ru
References: <20261019-upstream-qrtr-hello-gate-fix_b4-v1-1-bd420aec171b@oss.qualcomm.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350916-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 1/2] net: qrtr: ns: keep going when an announcement cannot be sent
Date: Fri, 23 Oct 2026 05:14:07 +0000
Organization: Usenet Network
Message-ID: <179273244795.3134.17153116106017337905@kernel.org>
References: <20261019-upstream-qrtr-hello-gate-fix_b4-v1-1-bd420aec171b@oss.qualcomm.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="417249"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:By4Ptvg9QiDm+9HKUejBDFfy0us= sha256:dAvlW89yfwbKrKoNsuvRcDhQBSb8P3bzwBAEd7hurok=
	sha1:FCZi9nzHZiHYkjLJWBotwxpnw0E= sha256:lslnKGOHTBLvv269FJZp7KkBX2k0+pPbepVenOCwrfU=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 12BEF1113F0; Fri, 23 Oct 2026 08:15:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.738
X-Spam-Status: No, score=-3.738 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id L2SVLQZFUeKW;
	Fri, 23 Oct 2026 08:15:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350916-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 749E4110E3A; Fri, 23 Oct 2026 08:15:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 5DB8035CD9; Fri, 23 Oct 2026 05:14:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792732460;
	b=r0L/3Xip0KVzHedSsQ6c+GueWRYjgVKf32BJ+Ma7NLKAzFlwVCHnWJREuoVC+tH36qQT
	 JQe8kOBmU0FL6hkMP2mW3tjayrbRNwhpz+A14TpEGki86XIcZ4dZPV8skqfSn5+RgJkfP
	 AWQtOpCd5UvooLDNFeMfl0Q9jN1huI+xkYwydu4POTap1XQO/nxYsQwqySxcNO+OVQ7v2
	 ZCTq+8PxCSsvWzWC+LSYsyjus/2xvYERDLgHiFt4f+GkpZjZH4dVcvSR9+iQnLilPDrbs
	 GF5f9hv1ib2WLBfsqbYnSY87dR0na/yExtmoE47OJwFnb14IZ0cjN3mLiNTitw9bfgw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792732460;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=/sy7g4D+Ct+QfqtJ/+4EFOAgm3xrpivnxb24FrepwAo=;
	b=WRUJAmzIn35Q1StPbFbm7WQzh0//Ou+5Y4oQo1MV5hxGy6NBhKdnEYQbYhyt8jTLT2kt
	 fQI3uUkO7GtAZJYlE81+JncvXCFLEg/puLfgF33k1XflL76c8CNcOtQ+wsPeEJBJqWegK
	 EZBXVH9InMnG+9d2ezDshFYHwRh0uDAHduSmjoR1eFYl0DtVVIBl3ENlKB8UB8zBaxwXK
	 VdU1q9uxrKIq+6+DzG6STxueoHN5XYXOQYZIRdhnYR6/R6nNtvr12ACq5anGwOrl1JqGu
	 t6tZhqvammWm2A1KaOqP46G22H7ec2Z+gU6x0CF2UQsTD4lGhsGsr/La9e2hwfHISXA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ROo3UrtT;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D06BA606A31B;
	Fri, 23 Oct 2026 05:14:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ROo3UrtT
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792732450;
	b=En4MRpwQwCwBTtvX0fJkbscfKstRi4kNTNDDNnlygIBB2CJj0vyIEGgm4xhIlrBqTF22
	 QP3wGQW5sWw9k++KjAqqAJLp+U2pQ70G7/YjXfvFE7DVRZfDHSwIr8cgkz6m5CAAXh29H
	 GhdLV48v7+swHDJ2/DajItUvwXWcNcPkIK201qYPvqWIoRVfF1aNnIIK0TrIgLGxz7NXj
	 BicmII9ivepPOGtfPgSDD7o+8nP5mQKnLwkjp7bro9CP3MPLQTltN33ypQmzWKSKjwFCD
	 9HR5YyN9/mdc3Jweb32d1kUH21rg81eDbnInamRTMaQlMLbgv/frC8oDMfGzbTmFWdA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792732450;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=/sy7g4D+Ct+QfqtJ/+4EFOAgm3xrpivnxb24FrepwAo=;
	b=Z7O8qvxjtpYhinrCYbCAx0WmL75CBxCM0zXO3qjelPxnRNdw+8/HdpEnAETK2VjbsqeM
	 NmNDe+Txm9qeO+PLGNFyuJykZFM5vEkcvD+XEFE0fNKPqaATUd0sBW5hv19Ub2qHuzsuT
	 O8u7iWn6S21PaoezSpEIsvNZRculnbBQ29X6CRb2/qJ5OMP5T46NpuM0CZzTpFcszuWTQ
	 J+pd1J0w4RTequXRyZaMNe2ugwybMcLZ3TM2e4ULRzEscCKDBCC1zF9Vu/FFNzzgfl0PU
	 pVJs2ax8+T7vDVdklvZlvxfQnz5OPQ4tir5fFf1To6UPOUFmkmh6eNULUWHSL3jJOlw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ROo3UrtT;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EEE2606A31F;
	Fri, 23 Oct 2026 05:14:09 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C0AD1F01825;
	Fri, 23 Oct 2026 05:14:08 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792732449;
	bh=/sy7g4D+Ct+QfqtJ/+4EFOAgm3xrpivnxb24FrepwAo=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ROo3UrtTvt2EDavuHQOPPLqtEgdgOvu6g9NK2spN10zeX08ZeMRH/3SntVRUKDqLf
	 p50ah3c5Ndwt+OtymyhR6PKZ27n3LLoaSTMLgTDjzzMKkgiydcEFTpnFYIYTb+0dNt
	 9hqLG/l/5KUQzaFa37XPLsAhkYjOE0WtPir9QDRGtxSM0TjHlclzYdRhW0CbQ1/gbc
	 Gao/Y7Wv9Xa3TL9ra8mx38uBRgQzMtMouPKFdn8puQL6outlwihfJOOlbkUeskZt4R
	 3lzQ3TbjTZQm4t1aWOLwDVPdZ+LXKrP1fwPQPev3HDdWXEUwExqS0Qbtb0lTI3kVi3
	 ADQL+S3mReYYQ==
X-Cc: mani@kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
 pabeni@redhat.com, horms@kernel.org, pranav.phansalkar@oss.qualcomm.com,
 christopher.lew@oss.qualcomm.com, deepak.singh@oss.qualcomm.com,
 linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To:  <20261019-upstream-qrtr-hello-gate-fix_b4-v1-1-bd420aec171b@oss.qualcomm.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list