From: duoming@zju.edu.cn
To: "Dan Carpenter" <dan.carpenter@linaro.org>
Cc: "Lars Kellogg-Stedman" <lars@oddbit.com>,
linux-hams@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, pabeni@redhat.com, kuba@kernel.org,
edumazet@google.com, davem@davemloft.net, jreuter@yaina.de
Subject: Re: [PATCH net] ax25: Fix refcount leak issues of ax25_dev
Date: Tue, 7 May 2024 17:04:05 +0800 (GMT+08:00) [thread overview]
Message-ID: <5f92dba3.4404.18f524bb7a6.Coremail.duoming@zju.edu.cn> (raw)
In-Reply-To: <79dc1067-76dc-43b2-9413-7754f96fe08e@moroto.mountain>
On Tue, 7 May 2024 11:08:14 +0300 Dan Carpenter wrote:
> I have reviewed this code some more. My theory is:
>
> ax25_dev_device_up() <- sets refcount to 1
> ax25_dev_device_down() <- set refcount to 0 and frees it
>
> If the refcount is not 1 at ax25_dev_device_down() then something is
> screwed up. So why do we even need more refcounting than that? But
> apparently we do. I don't really understand networking that well so
> maybe we can have lingering connections after the device is down.
We do need more reference count. Because there is a race condition
between ax25_bind() and the cleanup routine.
The cleanup routine is consisted of three parts: ax25_kill_by_device(),
ax25_rt_device_down() and ax25_dev_device_down(). The ax25_kill_by_device()
is used to cleanup the connections and the ax25_dev_device_down() is used
to cleanup the device. If we call ax25_bind() and ax25_connect() between
the window of ax25_kill_by_device() and ax25_dev_device_down(), the ax25_dev
is freed in ax25_dev_device_down(). When we call ax25_release() to release
the connections, the UAF bugs will happen.
Best regards,
Duoming Zhou
next prev parent reply other threads:[~2024-05-07 9:04 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-01 6:02 [PATCH net] ax25: Fix refcount leak issues of ax25_dev Duoming Zhou
2024-05-01 17:33 ` Markus Elfring
2024-05-01 17:43 ` Dan Carpenter
2024-05-02 4:35 ` duoming
2024-05-02 7:56 ` Dan Carpenter
2024-05-02 9:30 ` Paolo Abeni
2024-05-02 1:29 ` Lars Kellogg-Stedman
2024-05-03 20:36 ` Dan Carpenter
2024-05-03 23:40 ` Lars Kellogg-Stedman
2024-05-04 12:16 ` Dan Carpenter
2024-05-04 22:16 ` Lars Kellogg-Stedman
2024-05-07 3:18 ` Lars Kellogg-Stedman
2024-05-07 8:08 ` Dan Carpenter
2024-05-07 9:04 ` duoming [this message]
2024-05-08 18:27 ` Dan Carpenter
2024-05-09 1:40 ` duoming
2024-05-23 12:30 ` Lars Kellogg-Stedman
2024-05-07 6:38 ` Dan Carpenter
2024-05-15 9:52 ` duoming
2024-05-16 19:20 ` Lars Kellogg-Stedman
[not found] ` <CANnsUMHTZ_P4-C2iGdbakcp_Xk5c-aCO5kYEvaBdOcsaSnK5Pg@mail.gmail.com>
2024-05-20 14:42 ` Kernel 6.9.1 AX.25 Crash Lars Kellogg-Stedman
2024-05-20 14:49 ` Chris Maness
2024-05-21 0:11 ` Chris Maness
2024-05-21 0:48 ` Lars Kellogg-Stedman
2024-05-21 1:38 ` Chris Maness
2024-05-21 2:12 ` Dan Cross
2024-05-21 3:07 ` Chris Maness
2024-05-21 11:47 ` Dave Hibberd
2024-05-21 12:03 ` Chris Maness
2024-05-21 19:20 ` Mike Quin
2024-05-21 23:02 ` Chris Maness
2024-05-21 23:07 ` Mike Quin
2024-05-21 23:17 ` Chris Maness
2024-05-21 15:53 ` David Ranch
2024-05-21 16:28 ` Chris Maness
2024-05-21 18:12 ` Lars Kellogg-Stedman
2024-05-22 15:32 ` Dan Cross
2024-05-22 16:07 ` Chris Maness
2024-05-22 17:06 ` David Ranch
2024-05-22 18:04 ` Dan Cross
2024-05-22 17:54 ` Dan Cross
2024-05-22 18:17 ` Lars Kellogg-Stedman
2024-05-22 18:37 ` Dan Cross
2024-05-22 19:23 ` Lars Kellogg-Stedman
2024-05-22 22:22 ` David Ranch
2024-05-22 22:32 ` Lars Kellogg-Stedman
2024-05-23 0:54 ` Userspace AX.25 stack library [was Re: Kernel 6.9.1 AX.25 Crash] Stuart Longland VK4MSL
2024-05-23 16:32 ` Dan Cross
2024-05-22 16:10 ` Kernel 6.9.1 AX.25 Crash David Ranch
2024-05-22 18:13 ` Lars Kellogg-Stedman
2024-06-07 12:01 ` Lars Kellogg-Stedman
2024-06-07 13:49 ` David Ranch
2024-06-08 1:59 ` Lars Kellogg-Stedman
2024-06-08 15:23 ` David Ranch
2024-05-23 10:30 ` Dan Carpenter
2024-05-27 17:59 ` Chris Maness
2024-05-04 11:04 ` [PATCH net] ax25: Fix refcount leak issues of ax25_dev Dan Carpenter
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=5f92dba3.4404.18f524bb7a6.Coremail.duoming@zju.edu.cn \
--to=duoming@zju.edu.cn \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jreuter@yaina.de \
--cc=kuba@kernel.org \
--cc=lars@oddbit.com \
--cc=linux-hams@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox