From: Murali Krishna <muralikrishna2444b@gmail.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: Murali Krishna <muralikrishna2444b@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>, Hui Peng <benquike@gmail.com>,
linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH net] net: qrtr: ns: reject BYE from local sockets
Date: Fri, 4 Dec 2026 09:17:27 +0530 [thread overview]
Message-ID: <20261204034736.44740-1-muralikrishna2444b@gmail.com> (raw)
ctrl_cmd_bye() acts on whichever node sent the BYE. Any local socket,
including an unprivileged one, can send to the name server's control
port, and a local sender's node is the local node. Such a BYE makes the
name server delete every server registered on the local node, announce
DEL_SERVER for each to the other nodes and to local lookups, and free
the local node's record. The services stay unlisted until they register
again.
The other handlers already stop a local sender from acting for anyone
but itself: a local NEW_SERVER or DEL_SERVER applies to the sender's
own port, a local DEL_CLIENT must come from the port being closed, and
DEL_LOOKUP removes only the sender's lookups. A genuine BYE is always
for a remote node: qrtr_endpoint_unregister() sends one for each node
an endpoint carried, and a remote node can send its own. Reject a BYE
from the local node.
Hui Peng reported this with a patch that required a BYE to come from
the control port [1]. As its review noted, a remote BYE can carry the
legacy control port 0xffff as its source, since qrtr_endpoint_post()
maps the legacy value only for the destination port, so that check
could also drop genuine BYEs. Checking for a local sender, as the
review suggested, leaves remote BYEs alone.
It was found again by an AI coding assistant while working on an IPA
fix that involves the same BYE path, and reproduced as an unprivileged
user on a distribution 7.0 kernel: after one socket sends a
QRTR_TYPE_BYE control packet to the local control port, the name server
no longer lists a service registered by another socket, and a lookup
client gets DEL_SERVER for it, while a PING sent the same way changes
nothing. The fix itself is build-tested only (arm64, W=1). The fix and
this message were drafted with an LLM coding assistant and reviewed by
me.
Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
Reported-by: Hui Peng <benquike@gmail.com>
Closes: https://lore.kernel.org/20260919212850.3240353-1-benquike@gmail.com [1]
Cc: stable@vger.kernel.org
Signed-off-by: Murali Krishna <muralikrishna2444b@gmail.com>
---
Hui, your patch for this has been at changes-requested since September,
so I picked it up and kept you as Reported-by. This version only rejects
a BYE from a local sender, as the review of your patch suggested, and
leaves its short-packet part alone.
I have a small unprivileged test program that shows the problem and can
send it to the maintainers if it helps.
net/qrtr/ns.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c
index 8209573221a5..ab75992224e0 100644
--- a/net/qrtr/ns.c
+++ b/net/qrtr/ns.c
@@ -347,6 +347,10 @@ static int ctrl_cmd_bye(struct sockaddr_qrtr *from)
iv.iov_base = &pkt;
iv.iov_len = sizeof(pkt);
+ /* Only a remote node goes away; a local socket can't say BYE for one */
+ if (from->sq_node == qrtr_ns.local_node)
+ return -EINVAL;
+
node = node_get(from->sq_node);
if (!node)
return 0;
base-commit: c1c39137dcc3134010566ff29a81c93124efa539
--
2.43.0
reply other threads:[~2026-12-04 3:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204034736.44740-1-muralikrishna2444b@gmail.com \
--to=muralikrishna2444b@gmail.com \
--cc=benquike@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=mani@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox