netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: asmadeus@codewreck.org
To: Leon Romanovsky <leon@kernel.org>
Cc: syzbot <syzbot+67d13108d855f451cafc@syzkaller.appspotmail.com>,
	davem@davemloft.net, edumazet@google.com, ericvh@gmail.com,
	kuba@kernel.org, linux-kernel@vger.kernel.org,
	linux_oss@crudebyte.com, lucho@ionkov.net,
	netdev@vger.kernel.org, pabeni@redhat.com,
	syzkaller-bugs@googlegroups.com,
	v9fs-developer@lists.sourceforge.net
Subject: Re: [syzbot] KASAN: use-after-free Read in rdma_close
Date: Wed, 28 Sep 2022 20:23:14 +0900	[thread overview]
Message-ID: <YzQuoqyGsooyDfId@codewreck.org> (raw)
In-Reply-To: <YzQmr8LVTmUj9+zB@unreal>

Leon Romanovsky wrote on Wed, Sep 28, 2022 at 01:49:19PM +0300:
> > But I agree I did get that wrong: trans_mod->close() wasn't called if
> > create failed.
> > We do want the idr_for_each_entry() that is in p9_client_destroy so
> > rather than revert the commit (fix a bug, create a new one..) I'd rather
> > split it out in an internal function that takes a 'bool close' or
> > something to not duplicate the rest.
> > (Bit of a nitpick, sure)
> 
> Please do proper unwind without extra variable.
> 
> Proper unwind means that you will call to symmetrical functions in
> destroy as you used in create:
> alloc -> free
> create -> close
> e.t.c
> 
> When you use some global function like you did, there is huge chance
> to see unwind bugs.

No.

Duplicating complicated cleanup code leads to leaks like we used to
have; that destroy function already frees up things in the right order.

And, well, frankly 9p is a mess anyway; the problem here is that
trans_mod->create() doesn't leave any trace we can rely on in a common
cleanup function, but the original "proper unwind" missed:
 - p9_fid_destroy/tags cleanup for anything in the cache (because, yes,
apparently fuzzers managed to use the client before it's fully
initialized. I don't want to know.)
 - fcall cache destory

I'm not duplicating all this mess. This is the only place that can call
destroy before trans_mod create has been called, I wish we'd have a
pattern like "clnt->trans = clnt->trans_mod->create()" so we could just
check if trans is null, but a destroy parameter will do.

... Well, I guess it's not like there are out of tree trans, I could
just change create() to do that if I had infinite time...

--
Dominique



  reply	other threads:[~2022-09-28 11:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 11:29 [syzbot] KASAN: use-after-free Read in rdma_close syzbot
2022-09-28 10:07 ` Leon Romanovsky
2022-09-28 10:43   ` asmadeus
2022-09-28 10:49     ` Leon Romanovsky
2022-09-28 11:23       ` asmadeus [this message]
2022-09-28 11:54         ` Leon Romanovsky
2022-09-28 12:57           ` Christian Schoenebeck
2022-09-28 21:52             ` asmadeus
2022-09-29  6:10               ` Leon Romanovsky
2022-12-30 10:34 ` syzbot
2023-01-13 10:35 ` syzbot
2023-01-27 10:36 ` syzbot
2023-02-10 10:36 ` syzbot
2023-02-24 10:37 ` syzbot
2023-03-10 10:38 ` syzbot
2023-03-24 10:38 ` syzbot
2023-04-07 10:38 ` syzbot
2023-04-21 10:39 ` syzbot
2023-05-05 10:40 ` syzbot
2023-05-19 10:40 ` syzbot
2023-06-02 10:42 ` syzbot
2023-06-02 10:57   ` Aleksandr Nogikh

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=YzQuoqyGsooyDfId@codewreck.org \
    --to=asmadeus@codewreck.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ericvh@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux_oss@crudebyte.com \
    --cc=lucho@ionkov.net \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+67d13108d855f451cafc@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=v9fs-developer@lists.sourceforge.net \
    /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).