Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3779717imm; Mon, 30 Jul 2018 03:25:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe71euUpowsjyuuwncDhp++yMC0LjXRC70hwGvOLhqG4Rj3yZi/H3IB2ZpjwOxVz4fGKRZ3 X-Received: by 2002:a65:5205:: with SMTP id o5-v6mr15843162pgp.108.1532946311497; Mon, 30 Jul 2018 03:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532946311; cv=none; d=google.com; s=arc-20160816; b=V2Yy1UWgRetRqwu5QzjSu6NVeCTJfGI1DUgKGMJ0w5PrKb2A8/NqQTU5vM/LP+PMMU 5JnX5fPj8Nt5aay6f7flTTCqcOz7BxH6gMIWD09dtOjzkzFSB0hiCa0uzd9hfZCwE7NM bLE3g4YeIkbtIKaidTeeUlLEmsH36Mmikf00Shh+lh9P/I2f9w48yXKq+GnE5eXtJMTX wEZk3HVcN4bGnxdUpnm9KSeMgzgVMkszMwtUYOP5nJm7AOJQrlu8elhBDFDVAoNPXzSB KYOYIFvMfGRQEUbQh1kBr1lmesa6U9Oytdl74NFelyQo9iuexDHxHZ0nL5UJAS8oq59y 4taA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=pSSYWBzLfLG+2tG3jpT1MjwBE9n6M0+KatVgG/MZzFY=; b=nOxJfXl5hyZmMj+lKdCpwOZ8jbzGATLn4PI1x0IyZKtR3a/sNhOoHZst5cdJ9zJ4pi 7+C2y5vDdv+EA+dtt/og40XTsXw0lj4+cilXDckFVn6K38esMquUs8qHLsPSg1D3p5Ms ffnNYK2Un8T6YBrfCxGPeUs7hhlO/v8yMrGPw5zdNm9PCNR1/gCvLkO+SKWMcK03nhaQ nOhLLMP/wUZmLGXpKFc0bkA6Ln4lM7n9/55Q0OxB6cwKZu+6CPoWygkAjGXmXc1XBfNf 1V8l4/nCQpfYZCHJ7aVBMOFfJGvLbBWcXKPEWudCgXjhwH+v4IfsfR4GpVzLASKJ2SPr h0cQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b2-v6si9839754plm.202.2018.07.30.03.24.57; Mon, 30 Jul 2018 03:25:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726919AbeG3L6Y (ORCPT + 99 others); Mon, 30 Jul 2018 07:58:24 -0400 Received: from nautica.notk.org ([91.121.71.147]:37439 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbeG3L6Y (ORCPT ); Mon, 30 Jul 2018 07:58:24 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id BB95FC009; Mon, 30 Jul 2018 12:24:04 +0200 (CEST) Date: Mon, 30 Jul 2018 12:23:49 +0200 From: Dominique Martinet To: Tomas Bortoli Cc: davem@davemloft.net, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com Subject: Re: [PATCH] 9p: fix Use-After-Free in p9_write_work() 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 Content-Disposition: inline In-Reply-To: <4ac26f97-778b-6527-9a5b-08b7bfc8a5e8@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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