Linux CAN drivers development
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Robin van der Gracht <robin@protonic.nl>,
	kernel@pengutronix.de, Oliver Hartkopp <socketcan@hartkopp.net>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	linux-can@vger.kernel.org
Subject: Re: [PATCH v2] can: j1939: make j1939_sk_bind() fail if device is no longer registered
Date: Thu, 11 Dec 2025 10:49:41 +0100	[thread overview]
Message-ID: <aTqTtVAU11_NiJOf@pengutronix.de> (raw)
In-Reply-To: <5732921e-247e-4957-a364-da74bd7031d7@I-love.SAKURA.ne.jp>

On Tue, Nov 25, 2025 at 10:43:12PM +0900, Tetsuo Handa wrote:
> There is a theoretical race window in j1939_sk_netdev_event_unregister()
> where two j1939_sk_bind() calls jump in between read_unlock_bh() and
> lock_sock().
> 
> The assumption jsk->priv == priv can fail if the first j1939_sk_bind()
> call once made jsk->priv == NULL due to failed j1939_local_ecu_get() call
> and the second j1939_sk_bind() call again made jsk->priv != NULL due to
> successful j1939_local_ecu_get() call.
> 
> Since the socket lock is held by both j1939_sk_netdev_event_unregister()
> and j1939_sk_bind(), checking ndev->reg_state with the socket lock held can
> reliably make the second j1939_sk_bind() call fail (and close this race
> window).
> 
> Fixes: 7fcbe5b2c6a4 ("can: j1939: implement NETDEV_UNREGISTER notification handler")
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

I guess, this one is needed too:
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2025-12-11  9:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24 14:16 [PATCH] can: j1939: close theoretical race window in j1939_sk_netdev_event_unregister() Tetsuo Handa
2025-11-25 13:43 ` [PATCH v2] can: j1939: make j1939_sk_bind() fail if device is no longer registered Tetsuo Handa
2025-12-11  9:49   ` Oleksij Rempel [this message]
2025-12-17  9:48   ` Marc Kleine-Budde

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=aTqTtVAU11_NiJOf@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=robin@protonic.nl \
    --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