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, willemb@google.com, horms@kernel.org,
netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
liuhangbin@kylinos.cn
Subject: Re: [PATCH net-next v4] selftests: net: add tests for the QRTR socket family
Date: Fri, 04 Dec 2026 13:18:58 +0000 [thread overview]
Message-ID: <179639033817.3146.2489983699723365871@kernel.org> (raw)
In-Reply-To: <20261203122145.144381-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] qrtr_endpoint.c hard-codes TEST_SRC_NODE to 5, and every frame
it writes to /dev/qrtr-tun (through v1_init() and the v2 tests) uses…
- [Medium] size_exceeds_frame (qrtr_endpoint.c:264) only sends a 52-byte
frame with size = sizeof(f) + 64 = 116.
- [Medium] bind_privileged_port() (qrtr_sock.c:201-202) uses
has_net_admin() to decide whether binding port 0x100 must succeed.
- [Medium] selftests: qrtr: qrtr_endpoint masks bind errors as SKIP on
hardcoded port
- [Low] Hangbin Liu's Tested-by from v3 is kept even though the v4
changelog says the test changes came after his run.
- [Low] The commit says the tests cover 'the CAP_NET_ADMIN boundary
documented above qrtr_port_assign()'.
--
selftests: net: add tests for the QRTR socket family
This adds tools/testing/selftests/net/qrtr with two kselftest programs.
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 a qrtr.sh wrapper loads the
modules, runs both programs and exits with the skip code if nothing
passed.
Link: https://lore.kernel.org/r/20261202120303.257866-1-muralikrishna2444b@gmail.com [v3]
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]
> Tested-by: Hangbin Liu <liuhangbin@kylinos.cn>
[Severity: Low]
The v4 notes say "keep Hangbin's Tested-by from v3; the test changes above
came after his run". Those changes are not small:
- unaligned_length and zero_size were rewritten
- capability dropping was added to bind_privileged_port and
bind_unprivileged_port
- getsockname_unbound gained a node check
- the KSFT_SKIP logic in qrtr.sh is new
The explanation is below the --- line, so it will not reach git history.
Should the Tested-by be dropped, or re-confirmed against v4?
Documentation/process/submitting-patches.rst says Tested-by tags may no
longer apply once a patch has changed substantially.
> 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..e24650c1d0a39
> --- /dev/null
> +++ b/tools/testing/selftests/net/qrtr/qrtr_endpoint.c
> @@ -0,0 +1,394 @@
[ ... ]
> +/* A node id for the test endpoint, distinct from the local node (1). */
> +#define TEST_SRC_NODE 5
[Severity: Medium]
Can this fixed node id collide with a real remote node?
This patch adds net/qrtr to the default TARGETS, and qrtr.sh loads
qrtr-tun itself. So the suite will also run as root on Qualcomm boards
with live remote processors, where node 5 is commonly the id the ADSP
firmware uses.
Every frame written to /dev/qrtr-tun claims src_node_id 5.
qrtr_endpoint_post() then calls qrtr_node_assign(), which ignores the
result of the insert:
net/qrtr/af_qrtr.c:qrtr_node_assign() {
...
spin_lock_irqsave(&qrtr_nodes_lock, flags);
radix_tree_insert(&qrtr_nodes, nid, node);
...
}
If the real node 5 is already registered, the insert fails silently. The
HELLOs from valid_hello, legacy_control_port and valid_v2_hello still reach
the name service with sq_node = 5. ctrl_cmd_hello()->announce_servers()
then sends NEW_SERVER for every local service to node 5, which is the real
firmware.
If the remote processor is not up yet, or is restarting, the tun node takes
slot 5 instead. When the fd is closed, qrtr_endpoint_unregister() queues a
QRTR_TYPE_BYE with src.sq_node = 5. ctrl_cmd_bye() then deletes every
server recorded for node 5, including any the firmware announced in that
window.
The comment only rules out the local node, and the commit message only
claims the suite is harmless on non-Qualcomm configs. Could a node id be
chosen that firmware will not use? Alternatively, could these tests skip
when other QRTR endpoints are registered?
[ ... ]
> +/*
> + * A declared size larger than the frame is rejected: it would over-read. The
> + * frame length check rejects this frame as well, so this test cannot tell the
> + * two checks apart; on 64-bit no frame can.
> + */
> +TEST_F(tun, size_exceeds_frame)
> +{
> + struct v1_frame f;
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> + f.hdr.size = htole32(sizeof(f) + 64);
[Severity: Medium]
Would this test notice the size > len check being removed on a 32-bit
kernel?
The check in qrtr_endpoint_post() is:
if (!size || size > len || len != ALIGN(size, 4) + hdrlen)
goto err;
This frame is 52 bytes with size = 116, so the length comparison also
rejects it. That means the test passes on every architecture even with
size > len removed.
On 32-bit, size_t is 32 bits and ALIGN(0xffffffff, 4) wraps to 0. A bare
32-byte v1 header with size = 0xffffffff passes the alignment, zero-size
and length checks (32 == 0 + 32). Only size > len stops skb_put_data()
being called with 0xffffffff bytes.
The file comment says isolation is impossible only on 64-bit. Should this
test also write that 32-byte frame? It is still rejected on 64-bit.
> +
> + EXPECT_EQ(-1, write(self->fd, &f, sizeof(f)));
> + EXPECT_EQ(EINVAL, 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..96ff91f21d766
> --- /dev/null
> +++ b/tools/testing/selftests/net/qrtr/qrtr_sock.c
> @@ -0,0 +1,356 @@
[ ... ]
> +static bool has_net_admin(void)
> +{
> + struct __user_cap_data_struct data[_LINUX_CAPABILITY_U32S_3] = {};
> +
> + return !net_admin_caps(data) &&
> + (data[0].effective & (1u << CAP_NET_ADMIN));
> +}
[ ... ]
> +/*
> + * A port at or above the ephemeral range may be claimed by any user, so the
> + * bind must succeed even with CAP_NET_ADMIN dropped.
> + */
> +TEST_F(qrtr, bind_unprivileged_port)
> +{
> + const __u32 want = QRTR_MIN_EPH_SOCKET + 0x1000;
[Severity: Low]
The commit message says qrtr_sock covers "the CAP_NET_ADMIN boundary
documented above qrtr_port_assign()". That comment reads:
* <QRTR_MIN_EPH_SOCKET: Specified; requires CAP_NET_ADMIN
* >QRTR_MIN_EPH_SOCKET: Specified; available to all
This leaves 0x4000 itself unspecified. The code uses
*port < QRTR_MIN_EPH_SOCKET, which makes 0x4000 unprivileged.
bind_privileged_port probes 0x3fff and this test probes 0x5000, so neither
one checks 0x4000. Suppose the check were changed to <= to match the
comment: would any test here fail?
The stale comment in af_qrtr.c was already there before this patch.
> +
> + ASSERT_EQ(0, drop_net_admin());
> + 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. With the
> + * capability the bind succeeds; after dropping it, a bind just below the
> + * range must fail with EACCES. Run as root, both sides are checked.
> + */
> +TEST_F(qrtr, bind_privileged_port)
> +{
> + int other;
> +
> + if (has_net_admin()) {
> + EXPECT_EQ(0, qrtr_bind_port(self->fd, self->node, 0x100));
[Severity: Medium]
Can this report a failure on a correct kernel when the test runs as uid 0
in a child user namespace that still shares init_net?
has_net_admin() reads the effective set with capget(), and that set is
relative to the caller's own user namespace. qrtr_port_assign() checks
against init_user_ns instead:
} else if (*port < QRTR_MIN_EPH_SOCKET && !capable(CAP_NET_ADMIN)) {
rc = -EACCES;
qrtr_create() only rejects network namespaces other than init_net. Under
"unshare -Ur ./qrtr.sh" (no -n), or a rootless container on host
networking, the fixture therefore does not skip:
- has_net_admin() returns true
- the bind to 0x100 returns EACCES
- this EXPECT_EQ fails, and qrtr.sh reports a failure
Should success only be expected when running in the initial user
namespace?
> + ASSERT_EQ(0, drop_net_admin());
> + }
[ ... ]
> @@ -0,0 +1,394 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Tests for QRTR frame validation in qrtr_endpoint_post().
> + *
> + * /dev/qrtr-tun (CONFIG_QRTR_TUN) lets userspace act as a QRTR endpoint:
> + * a write() is copied and handed to qrtr_endpoint_post(), so its length and
> + * header checks (apart from len == 0, which qrtr-tun rejects itself) are
> + * reachable from here with no Qualcomm hardware. A rejected frame makes
> + * write() fail with EINVAL; an accepted one returns the full length.
> + *
> + * Where possible, each rejected frame below fails only the check its test is
> + * named for, so removing that check makes the test fail. That is not possible
> + * for the version 1 and version 2 header length checks, nor on 64-bit for the
> + * size-larger-than-frame check: other length checks reject the same frames,
> + * so removing one of them does not change what write() returns. Those tests
> + * still check that such frames are refused.
> + *
> + * On-wire header fields are little endian, and qrtr_endpoint_post() reads the
> + * version from the first byte of the frame and decodes the rest with
> + * le32_to_cpu()/le16_to_cpu(), so every multi-byte field is built with
> + * htole32()/htole16() rather than in host order.
> + */
> +
> +#include <endian.h>
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <stdint.h>
> +#include <string.h>
> +#include <unistd.h>
> +
> +#include <linux/qrtr.h>
> +#include <sys/socket.h>
> +
> +#include "../../kselftest_harness.h"
> +
> +/* From net/qrtr/af_qrtr.c */
> +#define QRTR_PROTO_VER_1 1
> +#define QRTR_PROTO_VER_2 3
> +#define QRTR_PORT_CTRL_LEGACY 0xffff
> +
> +/* A node id for the test endpoint, distinct from the local node (1). */
> +#define TEST_SRC_NODE 5
> +
> +/* An ordinary (non-control) port, inside the unprivileged ephemeral range. */
> +#define TEST_NORMAL_PORT 0x4321
> +
> +struct qrtr_hdr_v1 {
> + __le32 version;
> + __le32 type;
> + __le32 src_node_id;
> + __le32 src_port_id;
> + __le32 confirm_rx;
> + __le32 size;
> + __le32 dst_node_id;
> + __le32 dst_port_id;
> +} __attribute__((packed));
> +
> +struct qrtr_hdr_v2 {
> + uint8_t version;
> + uint8_t type;
> + uint8_t flags;
> + uint8_t optlen;
> + __le32 size;
> + __le16 src_node_id;
> + __le16 src_port_id;
> + __le16 dst_node_id;
> + __le16 dst_port_id;
> +};
> +
> +/* One header plus one control packet: the smallest realistic valid frame. */
> +struct v1_frame {
> + struct qrtr_hdr_v1 hdr;
> + struct qrtr_ctrl_pkt pkt;
> +} __attribute__((packed));
> +
> +static void v1_init(struct v1_frame *f, uint32_t type)
> +{
> + memset(f, 0, sizeof(*f));
> + f->hdr.version = htole32(QRTR_PROTO_VER_1);
> + f->hdr.type = htole32(type);
> + f->hdr.src_node_id = htole32(TEST_SRC_NODE);
> + f->hdr.src_port_id = htole32(QRTR_PORT_CTRL);
> + f->hdr.size = htole32(sizeof(f->pkt));
> + f->hdr.dst_node_id = htole32(0);
> + f->hdr.dst_port_id = htole32(QRTR_PORT_CTRL);
> + f->pkt.cmd = htole32(type);
> +}
> +
> +/*
> + * 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)
> +{
> + struct sockaddr_qrtr sq = {};
> + socklen_t len = sizeof(sq);
> + int fd;
> +
> + fd = socket(AF_QIPCRTR, SOCK_DGRAM, 0);
> + if (fd < 0)
> + return -1;
> +
> + if (getsockname(fd, (struct sockaddr *)&sq, &len)) {
> + close(fd);
> + return -1;
> + }
> +
> + sq.sq_family = AF_QIPCRTR;
> + sq.sq_port = port;
> +
> + if (bind(fd, (struct sockaddr *)&sq, sizeof(sq))) {
> + close(fd);
> + return -1;
> + }
> +
> + *fdp = fd;
> + return 0;
> +}
> +
> +FIXTURE(tun)
> +{
> + int fd;
> +};
> +
> +FIXTURE_SETUP(tun)
> +{
> + self->fd = open("/dev/qrtr-tun", O_RDWR | O_NONBLOCK);
> + if (self->fd < 0) {
> + if (errno == ENOENT)
> + SKIP(return,
> + "no /dev/qrtr-tun: modprobe qrtr-tun, or CONFIG_QRTR_TUN=n");
> + if (errno == EACCES || errno == EPERM)
> + SKIP(return, "/dev/qrtr-tun needs root");
> + ASSERT_LE(0, self->fd);
> + }
> +}
> +
> +FIXTURE_TEARDOWN(tun)
> +{
> + if (self->fd >= 0)
> + close(self->fd);
> +}
> +
> +/* Baseline: a well formed HELLO to the control port is accepted. */
> +TEST_F(tun, valid_hello)
> +{
> + struct v1_frame f;
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> +
> + EXPECT_EQ((ssize_t)sizeof(f), write(self->fd, &f, sizeof(f)));
> +}
> +
> +/*
> + * A length that is not a multiple of four is rejected before anything else.
> + * A version 1 frame cannot isolate that check, because its header is 32 bytes
> + * and the length must equal the padded payload plus the header. A version 2
> + * header with three option bytes can: the frame below is 16 + 3 + 20 bytes,
> + * consistent with its declared size and addressed to the control port, so the
> + * alignment check is the only thing that rejects it.
> + */
> +TEST_F(tun, unaligned_length)
> +{
> + uint8_t buf[sizeof(struct qrtr_hdr_v2) + 3 +
> + sizeof(struct qrtr_ctrl_pkt)] = {};
> + struct qrtr_ctrl_pkt pkt = {};
> + struct qrtr_hdr_v2 hdr = {};
> +
> + hdr.version = QRTR_PROTO_VER_2;
> + hdr.type = QRTR_TYPE_HELLO;
> + hdr.optlen = 3;
> + hdr.size = htole32(sizeof(pkt));
> + hdr.src_node_id = htole16(TEST_SRC_NODE);
> + hdr.src_port_id = htole16((uint16_t)QRTR_PORT_CTRL);
> + hdr.dst_port_id = htole16((uint16_t)QRTR_PORT_CTRL);
> + pkt.cmd = htole32(QRTR_TYPE_HELLO);
> +
> + memcpy(buf, &hdr, sizeof(hdr));
> + memcpy(buf + sizeof(hdr) + 3, &pkt, sizeof(pkt));
> +
> + EXPECT_EQ(-1, write(self->fd, buf, sizeof(buf)));
> + EXPECT_EQ(EINVAL, errno);
> +}
> +
> +/*
> + * Only protocol versions 1 and 3 exist. Apart from the version byte both
> + * frames are valid version 1 HELLOs, so an unknown version parsed as
> + * version 1 would be accepted.
> + */
> +TEST_F(tun, bad_version)
> +{
> + struct v1_frame f;
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> + f.hdr.version = htole32(2);
> + EXPECT_EQ(-1, write(self->fd, &f, sizeof(f)));
> + EXPECT_EQ(EINVAL, errno);
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> + f.hdr.version = htole32(0xff);
> + EXPECT_EQ(-1, write(self->fd, &f, sizeof(f)));
> + EXPECT_EQ(EINVAL, errno);
> +}
> +
> +/*
> + * A frame shorter than the version 1 header cannot carry one. The size checks
> + * reject these too, so without this check write() still fails, but the
> + * header is read past the end of the frame (KASAN reports it).
> + */
> +TEST_F(tun, truncated_v1_header)
> +{
> + struct v1_frame f;
> + size_t len;
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> +
> + for (len = 4; len < sizeof(struct qrtr_hdr_v1); len += 4) {
> + EXPECT_EQ(-1, write(self->fd, &f, len));
> + EXPECT_EQ(EINVAL, errno);
> + }
> +}
> +
> +/*
> + * A frame shorter than the version 2 header cannot carry one. As above, the
> + * size checks also reject these; this check is what stops the header being
> + * read past the end of the frame.
> + */
> +TEST_F(tun, truncated_v2_header)
> +{
> + struct qrtr_hdr_v2 hdr = {};
> + size_t len;
> +
> + hdr.version = QRTR_PROTO_VER_2;
> + hdr.type = QRTR_TYPE_HELLO;
> +
> + for (len = 4; len < sizeof(hdr); len += 4) {
> + EXPECT_EQ(-1, write(self->fd, &hdr, len));
> + EXPECT_EQ(EINVAL, errno);
> + }
> +}
> +
> +/*
> + * A declared payload size of zero is rejected. Only the header is written, so
> + * the frame length equals the header length plus the (empty) padded payload
> + * and the zero-size check is the only thing that rejects it.
> + */
> +TEST_F(tun, zero_size)
> +{
> + struct v1_frame f;
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> + f.hdr.size = htole32(0);
> +
> + EXPECT_EQ(-1, write(self->fd, &f.hdr, sizeof(f.hdr)));
> + EXPECT_EQ(EINVAL, errno);
> +}
> +
> +/*
> + * A declared size larger than the frame is rejected: it would over-read. The
> + * frame length check rejects this frame as well, so this test cannot tell the
> + * two checks apart; on 64-bit no frame can.
> + */
> +TEST_F(tun, size_exceeds_frame)
> +{
> + struct v1_frame f;
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> + f.hdr.size = htole32(sizeof(f) + 64);
> +
> + EXPECT_EQ(-1, write(self->fd, &f, sizeof(f)));
> + EXPECT_EQ(EINVAL, errno);
> +}
> +
> +/* The frame length must be exactly the header plus the padded payload. */
> +TEST_F(tun, size_does_not_match_length)
> +{
> + struct v1_frame f;
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> + /* Fits in the frame, but leaves four unaccounted trailing bytes. */
> + f.hdr.size = htole32(sizeof(f.pkt) - 4);
> +
> + EXPECT_EQ(-1, write(self->fd, &f, sizeof(f)));
> + EXPECT_EQ(EINVAL, errno);
> +}
> +
> +/*
> + * NEW_SERVER and RESUME_TX are parsed as a struct qrtr_ctrl_pkt, so a
> + * payload too small to hold one must be rejected rather than read past.
> + */
> +TEST_F(tun, control_payload_too_small)
> +{
> + struct {
> + struct qrtr_hdr_v1 hdr;
> + uint32_t body;
> + } __attribute__((packed)) f;
> +
> + memset(&f, 0, sizeof(f));
> + f.hdr.version = htole32(QRTR_PROTO_VER_1);
> + f.hdr.src_node_id = htole32(TEST_SRC_NODE);
> + f.hdr.src_port_id = htole32(QRTR_PORT_CTRL);
> + f.hdr.size = htole32(sizeof(f.body));
> + f.hdr.dst_port_id = htole32(QRTR_PORT_CTRL);
> +
> + f.hdr.type = htole32(QRTR_TYPE_NEW_SERVER);
> + EXPECT_EQ(-1, write(self->fd, &f, sizeof(f)));
> + EXPECT_EQ(EINVAL, errno);
> +
> + f.hdr.type = htole32(QRTR_TYPE_RESUME_TX);
> + EXPECT_EQ(-1, write(self->fd, &f, sizeof(f)));
> + EXPECT_EQ(EINVAL, errno);
> +}
> +
> +/*
> + * DATA addressed to an ordinary port is accepted and delivered. This is the
> + * positive half of control_type_to_normal_port below: it shows that a frame
> + * to TEST_NORMAL_PORT does reach qrtr_port_lookup() and succeeds, so the
> + * EINVAL that test expects can only come from the control-type check.
> + */
> +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?)");
> +
> + v1_init(&f, QRTR_TYPE_DATA);
> + f.hdr.dst_port_id = htole32(TEST_NORMAL_PORT);
> +
> + EXPECT_EQ((ssize_t)sizeof(f), write(self->fd, &f, sizeof(f)));
> +
> + close(peer);
> +}
> +
> +/*
> + * Only DATA and RESUME_TX may be addressed to an ordinary port. A control
> + * message aimed at a normal port is rejected.
> + *
> + * A socket must be bound to the destination port for this to mean anything:
> + * with nothing bound, qrtr_port_lookup() fails and qrtr_endpoint_post()
> + * returns -EINVAL from there instead, so the test would still pass if the
> + * control-type check were removed.
> + */
> +TEST_F(tun, control_type_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?)");
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> + f.hdr.dst_port_id = htole32(TEST_NORMAL_PORT);
> +
> + EXPECT_EQ(-1, write(self->fd, &f, sizeof(f)));
> + EXPECT_EQ(EINVAL, errno);
> +
> + close(peer);
> +}
> +
> +/* The legacy 16-bit control port number is still understood. */
> +TEST_F(tun, legacy_control_port)
> +{
> + struct v1_frame f;
> +
> + v1_init(&f, QRTR_TYPE_HELLO);
> + f.hdr.dst_port_id = htole32(QRTR_PORT_CTRL_LEGACY);
> +
> + EXPECT_EQ((ssize_t)sizeof(f), write(self->fd, &f, sizeof(f)));
> +}
> +
> +/* A version 2 header is accepted on its own terms. */
> +TEST_F(tun, valid_v2_hello)
> +{
> + struct {
> + struct qrtr_hdr_v2 hdr;
> + struct qrtr_ctrl_pkt pkt;
> + } f;
> +
> + memset(&f, 0, sizeof(f));
> + f.hdr.version = QRTR_PROTO_VER_2;
> + f.hdr.type = QRTR_TYPE_HELLO;
> + f.hdr.size = htole32(sizeof(f.pkt));
> + f.hdr.src_node_id = htole16(TEST_SRC_NODE);
> + f.hdr.src_port_id = htole16((uint16_t)QRTR_PORT_CTRL);
> + f.hdr.dst_port_id = htole16((uint16_t)QRTR_PORT_CTRL);
> + f.pkt.cmd = htole32(QRTR_TYPE_HELLO);
> +
> + EXPECT_EQ((ssize_t)sizeof(f), write(self->fd, &f, sizeof(f)));
> +}
> +
> +TEST_HARNESS_MAIN
[Severity: Medium]
Should a bind() failure here really be reported as a skip?
qrtr_bind_local() returns the same -1 whether socket(), getsockname()
or bind() failed. Both data_to_normal_port and
control_type_to_normal_port turn that -1 into SKIP with the hint
"CONFIG_QRTR=n?".
That hint cannot be right here. By the time these tests run,
FIXTURE_SETUP(tun) has already opened /dev/qrtr-tun. QRTR_TUN sits
inside "if QRTR" in net/qrtr/Kconfig, so QRTR is enabled.
Only one of these failures looks like a missing prerequisite: socket()
returning EAFNOSUPPORT. qrtr_create() does that outside init_net, and
/dev/qrtr-tun can still be opened there.
A getsockname() or bind() failure means something else. Either the
kernel has regressed, or TEST_NORMAL_PORT is already taken. The
qrtr_ports table is global, so any other AF_QIPCRTR user on the system
may already hold 0x4321, and bind() then returns EADDRINUSE.
In every one of these cases both tests skip while the rest of
qrtr_endpoint passes. qrtr.sh then reports ok, and the check that
rejects control types sent to a normal port loses its only coverage
without anyone noticing.
Could the helper bind port 0 instead, read the assigned port back with
getsockname(), and put that port in dst_port_id? That avoids the
collision, and the port is still an ordinary one in the ephemeral
range. Then only socket() failing with EAFNOSUPPORT would skip, and
getsockname() or bind() failures would go through ASSERT.
A smaller point: the comment above the helper says it returns the fd.
It actually returns 0 and stores the fd in *fdp.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203122145.144381-1-muralikrishna2444b%40gmail.com
prev parent reply other threads:[~2026-12-04 13:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 12:21 [PATCH net-next v4] selftests: net: add tests for the QRTR socket family Murali Krishna
2026-12-03 14:21 ` Murali Krishna
2026-12-04 13:18 ` 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=179639033817.3146.2489983699723365871@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hangbin.liu@linux.dev \
--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=liuhangbin@kylinos.cn \
--cc=mani@kernel.org \
--cc=muralikrishna2444b@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--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