[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YzQuoqyGsooyDfId@codewreck.org>
Date: Wed, 28 Sep 2022 20:23:14 +0900
From: asmadeus@...ewreck.org
To: Leon Romanovsky <leon@...nel.org>
Cc: syzbot <syzbot+67d13108d855f451cafc@...kaller.appspotmail.com>,
davem@...emloft.net, edumazet@...gle.com, ericvh@...il.com,
kuba@...nel.org, linux-kernel@...r.kernel.org,
linux_oss@...debyte.com, lucho@...kov.net, netdev@...r.kernel.org,
pabeni@...hat.com, syzkaller-bugs@...glegroups.com,
v9fs-developer@...ts.sourceforge.net
Subject: Re: [syzbot] KASAN: use-after-free Read in rdma_close
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
Powered by blists - more mailing lists