From: netdev-bot+sashiko@kernel.org
To: o.rempel@pengutronix.de
Cc: robin@protonic.nl, socketcan@hartkopp.net, mkl@pengutronix.de,
shuah@kernel.org, kernel@pengutronix.de,
linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, fmaurer@redhat.com,
mailhol@kernel.org, alexander.hoelzl@gmx.net,
quchaosheng000406@163.com, penguin-kernel@I-love.SAKURA.ne.jp,
kuba@kernel.org
Subject: Re: [PATCH can-next v2 9/9] selftests: can: check SO_J1939_PROMISC receive effect
Date: Fri, 06 Nov 2026 05:35:26 +0000 [thread overview]
Message-ID: <179394332621.488853.1609910990759756381@kernel.org> (raw)
In-Reply-To: <20261104-j1939-selftests-v2-9-cf797c83317b@pengutronix.de>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In TEST_F(j1939_opts, promisc_receive)
(tools/testing/selftests/net/can/test_j1939_opts.c), the post-promisc…
--
selftests: can: check SO_J1939_PROMISC receive effect
This adds a J1939 selftest that checks SO_J1939_PROMISC changes what the
RX path delivers. It sends two probe frames, each missing either the bound
address or the bound PGN, once before and once after enabling the flag.
Only the frames sent after enabling the flag are expected to arrive.
> diff --git a/tools/testing/selftests/net/can/test_j1939_opts.c b/tools/testing/selftests/net/can/test_j1939_opts.c
> index 10d0e37984027..bbf2698de7d94 100644
> --- a/tools/testing/selftests/net/can/test_j1939_opts.c
> +++ b/tools/testing/selftests/net/can/test_j1939_opts.c
[ ... ]
> +static const struct {
> + uint8_t da;
> + pgn_t pgn;
> +} promisc_probes[] = {
> + { SA_RX, PGN_B }, /* the bound address, another PGN */
> + { SA_OTHER, PGN_A }, /* another address, the bound PGN */
> +};
> +
> +/* SO_J1939_PROMISC delivers frames that do not match the bound (addr, pgn). */
> +TEST_F(j1939_opts, promisc_receive)
> +{
> + uint8_t tx_buf[CAN_MAX_DLEN];
> + uint8_t rx_buf[CAN_MAX_DLEN];
> + int enable = 1;
> + size_t i;
> +
> + fill_pattern(tx_buf, sizeof(tx_buf));
[ ... ]
> + for (i = 0; i < ARRAY_SIZE(promisc_probes); i++) {
> + ASSERT_TRUE(j1939_sendto_ok(self->tx, tx_buf, sizeof(tx_buf),
> + self->ifindex, J1939_NO_NAME,
> + promisc_probes[i].da,
> + promisc_probes[i].pgn))
> + TH_LOG("sendto probe %zu failed: %d", i, errno);
> + EXPECT_EQ(recv_timeout(self->rx, rx_buf, sizeof(rx_buf),
> + J1939_NEG_RECV_TIMEOUT_MS), -1)
> + TH_LOG("probe %zu was received without promisc", i);
> + }
[ ... ]
> + for (i = 0; i < ARRAY_SIZE(promisc_probes); i++) {
> + ASSERT_TRUE(j1939_sendto_ok(self->tx, tx_buf, sizeof(tx_buf),
> + self->ifindex, J1939_NO_NAME,
> + promisc_probes[i].da,
> + promisc_probes[i].pgn))
> + TH_LOG("sendto probe %zu failed: %d", i, errno);
> + EXPECT_TRUE(recv_verify_ok(self->rx, tx_buf, sizeof(tx_buf),
> + J1939_RECV_TIMEOUT_MS))
> + TH_LOG("probe %zu not received despite promisc", i);
[Severity: Low]
Can this check confirm that the message it read is really
promisc_probes[i]?
tx_buf is filled once by fill_pattern(), so all four frames carry the same
payload. recv_verify_ok() passes src = NULL, and recvfrom_verify_ok() in
j1939_tests.h only checks the length and the payload:
tools/testing/selftests/net/can/j1939_tests.h:recvfrom_verify_ok() {
...
ok = n == want_len && !memcmp(want, rx_buf, len);
...
}
This means a stale or duplicated message in the rx queue can pass the
check for a different probe. For example, on a buggy kernel:
1. The pre-promisc probe 1 ({SA_OTHER, PGN_A}) gets delivered after the
300 ms J1939_NEG_RECV_TIMEOUT_MS window, so the
EXPECT_EQ(recv_timeout(...), -1) check still passes.
2. Post-promisc probe 0 then reads that stale probe 1 message and passes.
3. Post-promisc probe 1 reads the real probe 0 and passes, even if
promisc never delivered probe 1.
Both the leak before promisc and the missing delivery after promisc would
go unnoticed. A kernel that delivers duplicates could hide a missing probe
in the same way.
Under normal timing this does catch the regression the commit message
targets (flag stored but ignored), because every post-promisc
recv_verify_ok() times out.
The v2 notes say the test should "check the address and the PGN filter
each on its own". The kernel reports the PGN in msg_name, and the two
probes use different PGNs. Could the post-promisc loop call
recvfrom_verify_ok() with a struct sockaddr_can and check that
src.can_addr.j1939.pgn matches promisc_probes[i].pgn? Giving each probe
its own payload would work too.
> + }
> +}
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261104-j1939-selftests-v2-0-cf797c83317b%40pengutronix.de
next prev parent reply other threads:[~2026-11-06 5:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 16:17 [PATCH can-next v2 0/9] selftests: can: add J1939 socket and transport tests Oleksij Rempel
2026-11-04 16:17 ` [PATCH can-next v2 1/9] selftests: can: install net/lib.sh with the CAN tests Oleksij Rempel
2026-11-04 16:17 ` [PATCH can-next v2 2/9] selftests: can: add J1939 test helper header and library Oleksij Rempel
2026-11-06 5:35 ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 3/9] selftests: can: add J1939 base functional tests Oleksij Rempel
2026-11-06 5:35 ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 4/9] selftests: can: add J1939 socket option and metadata tests Oleksij Rempel
2026-11-06 5:35 ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 5/9] selftests: can: add J1939 addressing and concurrency tests Oleksij Rempel
2026-11-06 5:35 ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 6/9] selftests: can: add J1939 wire-format tests against CAN_RAW Oleksij Rempel
2026-11-06 5:35 ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 7/9] selftests: can: add J1939 TP/ETP multi-frame " Oleksij Rempel
2026-11-06 5:35 ` netdev-bot+sashiko
2026-11-04 16:17 ` [PATCH can-next v2 8/9] selftests: can: cover J1939 transport abort and timeout paths Oleksij Rempel
2026-11-04 16:17 ` [PATCH can-next v2 9/9] selftests: can: check SO_J1939_PROMISC receive effect Oleksij Rempel
2026-11-06 5:35 ` netdev-bot+sashiko [this message]
2026-11-06 10:30 ` [PATCH can-next v2 0/9] selftests: can: add J1939 socket and transport tests Oleksij Rempel
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=179394332621.488853.1609910990759756381@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alexander.hoelzl@gmx.net \
--cc=fmaurer@redhat.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=quchaosheng000406@163.com \
--cc=robin@protonic.nl \
--cc=shuah@kernel.org \
--cc=socketcan@hartkopp.net \
/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
all inboxes | Powered by JetHome®