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: Thu, 9 May 2024 09:40:02 +0800 (GMT+08:00) [thread overview]
Message-ID: <5a4e0ffa.6776.18f5b01e5e0.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:
> diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
> index 9169efb2f43a..4d1ab296d52c 100644
> --- a/net/ax25/af_ax25.c
> +++ b/net/ax25/af_ax25.c
> @@ -92,6 +92,7 @@ static void ax25_kill_by_device(struct net_device *dev)
> spin_unlock_bh(&ax25_list_lock);
> ax25_disconnect(s, ENETUNREACH);
> s->ax25_dev = NULL;
> + ax25_dev_put(ax25_dev);
> ax25_cb_del(s);
> spin_lock_bh(&ax25_list_lock);
> goto again;
> @@ -101,11 +102,8 @@ static void ax25_kill_by_device(struct net_device *dev)
> lock_sock(sk);
> ax25_disconnect(s, ENETUNREACH);
> s->ax25_dev = NULL;
> - if (sk->sk_socket) {
> - netdev_put(ax25_dev->dev,
> - &s->dev_tracker);
> - ax25_dev_put(ax25_dev);
> - }
> + netdev_put(ax25_dev->dev, &s->dev_tracker);
> + ax25_dev_put(ax25_dev);
We should not decrease the refcount without checking "if (sk->sk_socket)", because
there is a race condition between ax25_kill_by_device() and ax25_release(), if we
decrease the refcount in ax25_release(), we should not decrease it here, otherwise
the refcount underflow will happen.
Best regards,
Duoming Zhou
next prev parent reply other threads:[~2024-05-09 1:40 UTC|newest]
Thread overview: 53+ 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
2024-05-08 18:27 ` Dan Carpenter
2024-05-09 1:40 ` duoming [this message]
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-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=5a4e0ffa.6776.18f5b01e5e0.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).