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=1796359554; b=dznAQWAmEzDN/RySJZ7BSA4CY3l6d8rd3TJiHOFF/Mvtw5o6WyeltrM+e/90cbMcEYDa 9VGrbAVqKEPPB0vtvRTgZ7+v8YUO3HPYeYjyAcN3B9gWIQaYLx2mHETIZszUaVlB11hgO kyzcnxkEgVUdIlIAZjtWDEgUN9qg2aA/UxB1V9Xn/Rtllr4XzEZBdzaADujCZmSp1FXXk nJgFPUv337k+CyOJTXt0VMv0gObDtPohtrCkXrWyJaRDgZIzzLBGVRMPUKzR1gjyCawxl Ha2PBtlWmnmIs4BWqxhr/1tTcVzOJQ6eoFw6r6NCEvHPl2lBbTphfozWKuqeBlCiIZA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796359554; 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=+V5X5V5T3gTTiTLDkfy6kh+8w6HptDgzTnVxcxBkc4w=; b=qOjXyYmS2jlB0ZsuRpAZbNirX1s3g1NnFrur5918Zvu15GwDxK5sZuDpKxMZxCIAAnil rarqTppU1zmA18ky0mhl6MWbSv29M6TQySeJjljb8beSahKnqsgshwKH1c5+3JwQKzdt+ yP4+rm7ESkw0VH9inP2JpNql7xSUNSfMur6k67kJ9+kmpMYQMNwcTHYPDR9lArxLAdbfe 9pfaYRW2RON01/RPyyhGZtIQmpHgH08qT3IfEb1BLg649h/5Fh7hXz2nZqQwF4apnA9Zx smDCdAaUr7fvLpUmtWwYnfUCMuEeaHp3fawkf3nOcYHIqL+c/NgRd9xTvyT4CKpGnTQ== 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=CC3EV5s5; 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 77C84606A682; Fri, 4 Dec 2026 04:45:54 +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=CC3EV5s5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A019B1F0092C; Fri, 4 Dec 2026 04:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796359554; bh=+V5X5V5T3gTTiTLDkfy6kh+8w6HptDgzTnVxcxBkc4w=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=CC3EV5s5zK4GBv3KNAwwApS08lkxfYTZjNBAt87wt3Y6qksCpAaafJk89QV96zhqc jIOESxTLqr1tOP7S9QbNVIalx1lev6SwDmqo4WidRfHE/V9+/0LH4VO+TkOMwtH/D9 UBazosEmextI8/6MaOPV55+7S11pFZmi2NDoPs88Ab2lRWTHwaBJ6/+xgN/4wFQ3oi rplwfq3zrUxOPDP/bhPlATsxz+UNYLEcpjTnwMklyqSWHDcIZzymhL7JTNM0PKJYRq juZtKBRcS0RxevqpGd1I4Jb/XkIuPYmjcFAp7MB+BppSRyjIf6KVRdwPMiOaZK9G4O dPRFhkdzCTijw== Subject: Re: [PATCH net-next v2] 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, 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: Fri, 04 Dec 2026 04:45:53 +0000 Message-ID: <179635955318.3146.18317073987463541646@kernel.org> In-Reply-To: <20261201104515.45339-1-muralikrishna2444b@gmail.com> References: <20261201104515.45339-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 6 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 4 · Low: 2 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] The changelog says "Each rejection test malforms the frame in exactly one way, so a failure names the check that regressed". - [Medium] The changelog says qrtr_sock covers "the CAP_NET_ADMIN boundary documented above qrtr_port_assign()". - [Medium] tools/testing/selftests/net/qrtr/config sets CONFIG_QRTR_TUN=m, but nothing ever loads the qrtr-tun module. - [Medium] Every frame the tun tests send claims src_node_id = TEST_SRC_NODE (5). - [Low] data_to_normal_port (qrtr_endpoint.c:282-283) and control_type_to_normal_port (qrtr_endpoint.c:307-308) turn any… - [Low] The comment above qrtr_bind_local() (qrtr_endpoint.c:86-87) says it "Returns the fd, or -1 with errno set". -- selftests: net: add tests for the QRTR socket family This adds two kselftests for net/qrtr. qrtr_sock checks the AF_QIPCRTR bind(), port assignment and local delivery rules. qrtr_endpoint writes crafted frames to /dev/qrtr-tun to exercise the validation in qrtr_endpoint_post(), and the new directory is added to the default selftests TARGETS. > diff --git a/tools/testing/selftests/net/qrtr/config b/tools/testing/selftests/net/qrtr/config > new file mode 100644 > index 0000000000000..0bdb8a4c52116 > --- /dev/null > +++ b/tools/testing/selftests/net/qrtr/config > @@ -0,0 +1,2 @@ > +CONFIG_QRTR=m > +CONFIG_QRTR_TUN=m [Severity: Medium] When the kernel is built from this fragment, does anything load the qrtr-tun module? net/qrtr/tun.c registers qrtr_tun_miscdev with MISC_DYNAMIC_MINOR and has no MODULE_ALIAS. So /dev/qrtr-tun only appears after an explicit modprobe, and opening the path can't trigger a module load. FIXTURE_SETUP(tun) in qrtr_endpoint.c turns the resulting ENOENT into a skip: if (errno == ENOENT) SKIP(return, "no /dev/qrtr-tun: modprobe qrtr-tun, or CONFIG_QRTR_TUN=n"); The patch doesn't add a TEST_PROGS wrapper that runs modprobe either. In CI runs that use this config, wouldn't all 13 qrtr_endpoint tests skip? The core qrtr module autoloads through MODULE_ALIAS_NETPROTO(PF_QIPCRTR), so qrtr_sock is not affected. The 13/13 result in the changelog was obtained with CONFIG_QRTR_TUN=y. > 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 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Tests for QRTR frame validation in qrtr_endpoint_post(). [ ... ] > + * The frames below are deliberately malformed in one way each, so a failure > + * names the specific check that regressed. [Severity: Medium] The changelog says "Each rejection test malforms the frame in exactly one way, so a failure names the check that regressed", and this comment says the same. Is that true for every rejection test? Every check in qrtr_endpoint_post() returns -EINVAL, and the last one is: net/qrtr/af_qrtr.c:qrtr_endpoint_post() { ... if (!size || size > len || len != ALIGN(size, 4) + hdrlen) goto err; ... } The v1 header is 32 bytes, the v2 header is 16 bytes and struct qrtr_ctrl_pkt is 20 bytes. With those sizes, several of the frames below fail more than one check: - unaligned_length writes 51 bytes. That also fails 51 != ALIGN(20, 4) + 32. - zero_size has size 0 and len 52. That also fails 52 != 0 + 32. - size_exceeds_frame has size 116. That also fails 52 != 116 + 32. The one case that only size > len catches is an ALIGN() wrap on a 32-bit size_t (for example size 0xfffffffd), and no test covers it. - truncated_v2_header sends an all-zero header, so size is 0 and !size rejects it too. - truncated_v1_header prefixes of 24 and 28 bytes carry size 20, so they also fail the length equality check. If the header length check were removed, the shorter prefixes would read size from beyond the bytes written. They would still be rejected by the same check. Suppose the len & 3, !size, size > len or per-version header length check were deleted. Wouldn't the matching test still pass? The mutation test in the changelog only removed the control-type check. Could these frames be built so that only the named check fails? If not, could the comment and the changelog be reworded? [ ... ] > +/* A node id for the test endpoint, distinct from the local node (1). */ > +#define TEST_SRC_NODE 5 [Severity: Medium] On Qualcomm hardware, node 5 can already belong to a real remote processor, often the ADSP. What happens then? This patch puts net/qrtr in the default TARGETS, and arm64 defconfig builds CONFIG_QRTR_TUN=m, so CI may run the suite on such boards. Every frame here claims src_node_id 5. That includes the HELLO frames that valid_hello, legacy_control_port and valid_v2_hello expect to be accepted. When one of them is accepted, the path is: qrtr_endpoint_post() qrtr_node_assign(node, 5) radix_tree_insert() fails with -EEXIST, which is ignored node->nid is still set to 5 HELLO is delivered to the name service control port net/qrtr/ns.c:ctrl_cmd_hello() announce_servers(sq) sq->sq_node == 5 qrtr_sendmsg() qrtr_node_lookup(5) returns the real remote node Would the test then send unsolicited NEW_SERVER announcements over the real transport to a live remote processor? On close, qrtr_endpoint_unregister() only walks radix slots where *slot == node. The tun node doesn't own that slot, so no BYE is sent for it. Neither the comment nor the changelog mentions this. The changelog only says the suite is "harmless on non-Qualcomm configurations". Can the test choose a source node that can't collide with a registered remote node? [ ... ] > +/* > + * Bind a fresh socket to a given port on the local node. Returns the fd, or > + * -1 with errno set. bind() insists the address name the socket's own node, > + * so that is read back from the socket rather than assumed. > + */ > +static int qrtr_bind_local(int *fdp, uint32_t port) > +{ [ ... ] > + *fdp = fd; > + return 0; > +} [Severity: Low] This isn't a bug, but the comment says qrtr_bind_local() "Returns the fd", while the function returns 0 on success and passes the fd back through *fdp. Both current callers use the 0/-1 convention, which matches the code. [ ... ] > +TEST_F(tun, data_to_normal_port) > +{ > + struct v1_frame f; > + int peer; > + > + if (qrtr_bind_local(&peer, TEST_NORMAL_PORT)) > + SKIP(return, "cannot bind AF_QIPCRTR port (CONFIG_QRTR=n?)"); [Severity: Low] Can CONFIG_QRTR=n be the cause at this point? This body only runs after FIXTURE_SETUP(tun) has opened /dev/qrtr-tun. QRTR_TUN sits inside "if QRTR" in net/qrtr/Kconfig. More likely causes are: - EADDRINUSE on the fixed port 0x4321. - EAFNOSUPPORT from qrtr_create() in a non-init netns. The char device isn't netns-scoped. - A regression in qrtr_bind(). In each case this positive control becomes a skip with the wrong reason. The control_type_to_normal_port comment relies on this test running: "so the EINVAL that test expects can only come from the control-type check". control_type_to_normal_port uses the same skip. FIXTURE_SETUP(qrtr) in qrtr_sock.c also reports EAFNOSUPPORT from a non-init netns as "CONFIG_QRTR=n?". Should a bind failure here fail the test, or at least report the errno? [ ... ] > 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 @@ [ ... ] > +/* > + * 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()". This test branches on geteuid() instead. The kernel checks the capability: net/qrtr/af_qrtr.c:qrtr_port_assign() { ... } else if (*port < QRTR_MIN_EPH_SOCKET && !capable(CAP_NET_ADMIN)) { rc = -EACCES; ... } Won't this report a failure whenever euid and capability disagree? Root without CAP_NET_ADMIN in the init user namespace gets -EACCES, but the test expects 0. Examples are a container sharing the host network namespace with default capabilities, unshare -U with a root mapping, or capsh --drop=cap_net_admin. A non-root process that holds CAP_NET_ADMIN gets 0, but the test expects EACCES. QRTR sockets only work in init_net, but all of these setups can still be in init_net. Would checking the effective CAP_NET_ADMIN capability match the kernel behaviour better? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201104515.45339-1-muralikrishna2444b%40gmail.com