All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guillaume Nault <g.nault@alphalink.fr>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Denys Fedoryshchenko <nuclearcat@nuclearcat.com>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: Re: ppp/pppoe, still panic 4.15.3 in ppp_push
Date: Tue, 27 Feb 2018 19:54:38 +0100	[thread overview]
Message-ID: <20180227185438.GH1322@alphalink.fr> (raw)
In-Reply-To: <20180222183038.GD1322@alphalink.fr>

On Thu, Feb 22, 2018 at 07:30:38PM +0100, Guillaume Nault wrote:
> On Wed, Feb 21, 2018 at 12:04:30PM -0800, Cong Wang wrote:
> > For me it looks like pch->clist is not removed from the list ppp->channels
> > when destroyed via ppp_release(). But I don't want to pretend I understand
> > ppp logic.
> > 
> I've thought about that too, but couldn't find a scenario that could
> trigger the bug.
> 
> To get ->private_data pointing to a struct channel pointer, a file needs
> to ioctl(PPPIOCATTCHAN) first. For this call to succeed, the channel
> must have been registered with ppp_register_net_channel(). Both
> operations take a reference on the channel, which means that, before
> adding pch->clist to a ppp->channels list (with ppp_connect_channel()),
> the channel is already held by a /dev/ppp file and by the code that
> registered the channel in the first place.
> 
> Therefore, closing the /dev/ppp file can't be enough to make
> ppp_release() free the channel. We need to unregister the channel for
> the refcount to drop to 0. And ppp_unregister_channel(), removes
> pch->clist from ppp->channels before decrementing the reference
> counter.
> 
And this is where my reasoning failed... If pch->clist hasn't been
added to a ppp->channels list (that is, there was no
ppp_connect_channel() call for this channel), then
ppp_unregister_channel() only decrements the reference counter.

Therefore, we now have an unregistered channel which is only held by a
/dev/ppp file. But ioctl(PPPIOCCONNECT) still works on such a file, so
one can add pch->clist to a ppp->channels list. When the file
descriptor closes, we fall in Cong's scenario and the channel is freed,
leaving dangling pointers in ppp->channels.
Then, it's just a matter of calling ioctl(PPPIOCCONNECT) on this ppp
unit again to make list_add_tail() follow those invalid pointers and
crash.

Thank you Cong for putting me on the right track.

  parent reply	other threads:[~2018-02-27 18:54 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 13:17 ppp/pppoe, still panic 4.15.3 in ppp_push Denys Fedoryshchenko
2018-02-14 16:07 ` Guillaume Nault
2018-02-14 16:29   ` Denys Fedoryshchenko
2018-02-14 16:47     ` Guillaume Nault
2018-02-14 16:49       ` Denys Fedoryshchenko
2018-02-14 17:25         ` Guillaume Nault
2018-02-15 10:19           ` Denys Fedoryshchenko
2018-02-15 15:55             ` Guillaume Nault
2018-02-15 16:01               ` Denys Fedoryshchenko
2018-02-15 19:31                 ` Guillaume Nault
2018-02-15 19:34                   ` Denys Fedoryshchenko
2018-02-15 19:42                     ` Guillaume Nault
2018-02-16 11:13                       ` Denys Fedoryshchenko
2018-02-16 18:48                         ` Guillaume Nault
2018-02-18 10:01                           ` Denys Fedoryshchenko
2018-02-21 18:38                             ` Guillaume Nault
2018-02-20  9:05                           ` Denys Fedoryshchenko
2018-02-21 10:26                           ` Denys Fedoryshchenko
2018-02-21 18:55                             ` Guillaume Nault
2018-02-21 19:30                               ` Denys Fedoryshchenko
2018-02-21 20:04                   ` Cong Wang
2018-02-22 18:30                     ` Guillaume Nault
2018-02-22 18:51                       ` Denys Fedoryshchenko
2018-02-23  9:38                         ` Guillaume Nault
2018-02-23  9:41                           ` Denys Fedoryshchenko
2018-02-23 10:07                             ` Guillaume Nault
2018-02-23 10:54                               ` Denys Fedoryshchenko
2018-02-24 21:22                               ` Denys Fedoryshchenko
2018-02-27 10:58                               ` Denys Fedoryshchenko
2018-02-27 18:56                                 ` Guillaume Nault
2018-03-01 20:01                                   ` Guillaume Nault
2018-03-01 20:07                                     ` Denys Fedoryshchenko
2018-03-02 17:43                                       ` Guillaume Nault
2018-03-03  9:33                                         ` Denys Fedoryshchenko
2018-03-05 17:22                                           ` Guillaume Nault
2018-02-27 18:54                       ` Guillaume Nault [this message]
2018-02-15 19:20         ` Guillaume Nault

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=20180227185438.GH1322@alphalink.fr \
    --to=g.nault@alphalink.fr \
    --cc=netdev@vger.kernel.org \
    --cc=nuclearcat@nuclearcat.com \
    --cc=xiyou.wangcong@gmail.com \
    /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.