Re: [PATCH net-next v5 6/6] selftests: drv-net: psp: add rekey tests

From: Daniel Zahka

Date: Mon Nov 23 2026 - 07:33:44 EST


On Sat Nov 21, 2026 at 6:03 PM EST, netdev-bot+sashiko wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> 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] selftests: drv-net: psp: stale length n in run_session() after
> tx assoc
>
> --
>
>> diff --git a/tools/testing/selftests/drivers/net/psp_responder.c b/tools/testing/selftests/drivers/net/psp_responder.c
>> --- a/tools/testing/selftests/drivers/net/psp_responder.c
>> +++ b/tools/testing/selftests/drivers/net/psp_responder.c
>> @@ -247,6 +354,16 @@ run_session(struct ynl_sock *ys, struct opts *opts,
>> fprintf(stderr, "WARN: echo but no data sock\n");
>> send_ack(comm_sock);
>> }
>> + if (cmd("rx assoc"))
>> + handle_rx_assoc(ys, data_sock,
>> + comm_sock);
>> + if (cmd_w_msg("tx assoc", struct assoc_msg)) {
>> + handle_tx_assoc(ys, buf, data_sock,
>> + comm_sock);
>> + __consume(sizeof(struct assoc_msg));
>> + }
>> + if (cmd("key rotate"))
>> + handle_key_rotate(ys, opts, comm_sock);
>> if (cmd("data close")) {
>> if (data_sock >= 0) {
>> close(data_sock);
>
> [Severity: Medium]
> In run_session(), n is set from off once, before the do/while loop,
> and is never updated. cmd() still tests n >= sz and __consume() tests
> n == sz. For a single tx assoc message n is 49.
>
> cmd("tx assoc") consumes the 9 byte string and moves the struct
> assoc_msg to buf[0]. __consume(sizeof(struct assoc_msg)) then takes
> the else branch. That leaves off == 0, but the 40 byte assoc_msg is
> still in buf[0..39].
>
> The checks that follow in the same iteration (key rotate, data close,
> conn psp, conn clr, exit) still see n == 49. They memcmp() buf against
> the SPI, version and key bytes of a message that was already handled.
> Suppose those bytes match a command string. For example, an SPI of
> 0x65786974 with version 0 reads as "exit\0". The matching __consume()
> then does off -= sz starting from zero, and memmove() gets a negative
> length converted to a huge size_t, which crashes the responder.
>
> The conn psp handler already has the same stale-n pattern, but it
> only leaves the two version bytes behind. tx assoc is the first
> command that leaves an arbitrary binary payload at the front of buf.
>
> Would it make sense to have cmd() and __consume() check off rather
> than n, perhaps as a small fix ahead of this patch? Then a command
> could only match bytes that have not been consumed yet.

that probably would make sense, but this is mostly a preexisting
hazard with the demux loop, so it would cost another setup patch, and
the issue is still not actually reachable during test execution. The 4B
SPI would need to alias the string "exit". That won't ever happen.

This would be the only reason to go to a v6 for the series here, so let
me know if you think this is worth it.