From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796302104; b=l3n6zC+R++4neNXS1tLVxlNsbdKOzCCGfB4QJwUSreLhVt4PKvaUGRiQdwwBFl3X6KaE dQPo8YJyw+bT5tZvjRE/0NAmtvAoyFvMJKWANPFkGZknesNxaY0nMZB0AVY7dq3YS6TlM Alha0JS5t+YOGlKRdFF7MdQGQqkx0vTE39z9HzH+sOal0lpyftv7Ahs4k+wTK6F1i3ru4 H258HZl0Dg8Vt4ufYC09ev5U99Of5l1M9iVNIuDl/fs7NRWPYuxmj99gLRvXdFXfY0RT9 Pr6P6Bm7YGPYoxcFuCOllygbf52qollfD/PEmBDzHODWbJURgLifi5amomXb2Bq0kpg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796302104; 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=soYOQ5PRpbtkCwKdX6yZkdKpguT9OlRbu7HHP5C2sn8=; b=0WrT/BRXeHg0oHu+1Q5C/lyasF4/LbJGs4JUKzJQCbqFJ/lR1KJyI5eoUeCXbHgRUNAw ES03XYpAKp35zThi0Y40HvgE0440BvdcYp7aKqe0s4evITWl2g1q+Ot/K+0+xPpyr4HKy mWA48NZ5LMDLemRmHS1KGcxYWx94XBd7RZDJmwKyM3FY2kdAnDATdEmzGJns/YJ/AK53K e3Fnn1e+Uz/VBzYeC66srTGxYKxKa/ndC+U+W6oKwdi8MVDuIUPVA5AO5Yoabox2/eNAn nahf/kXl0iVS++S3zEp4STOCeHHcjaCI3Pkx/kBqL4Qak51UftLCxasTMUMdJYkR78w== 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=PhzyEN9J; arc=none smtp.remote-ip=100.103.45.18 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 372C9606A32C; Thu, 3 Dec 2026 12:48:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PhzyEN9J Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EF491F00899; Thu, 3 Dec 2026 12:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796302103; bh=soYOQ5PRpbtkCwKdX6yZkdKpguT9OlRbu7HHP5C2sn8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=PhzyEN9JvOvLjZSGd81+rK664CtUmYh2FvZU3OprE/9YhgUERw1VwhRoITybNFWA4 k7P9ZeIyBMEY8oORobvseb3TDS7UZfRy/Tv4479f8LWQ416EHhow2KkiZYuOm8C0rU cCluvbTmS3E0nCs1zfmEaYFpUcnWrAqnYTihENH0bWNQTZ/LkJOKiA85gHNkO2RNfR ZduELpnDihkzDVXc7B6fS8rZoQRBFAhLGyiTDm1SRFGp8LnbSzDkNIPU1+zKv2lsRf UKp6LENgC+laUqR6ctyXIUTKK/NaWw3ziSDdUUvPlQo6+p2HvOtTPH83cRbfMZrwfU MwJBJDDUiXBQA== Subject: Re: [PATCH net-next v3] selftests: net: add tests for the QRTR socket family From: netdev-bot+sashiko@kernel.org To: muralikrishna2444b@gmail.com Cc: mani@kernel.org, shuah@kernel.org, hangbin.liu@linux.dev, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 03 Dec 2026 12:48:22 +0000 Message-ID: <179630210271.3146.11727363632224442979@kernel.org> In-Reply-To: <20261202120303.257866-1-muralikrishna2444b@gmail.com> References: <20261202120303.257866-1-muralikrishna2444b@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 4 · Low: 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] qrtr_endpoint.c gives the fake /dev/qrtr-tun endpoint the fixed node id TEST_SRC_NODE = 5. - [Medium] qrtr.sh passes on only the binaries' failure status, so it exits 0 (PASS) whenever nothing actually runs: - CONFIG_QRTR is not… - [Medium] The commit message says the suite covers the CAP_NET_ADMIN boundary, but bind_privileged_port in qrtr_sock.c does not test it… - [Medium] The qrtr_endpoint.c header comment (lines 11-12) and the commit message say each frame is malformed in exactly one way, so a… - [Low] Since commit 3b536db8fb32, qrtr_create() in net/qrtr/af_qrtr.c returns -EAFNOSUPPORT for any network namespace other than init_net… -- selftests: net: add tests for the QRTR socket family This adds tools/testing/selftests/net/qrtr with two programs. qrtr_sock tests the AF_QIPCRTR bind, port and send rules on the local node. qrtr_endpoint writes crafted frames to /dev/qrtr-tun to test the frame validation in qrtr_endpoint_post(), and a qrtr.sh wrapper loads the modules and runs both. Link: https://lore.kernel.org/r/20261201104515.45339-1-muralikrishna2444b@gmail.com [v2] Link: https://lore.kernel.org/r/20261124150753.115914-1-muralikrishna2444b@gmail.com [v1] > diff --git a/tools/testing/selftests/net/qrtr/qrtr.sh b/tools/testing/selftests/net/qrtr/qrtr.sh > new file mode 100755 > index 0000000000000..031cadd842a1f > --- /dev/null > +++ b/tools/testing/selftests/net/qrtr/qrtr.sh > @@ -0,0 +1,26 @@ [ ... ] > +# Only failure is propagated. kselftest_harness exits KSFT_PASS even when > +# every test skipped, so a skip cannot be detected from the exit status here. > + > +modprobe -q qrtr 2>/dev/null > +modprobe -q qrtr-tun 2>/dev/null > + > +ret=0 > + > +for t in qrtr_sock qrtr_endpoint; do > + echo "# $t" > + ./"$t" || ret=$? > +done > + > +exit $ret [Severity: Medium] Doesn't this script still report PASS whenever nothing actually ran? The modprobe results are ignored, and only a non-zero exit from the binaries is passed on. kselftest_harness ends with ksft_exit(ret == 0), which exits KSFT_PASS even when every test skipped. So the suite reports PASS when: - CONFIG_QRTR is not set and every test skips. - The script runs as non-root. modprobe then fails silently, and all 13 qrtr_endpoint tests skip with "/dev/qrtr-tun needs root" because the node is mode 0600. - The run is outside init_net (see the qrtr_sock.c comment below). The v3 notes say qrtr.sh was added so the suite does not report skips as passes. As written, it only handles the case where the module exists but is not loaded. A skip can't be seen in the binaries' exit status. Could the script check its own prerequisites first instead, and exit with ksft_skip (4) as other net selftest wrappers do? It could check for root, run [ -c /dev/qrtr-tun ], and confirm that modprobe succeeded. > diff --git a/tools/testing/selftests/net/qrtr/qrtr_endpoint.c b/tools/testing/selftests/net/qrtr/qrtr_endpoint.c > new file mode 100644 > index 0000000000000..c38bc69cb4ce9 > --- /dev/null > +++ b/tools/testing/selftests/net/qrtr/qrtr_endpoint.c > @@ -0,0 +1,350 @@ [ ... ] > + * The frames below are deliberately malformed in one way each, so a failure > + * names the specific check that regressed. [Severity: Medium] The commit message makes the same claim: Each test malforms a frame in exactly one way, so a failure names the check that regressed. Does that hold for every test here? qrtr_endpoint_post() ends with: net/qrtr/af_qrtr.c:qrtr_endpoint_post() { ... if (!size || size > len || len != ALIGN(size, 4) + hdrlen) goto err; ... } The final length check rejects several of these frames by itself. Those tests would still pass if the check they are named after were removed. For reference, sizeof(struct qrtr_hdr_v1) is 32 and sizeof(struct v1_frame) is 52: - unaligned_length writes 51 bytes with size=20. Without the len & 3 check, 51 != ALIGN(20, 4) + 32 still rejects it. - truncated_v1_header and truncated_v2_header use len < hdrlen, which can never equal ALIGN(size, 4) + hdrlen. Without the len < sizeof(*v1) and len < sizeof(*v2) guards, the kernel would read past the kzalloc(len) buffer from qrtr_tun_write_iter() and still return -EINVAL. Only KASAN would notice. - zero_size sends 52 bytes with size=0. Without the !size check, 52 != 0 + 32 still rejects it. Only a 32-byte header-only frame would test that check alone. - size_exceeds_frame uses size=116 and len=52. Without the size > len check, 52 != 116 + 32 still rejects it. Could these frames be built so that the named check is the only one that fails? Otherwise, could the comment and changelog be changed? [ ... ] > +/* A node id for the test endpoint, distinct from the local node (1). */ > +#define TEST_SRC_NODE 5 [Severity: Medium] Is node 5 safe to use on Qualcomm hardware? The only reason given is that it differs from the local node. On many Qualcomm SoCs, 5 is a real remote processor's QRTR node id, commonly the ADSP. Since net/qrtr is added to the default TARGETS, this suite will also run on Qualcomm boards. Suppose the real node already owns nid 5. valid_hello, legacy_control_port and valid_v2_hello send HELLO frames with src_node 5 to QRTR_PORT_CTRL. qrtr_node_assign() ignores the radix_tree_insert() failure, but still sets the tun node's nid to 5: net/qrtr/af_qrtr.c:qrtr_node_assign() { ... radix_tree_insert(&qrtr_nodes, nid, node); if (node->nid == QRTR_EP_NID_AUTO) WRITE_ONCE(node->nid, nid); ... } The HELLO then reaches the name server: qrtr_endpoint_post() HELLO queued to the name server socket ctrl_cmd_hello() announce_servers() NEW_SERVER for every local service sent to node 5 by kernel_sendmsg() Node 5 resolves to the real remote processor, so the selftest sends unsolicited control traffic to live firmware. Now suppose the tun node takes nid 5 first, for example while the ADSP boots or restarts during the test. Traffic for node 5 is then routed to /dev/qrtr-tun. When the fd closes, qrtr_endpoint_unregister() sends a BYE for node 5 to the name server. ctrl_cmd_bye() then deletes every server registered under node 5. The changelog only says "the suite is harmless on non-Qualcomm configs". Would a node id that Qualcomm firmware does not use avoid both cases? It would need to be a high value that still fits in the 16-bit v2 header. [ ... ] > diff --git a/tools/testing/selftests/net/qrtr/qrtr_sock.c b/tools/testing/selftests/net/qrtr/qrtr_sock.c > new file mode 100644 > index 0000000000000..592e4e429b975 > --- /dev/null > +++ b/tools/testing/selftests/net/qrtr/qrtr_sock.c > @@ -0,0 +1,298 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Tests for the AF_QIPCRTR socket address family. > + * > + * These exercise the port assignment contract documented above > + * qrtr_port_assign() in net/qrtr/af_qrtr.c, the bind() address rules in > + * qrtr_bind(), and local datagram delivery between two sockets on the local > + * node. No QRTR endpoint and no Qualcomm hardware is required: the local > + * node always exists. > + */ [ ... ] > +FIXTURE_SETUP(qrtr) > +{ > + struct sockaddr_qrtr sq = {}; > + socklen_t len = sizeof(sq); > + > + self->fd = socket(AF_QIPCRTR, SOCK_DGRAM, 0); > + if (self->fd < 0 && > + (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT)) > + SKIP(return, "AF_QIPCRTR not supported (CONFIG_QRTR=n?)"); [Severity: Low] The header comment and the commit message both say "the local node always exists". Is that still true outside init_net? Since commit 3b536db8fb32, qrtr_create() returns -EAFNOSUPPORT for any namespace other than init_net: net/qrtr/af_qrtr.c:qrtr_create() { ... if (!net_eq(net, &init_net)) return -EAFNOSUPPORT; ... } run_kselftest.sh -n/--netns runs each test in its own namespace. In that mode, this fixture skips all 12 qrtr_sock tests with "AF_QIPCRTR not supported (CONFIG_QRTR=n?)". data_to_normal_port and control_type_to_normal_port in qrtr_endpoint.c skip with "cannot bind AF_QIPCRTR port (CONFIG_QRTR=n?)". qrtr.sh still exits PASS. The tests were run on a 7.0.0-44-generic distro kernel, which may be older than this restriction. Could the skip messages name the init_net restriction? Could qrtr.sh also detect and report a run outside init_net? [ ... ] > +/* A port at or above the ephemeral range may be claimed by any user. */ > +TEST_F(qrtr, bind_unprivileged_port) > +{ > + const __u32 want = QRTR_MIN_EPH_SOCKET + 0x1000; > + > + ASSERT_EQ(0, qrtr_bind_port(self->fd, self->node, want)); > + EXPECT_EQ(want, qrtr_port(_metadata, self->fd)); > +} > + > +/* > + * A port below the ephemeral range requires CAP_NET_ADMIN. As a normal user > + * this must fail with EACCES; as root it must succeed. Both directions are > + * checked so the test says something either way. > + */ > +TEST_F(qrtr, bind_privileged_port) > +{ > + int ret = qrtr_bind_port(self->fd, self->node, 0x100); > + > + if (geteuid() == 0) { > + EXPECT_EQ(0, ret); > + } else { > + EXPECT_EQ(-1, ret); > + EXPECT_EQ(EACCES, errno); > + } > +} [Severity: Medium] The changelog says qrtr_sock covers "the CAP_NET_ADMIN boundary documented above qrtr_port_assign()". Do these two tests actually cover it? The kernel checks a capability, not the uid: net/qrtr/af_qrtr.c:qrtr_port_assign() { ... } else if (*port < QRTR_MIN_EPH_SOCKET && !capable(CAP_NET_ADMIN)) { rc = -EACCES; ... } qrtr_create() only requires init_net, not init_user_ns, so the result of geteuid() == 0 and capable(CAP_NET_ADMIN) can differ: - A uid 0 process without CAP_NET_ADMIN gets EACCES, but the test expects 0. This includes a host-network container with default caps, unshare -U -r without a new netns, and capsh --drop=cap_net_admin. - A non-root process with CAP_NET_ADMIN from file or ambient caps succeeds, but the test expects EACCES. qrtr.sh needs root for modprobe and /dev/qrtr-tun, and it does not drop privileges for qrtr_sock. Under the intended runner, the EACCES branch never runs. bind_unprivileged_port likewise cannot show that the range is open to non-root users. If the capable() check were removed, would anything in this suite fail? The tests also never probe the edge of the range. They use 0x100 and QRTR_MIN_EPH_SOCKET + 0x1000, but not QRTR_MIN_EPH_SOCKET - 1 or QRTR_MIN_EPH_SOCKET, so changing < to <= would go unnoticed. This part is pre-existing and was not introduced by this patch, but the boundary is also unclear in the kernel. The comment above qrtr_port_assign() says: * >QRTR_MIN_EPH_SOCKET: Specified; available to all while the code treats >= QRTR_MIN_EPH_SOCKET as unprivileged. Could the test check CAP_NET_ADMIN directly, for example with capget()? It could then drop the capability for the deny case and probe both QRTR_MIN_EPH_SOCKET - 1 and QRTR_MIN_EPH_SOCKET. [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202120303.257866-1-muralikrishna2444b%40gmail.com