All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
	"linux-can@vger.kernel.org" <linux-can@vger.kernel.org>,
	Joakim Zhang <qiangqing.zhang@nxp.com>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	Oliver Hartkopp <socketcan@hartkopp.net>
Subject: Re: [5.10 CAN BUG report] kernel dump about echo skb
Date: Fri, 22 Jan 2021 18:51:48 +0900	[thread overview]
Message-ID: <CAMZ6RqKd-P32QPyzeeJ7J-L1agHg7HmJtZrzO8WcXCRjDw5Rpw@mail.gmail.com> (raw)
In-Reply-To: <20210122094030.dvyzutfy4bw2si6f@pengutronix.de>

On Fri 22 Jan 2021 at 18:40, Oleksij Rempel <o.rempel@pengutronix.de> wrote:
> On Fri, Jan 22, 2021 at 10:23:24AM +0100, Marc Kleine-Budde wrote:
> > On Fri, Jan 22, 2021 at 06:08:18PM +0900, Vincent MAILHOL wrote:
> > > > > 1. Kernel dump log:
> > > > > [  101.688327] ------------[ cut here ]------------ [  101.692968] refcount_t:
> > > > > addition on 0; use-after-free.
> > >
> > > The skb already had its refcount at zero when reaching
> > > can_put_echo_skb(). It is as if it was already freed/consumed!
> >
> > ACK
> >
> > > If you remove Oleksij’s patch, can_put_echo_skb() will probably not
> > > clone the skb and thus not check the refcount: this means that you
> > > will not see the warning, however, it does not necessarily mean that
> > > the bug did not occur.
> >
> > ACK
> >
> > > So far, it seems to me to be another bug which was invisible until
> > > now and which Oleksij’s patch just uncovered. But I do not yet fully
> > > understand what the root cause could be.
> >
> > Or it's the same bug, hitting earlier. Oleksij's backtrace was in the
> > TX-complete path and the problem was fixes by cloning the skb in before TX.
> > This means the refcount of the original skb was decremented between TX and
> > TX-complete. Here the refcount is decremented even before TX.
> >
> > Does this make sense?

Makes absolute sense.

That would mean that Olesij’s patch addressed the issue but too late
and that somewhere earlier in the TX path, the refcount is either:
  - decremented where it shouldn’t be
  - not incremented where it should be

Assuming that the skb reaches the xmit() funcion, what should be its
refcount?
2 if the socket is still opened and 1 if the socket is closed?
Something else?

> Is socket was closed just before TX?

Good question!
In addition, I would like to know which protocol is used (raw_can, j1939,
other?)


Yours sincerely,
Vincent

> Regards,
> Oleksij
> --
> 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:[~2021-01-22 10:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21  8:37 [5.10 CAN BUG report] kernel dump about echo skb Joakim Zhang
2021-01-22  7:53 ` Joakim Zhang
2021-01-22  9:08   ` Vincent MAILHOL
2021-01-22  9:23     ` Marc Kleine-Budde
2021-01-22  9:40       ` Oleksij Rempel
2021-01-22  9:51         ` Vincent MAILHOL [this message]
2021-01-23  7:40           ` Joakim Zhang
2021-01-22  8:58 ` 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=CAMZ6RqKd-P32QPyzeeJ7J-L1agHg7HmJtZrzO8WcXCRjDw5Rpw@mail.gmail.com \
    --to=mailhol.vincent@wanadoo.fr \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=qiangqing.zhang@nxp.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 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.