Thread (22 messages) 22 messages, 5 authors, 2023-06-02

Re: [syzbot] KASAN: use-after-free Read in rdma_close

From: Leon Romanovsky <leon@kernel.org>
Date: 2022-09-28 10:49:53
Also in: lkml

On Wed, Sep 28, 2022 at 07:43:38PM +0900, asmadeus@codewreck.org wrote:
Leon Romanovsky wrote on Wed, Sep 28, 2022 at 01:07:23PM +0300:
quoted
The bug is in commit 3ff51294a055 ("9p: p9_client_create: use p9_client_destroy on failure").
Thanks for looking
quoted
It is wrong to call to p9_client_destroy() if clnt->trans_mod->create fails.
hmm that's a bit broad :)

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.
I'll send a patch and credit you in Reported-by unless you don't want
to.

-- 
Dominique
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help