From: Nikolay Aleksandrov <razor@blackwall.org>
To: Ziqi Zhao <astrajoan@yahoo.com>,
arnd@arndb.de, bridge@lists.linux-foundation.org,
davem@davemloft.net, edumazet@google.com, f.fainelli@gmail.com,
ivan.orlov0322@gmail.com, keescook@chromium.org, kuba@kernel.org,
hkallweit1@gmail.com, mudongliangabcd@gmail.com,
nikolay@nvidia.com, pabeni@redhat.com, roopa@nvidia.com,
skhan@linuxfoundation.org,
syzbot+881d65229ca4f9ae8c84@syzkaller.appspotmail.com,
vladimir.oltean@nxp.com
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] net: bridge: Fix refcnt issues in dev_ioctl
Date: Sat, 19 Aug 2023 12:25:15 +0300 [thread overview]
Message-ID: <df28eac7-ee6e-431c-acee-36a1c29a4ae0@blackwall.org> (raw)
In-Reply-To: <20230819081057.330728-1-astrajoan@yahoo.com>
Hi Ziqi,
On 8/19/23 11:10, Ziqi Zhao wrote:
> In the bug reported by Syzbot, certain bridge devices would have a
> leaked reference created by race conditions in dev_ioctl, specifically,
> under SIOCBRADDIF or SIOCBRDELIF operations. The reference leak would
How would it leak a reference, could you elaborate?
The reference is always taken and always released after the call.
> be shown in the periodic unregister_netdevice call, which throws a
> warning and cause Syzbot to report a crash. Upon inspection of the
If you reproduced it, is the device later removed or is it really stuck?
> logic in dev_ioctl, it seems the reference was introduced to ensure
> proper access to the bridge device after rtnl_unlock. and the latter
> function is necessary to maintain the following lock order in any
> bridge related ioctl calls:
>
> 1) br_ioctl_mutex => 2) rtnl_lock
>
> Conceptually, though, br_ioctl_mutex could be considered more specific
> than rtnl_lock given their usages, hence swapping their order would be
> a reasonable proposal. This patch changes all related call sites to
> maintain the reversed order of the two locks:
>
> 1) rtnl_lock => 2) br_ioctl_mutex
>
> By doing so, the extra reference introduced in dev_ioctl is no longer
> needed, and hence the reference leak bug is now resolved.
IIRC there was no bug, it was a false-positive. The reference is held a
bit longer but then released, so the device is deleted later.
I might be remembering wrong, but I think I briefly looked into this
when it was reported. If that's not the case I'd be interested to see
a new report/trace because the bug might be somewhere else.
>
> Reported-by: syzbot+881d65229ca4f9ae8c84@syzkaller.appspotmail.com
> Fixes: ad2f99aedf8f ("net: bridge: move bridge ioctls out of .ndo_do_ioctl")
> Signed-off-by: Ziqi Zhao <astrajoan@yahoo.com>
> ---
> net/bridge/br_ioctl.c | 4 ----
> net/core/dev_ioctl.c | 8 +-------
> net/socket.c | 2 ++
> 3 files changed, 3 insertions(+), 11 deletions(-)
>
Thanks,
Nik
next prev parent reply other threads:[~2023-08-19 10:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-10 1:34 [syzbot] [net?] unregister_netdevice: waiting for DEV to become free (8) syzbot
2023-06-21 7:07 ` Ziqi Zhao
2023-06-21 8:46 ` Dongliang Mu
2023-06-26 5:50 ` [PATCH] can: j1939: prevent deadlock by changing j1939_socks_lock to rwlock Ziqi Zhao
2023-08-19 8:10 ` [PATCH] net: bridge: Fix refcnt issues in dev_ioctl Ziqi Zhao
2023-08-19 9:25 ` Nikolay Aleksandrov [this message]
2023-08-19 22:50 ` Ziqi Zhao
2023-08-22 10:40 ` Nikolay Aleksandrov
2023-08-23 9:38 ` Ziqi Zhao
2024-02-12 15:28 ` [Bridge] " Alexander Ofitserov
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=df28eac7-ee6e-431c-acee-36a1c29a4ae0@blackwall.org \
--to=razor@blackwall.org \
--cc=arnd@arndb.de \
--cc=astrajoan@yahoo.com \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=ivan.orlov0322@gmail.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mudongliangabcd@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@nvidia.com \
--cc=pabeni@redhat.com \
--cc=roopa@nvidia.com \
--cc=skhan@linuxfoundation.org \
--cc=syzbot+881d65229ca4f9ae8c84@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=vladimir.oltean@nxp.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 NNTP newsgroup(s).