From: Pengfei Xu <pengfei.xu@intel.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Pavel Begunkov <asml.silence@gmail.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>
Subject: Re: [PATCH v1 net-next 2/3] af_unix: Remove io_uring code for GC.
Date: Wed, 14 Feb 2024 09:08:06 +0800 [thread overview]
Message-ID: <ZcwSdp8+gWAkXcru@xpf.sh.intel.com> (raw)
In-Reply-To: <8eb7c0b3-afc7-4dca-b614-397514a1994b@kernel.dk>
Hi Jens Axboe,
On 2024-02-12 at 10:47:20 -0700, Jens Axboe wrote:
> On 2/11/24 7:17 PM, Pengfei Xu wrote:
> > Hi,
> >
> > On 2024-01-29 at 11:04:34 -0800, Kuniyuki Iwashima wrote:
> >> Since commit 705318a99a13 ("io_uring/af_unix: disable sending
> >> io_uring over sockets"), io_uring's unix socket cannot be passed
> >> via SCM_RIGHTS, so it does not contribute to cyclic reference and
> >> no longer be candidate for garbage collection.
> >>
> >> Also, commit 6e5e6d274956 ("io_uring: drop any code related to
> >> SCM_RIGHTS") cleaned up SCM_RIGHTS code in io_uring.
> >>
> >> Let's do it in AF_UNIX as well by reverting commit 0091bfc81741
> >> ("io_uring/af_unix: defer registered files gc to io_uring release")
> >> and commit 10369080454d ("net: reclaim skb->scm_io_uring bit").
> >>
> >> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> >> ---
> >> include/net/af_unix.h | 1 -
> >> net/unix/garbage.c | 25 ++-----------------------
> >> net/unix/scm.c | 6 ------
> >> 3 files changed, 2 insertions(+), 30 deletions(-)
> >>
> >> diff --git a/include/net/af_unix.h b/include/net/af_unix.h
> >> index f045bbd9017d..9e39b2ec4524 100644
> >> --- a/include/net/af_unix.h
> >> +++ b/include/net/af_unix.h
> >> @@ -20,7 +20,6 @@ static inline struct unix_sock *unix_get_socket(struct file *filp)
> >> void unix_inflight(struct user_struct *user, struct file *fp);
> >> void unix_notinflight(struct user_struct *user, struct file *fp);
> >> void unix_destruct_scm(struct sk_buff *skb);
> >> -void io_uring_destruct_scm(struct sk_buff *skb);
> >> void unix_gc(void);
> >> void wait_for_unix_gc(struct scm_fp_list *fpl);
> >> struct sock *unix_peer_get(struct sock *sk);
> >> diff --git a/net/unix/garbage.c b/net/unix/garbage.c
> >> index af676bb8fb67..ce5b5f87b16e 100644
> >> --- a/net/unix/garbage.c
> >> +++ b/net/unix/garbage.c
> >> @@ -184,12 +184,10 @@ static bool gc_in_progress;
> >>
> >> static void __unix_gc(struct work_struct *work)
> >> {
> >> - struct sk_buff *next_skb, *skb;
> >> - struct unix_sock *u;
> >> - struct unix_sock *next;
> >> struct sk_buff_head hitlist;
> >> - struct list_head cursor;
> >> + struct unix_sock *u, *next;
> >> LIST_HEAD(not_cycle_list);
> >> + struct list_head cursor;
> >>
> >> spin_lock(&unix_gc_lock);
> >>
> >> @@ -269,30 +267,11 @@ static void __unix_gc(struct work_struct *work)
> >>
> >> spin_unlock(&unix_gc_lock);
> >>
> >> - /* We need io_uring to clean its registered files, ignore all io_uring
> >> - * originated skbs. It's fine as io_uring doesn't keep references to
> >> - * other io_uring instances and so killing all other files in the cycle
> >> - * will put all io_uring references forcing it to go through normal
> >> - * release.path eventually putting registered files.
> >> - */
> >> - skb_queue_walk_safe(&hitlist, skb, next_skb) {
> >> - if (skb->destructor == io_uring_destruct_scm) {
> >> - __skb_unlink(skb, &hitlist);
> >> - skb_queue_tail(&skb->sk->sk_receive_queue, skb);
> >> - }
> >> - }
> >> -
> >> /* Here we are. Hitlist is filled. Die. */
> >> __skb_queue_purge(&hitlist);
> >>
> >> spin_lock(&unix_gc_lock);
> >>
> >> - /* There could be io_uring registered files, just push them back to
> >> - * the inflight list
> >> - */
> >> - list_for_each_entry_safe(u, next, &gc_candidates, link)
> >> - list_move_tail(&u->link, &gc_inflight_list);
> >> -
> >> /* All candidates should have been detached by now. */
> >> WARN_ON_ONCE(!list_empty(&gc_candidates));
> >>
> >> diff --git a/net/unix/scm.c b/net/unix/scm.c
> >> index 505e56cf02a2..db65b0ab5947 100644
> >> --- a/net/unix/scm.c
> >> +++ b/net/unix/scm.c
> >> @@ -148,9 +148,3 @@ void unix_destruct_scm(struct sk_buff *skb)
> >> sock_wfree(skb);
> >> }
> >> EXPORT_SYMBOL(unix_destruct_scm);
> >> -
> >> -void io_uring_destruct_scm(struct sk_buff *skb)
> >> -{
> >> - unix_destruct_scm(skb);
> >> -}
> >> -EXPORT_SYMBOL(io_uring_destruct_scm);
> >
> > Syzkaller found below issue.
> > There is WARNING in __unix_gc in v6.8-rc3_internal-devel_hourly-20240205-094544,
> > the kernel contains kernel-next patches.
> >
> > Bisected and found first bad commit:
> > "
> > 11498715f266 af_unix: Remove io_uring code for GC.
> > "
> > It's the same patch as above.
>
> It should be fixed by:
>
> commit 1279f9d9dec2d7462823a18c29ad61359e0a007d
> Author: Kuniyuki Iwashima <kuniyu@amazon.com>
> Date: Sat Feb 3 10:31:49 2024 -0800
>
> af_unix: Call kfree_skb() for dead unix_(sk)->oob_skb in GC.
>
> which is in Linus's tree.
Thank you for the commit tip for the fix. This is indeed the same problem and
has been fixed.
I will check the community mail carefully next time to avoid reporting
duplicate problems.
Best Regards,
Thanks!
>
> --
> Jens Axboe
>
next prev parent reply other threads:[~2024-02-14 1:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-29 19:04 [PATCH v1 net-next 0/3] af_unix: Remove io_uring dead code in GC Kuniyuki Iwashima
2024-01-29 19:04 ` [PATCH v1 net-next 1/3] af_unix: Replace BUG_ON() with WARN_ON_ONCE() Kuniyuki Iwashima
2024-01-29 19:04 ` [PATCH v1 net-next 2/3] af_unix: Remove io_uring code for GC Kuniyuki Iwashima
2024-02-12 2:17 ` Pengfei Xu
2024-02-12 17:47 ` Jens Axboe
2024-02-14 1:08 ` Pengfei Xu [this message]
2024-01-29 19:04 ` [PATCH v1 net-next 3/3] af_unix: Remove CONFIG_UNIX_SCM Kuniyuki Iwashima
2024-01-29 21:02 ` [PATCH v1 net-next 0/3] af_unix: Remove io_uring dead code in GC Jens Axboe
2024-02-01 1:30 ` patchwork-bot+netdevbpf
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=ZcwSdp8+gWAkXcru@xpf.sh.intel.com \
--to=pengfei.xu@intel.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@amazon.com \
--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 NNTP newsgroup(s).