From: sashiko-bot@kernel.org
To: "Alexander Hölzl" <alexander.hoelzl@gmx.net>
Cc: "Oliver Hartkopp" <socketcan@hartkopp.net>,
"Oleksij Rempel" <o.rempel@pengutronix.de>,
linux-can@vger.kernel.org, "Vincent Mailhol" <mailhol@kernel.org>,
"Marc Kleine-Budde" <mkl@pengutronix.de>
Subject: Re: [PATCH] can: j1939: fix potential race condition in BAM segmentation
Date: Wed, 10 Jun 2026 09:16:38 +0000 [thread overview]
Message-ID: <20260610091638.5E7861F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260610090619.70626-1-alexander.hoelzl@gmx.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Remote-triggerable reference count leak of `j1939_session` due to un-cancelled `txtimer` when receiving duplicate or spoofed BAM data loopback frames.
--
commit d4773792dedead1d2a7d20d129ec0234fba6902b
Author: Alexander Hölzl <alexander.hoelzl@gmx.net>
can: j1939: fix potential race condition in BAM segmentation
This commit addresses a potential race condition in segmented messages using
the BAM protocol. It moves the TX timer scheduling so the timer is only
scheduled when the TX acknowledgment is received.
> diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
> index df93d57907da7..d00f0c158bb8e 100644
> --- a/net/can/j1939/transport.c
> +++ b/net/can/j1939/transport.c
[ ... ]
> @@ -1948,6 +1960,10 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
> } else if (remain) {
> if (!session->transmission)
> j1939_tp_set_rxtimeout(session, 750);
> + else if (j1939_cb_is_broadcast(&session->skcb)) {
> + j1939_tp_schedule_txtimer(session, J1939_TP_BAM_FRAME_SPACING_MS);
[Severity: High]
Does this unconditionally leak a j1939_session reference if a duplicate or
spoofed BAM loopback frame arrives while the timer is already active?
If a duplicate DAT loopback frame is received, the code detects it and falls
through to the remain = true block, calling j1939_tp_schedule_txtimer() again:
net/can/j1939/transport.c:j1939_tp_schedule_txtimer() {
j1939_session_get(session);
hrtimer_start(&session->txtimer, ms_to_ktime(msec),
HRTIMER_MODE_REL_SOFT);
}
Since j1939_tp_schedule_txtimer() takes a session reference without cancelling
any existing timer, and the timer callback will only fire once, won't the extra
references permanently leak and prevent the session from being freed?
> + j1939_tp_set_rxtimeout(session, J1939_TP_BAM_ECHO_TIMEOUT_MS);
> + }
> } else if (do_cts_eoma) {
> j1939_tp_set_rxtimeout(session, 1250);
> if (!session->transmission)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260610090619.70626-1-alexander.hoelzl@gmx.net?part=1
next prev parent reply other threads:[~2026-06-10 9:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 9:06 [PATCH] can: j1939: fix potential race condition in BAM segmentation Alexander Hölzl
2026-06-10 9:16 ` sashiko-bot [this message]
2026-10-01 10:42 ` Markus Koeniger
2026-10-01 10:57 ` Marc Kleine-Budde
2026-10-01 11:18 ` Hölzl, Alexander
2026-10-01 11:37 ` Oleksij Rempel
2026-10-01 11:54 ` Hölzl, Alexander
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=20260610091638.5E7861F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexander.hoelzl@gmx.net \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.