From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dominique Martinet Subject: Re: [PATCH] 9p: fix Use-After-Free in p9_write_work() Date: Mon, 30 Jul 2018 12:23:49 +0200 Message-ID: <20180730102349.GA31932@nautica> References: <20180729130248.29612-1-tomasbortoli@gmail.com> <20180729233336.GB28684@nautica> <4ac26f97-778b-6527-9a5b-08b7bfc8a5e8@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: davem@davemloft.net, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com To: Tomas Bortoli Return-path: Content-Disposition: inline In-Reply-To: <4ac26f97-778b-6527-9a5b-08b7bfc8a5e8@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org Tomas Bortoli wrote on Mon, Jul 30, 2018: > > Other transports also have the same issue see discussion in > > https://lkml.org/lkml/2018/7/19/727 > > (that is another syzbot report, slightly different but I believe it > > points to the same issue) > > > > Basically, a more global view of the problem is a race between > > p9_tag_lookup returning a p9_req_t and another thread freeing it. > > > > Matthew wrote the problem himself in a comment in p9_tag_lookup in his new > > version that used to be in linux-next at the time (I took the commit out > > temporarily until I've had time to benchmark it, but it will come back in, > > just you're working on thin air right now because the bug was only found > > thanks to this commit): > > + /* There's no refcount on the req; a malicious server could > > cause > > + * us to dereference a NULL pointer > > + */ > > > > So a more proper solution would be to had a refcount to req, have > > p9_tag_lookup increment the refcount within rcu_read_lock, and have a > > deref function free the req when the count hits 0. > > Which commit ? that's a comment. Sorry, the commit is this one: http://lkml.kernel.org/r/20180711210225.19730-6-willy@infradead.org It's now out of my 9p-next branch due to performance reasons but I'll definitely take it back in once my performance mitigation patches have had a few reviews. > That sound like the proper solution. Let's do it that way then. Cool :) -- Dominique