Netdev List
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH net-next v2] selftests: net: add tests for the QRTR socket family
Date: Fri, 04 Dec 2026 04:45:53 +0000	[thread overview]
Message-ID: <179635955318.3146.18317073987463541646@kernel.org> (raw)
In-Reply-To: <20261201104515.45339-1-muralikrishna2444b@gmail.com>

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

      parent reply	other threads:[~2026-12-04  4:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 10:44 [PATCH net-next v2] selftests: net: add tests for the QRTR socket family Murali Krishna
2026-12-02  9:17 ` Hangbin Liu
2026-12-02 11:56   ` Murali Krishna
2026-12-04  4:45 ` netdev-bot+sashiko [this message]

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=179635955318.3146.18317073987463541646@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=muralikrishna2444b@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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