public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Dae R. Jeong" <threeearcat@gmail.com>
To: socketcan@hartkopp.net, mkl@pengutronix.de, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	linux-can@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: WARNING in isotp_tx_timer_handler and WARNING in print_tainted
Date: Sun, 26 Mar 2023 17:10:07 +0900	[thread overview]
Message-ID: <ZB/93xJxq/BUqAgG@dragonet> (raw)

Hi,

I am curious about the error handling logic in isotp_sendmsg() which
looks a bit unclear to me.

I was looking the `WARNING in isotp_tx_timer_handler` warning [1],
which was firstly addressed by a commit [2] but reoccured even after
the commit.
[1]: https://syzkaller.appspot.com/bug?id=4f492d593461a5e44d76dd9322e179d13191a8ef
[2]: c6adf659a8ba can: isotp: check CAN address family in isotp_bind()

I thought that the warning is caused by the concurrent execution of
two isotp_sendmsg() as described below (I'm not 100% sure though).

CPU1                             CPU2
isotp_sendmsg()                  isotp_sendmsg()
-----                            -----
old_state = so->tx.state; // ISOTP_IDLE

                                 cmpxchg(&so->tx.state, ISTOP_IDLE, ISOTP_SENDING) // success
							     ...
							     so->tx.state = ISTOP_WAIT_FIRST_FC;
							     hrtimer_start(&so->txtimer);

cmpxchg(&so->tx.state, ISTOP_IDLE, ISOTP_SENDING) // failed
// if MSG_DONTWAIT is set in msg->msg_flags or
// a signal is delivered during wait_event_interruptible()
goto err_out;
err_out:
    so->tx.state = old_state; // ISTOP_IDLE

                                 isotp_tx_timer_handler()
								 -----
								 switch (so->tx.state) {
								 default:
								     WARN_ONCE();
								 }

Then, a commit [3] changed the logic of tx timer, and removed the
WARN_ONCE() statement. So I thought that the issue is completely
handled.
[3]: 4f027cba8216 can: isotp: split tx timer into transmission and timeout

But even after [3] is applied, I found a warning that seems related
occurred [4] (in the kernel commit: 478a351ce0d6).
[4]: https://syzkaller.appspot.com/bug?id=11d0e5f6fef53a0ea486bbd07ddd3cba66132150

So I wonder whether the `err_out` logic in isotp_sendmsg() is safe.
For me, it looks like isotp_sendmsg() can change so->tx.state to
ISTOP_IDLE at any time. It may not be a problem if all other locations
are aware of this. Is this an intended behavior?

Thank you in advance.


Best regards,
Dae R. Jeong

             reply	other threads:[~2023-03-26  8:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-26  8:10 Dae R. Jeong [this message]
2023-03-26 11:15 ` WARNING in isotp_tx_timer_handler and WARNING in print_tainted Oliver Hartkopp
2023-03-26 11:55   ` Dae R. Jeong
2023-03-26 16:17     ` Oliver Hartkopp
2023-03-27  1:58       ` Dae R. Jeong
     [not found]     ` <20230327014843.2431-1-hdanton@sina.com>
2023-03-31 10:25       ` Oliver Hartkopp

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=ZB/93xJxq/BUqAgG@dragonet \
    --to=threeearcat@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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