Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2613524imm; Fri, 20 Jul 2018 01:35:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfd9DneA/HSheC3DqZxDKvJGNxpMep4PyXHW0F5KRpq+yALHRCR7qPNWiSHGUtjbYzsmAcm X-Received: by 2002:a17:902:6684:: with SMTP id e4-v6mr1196282plk.35.1532075755850; Fri, 20 Jul 2018 01:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532075755; cv=none; d=google.com; s=arc-20160816; b=lNtx85YNoGupeKXqvTYC2jzXgDwXYIKOZQS+UbYndjByPWA08eoVLePv69311x2kfi BO80r8m8ONIKejpAvAx1UTI2Q7/AgZST5YsrS026zAp7zctaJjQOuJGVJeGra8V9MXSK +nJ74CstIMMLQ+Lob7osSXlWiwfS9jmvqQaAajWOzTksrIVU6/kKA9umCq5+jlye8bGD Qm52xIScWdre5/1/uYkDzQJyZ6tKSYZdM7vg//8UzBNRMqksXBqA4olrwvXhfaoYqOZO kjc42Xbs5am87d6O+LYvsKt41BLV0J8cr7mAPCKVCH4KHsj6XQJJCip01LYKmCJfLBJB PVJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=AavHDyh/fA3UGA3Z3usjHfTZtAxrGOKLFRhOriBvqRc=; b=U/JYjqeJRb4RPaYjhx9b+D3smZ/rzvAqm28d/qlAxB6A6nFuWJzrC6JzO+Ay7u4tcG Gi0LUY53qi/DBVOjpP0tS+zfh1MCDQZVJecv63/Nutl7prN6Zrzx7rPrCymTHIFJu1H8 cBnTUnoBxNRViP7zPMZrq+wNHOtSjjoAMQaY+5PVLC1D/vXU7UGcki/yT9UYfByjJAeZ xLayzXjobe4olD9mF/uRyvTn+AcTpW88Zgvwain+vnMBGx8jDfqnzeiD6LzPUUKEg6NU H7BlAEnJyYO1TBCpKdu+bDYFbLNz7B96cA9yntgBx3JQxCywwtmT7tqKkgmB+FKq9KqS QOhQ== 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 t6-v6si1322961pgk.215.2018.07.20.01.35.41; Fri, 20 Jul 2018 01:35:55 -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 S1728155AbeGTJWO (ORCPT + 99 others); Fri, 20 Jul 2018 05:22:14 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:37196 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727133AbeGTJWO (ORCPT ); Fri, 20 Jul 2018 05:22:14 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0AA831BC4BBDF; Fri, 20 Jul 2018 16:35:00 +0800 (CST) Received: from [127.0.0.1] (10.177.16.168) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.382.0; Fri, 20 Jul 2018 16:34:58 +0800 Subject: Re: [V9fs-developer] [PATCH] /net/9p/trans_fd.c: fix race-condition by flushing workqueue before the kfree() To: Tomas Bortoli , , , References: <20180719200607.30286-1-tomasbortoli@gmail.com> CC: , , , , From: jiangyiwen Message-ID: <5B519EB0.8000700@huawei.com> Date: Fri, 20 Jul 2018 16:34:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20180719200607.30286-1-tomasbortoli@gmail.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.16.168] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/7/20 4:06, Tomas Bortoli wrote: > The patch adds the flush in p9_mux_poll_stop() as it the function used by > p9_conn_destroy(), in turn called by p9_fd_close() to stop the async > polling associated with the data regarding the connection. > > Signed-off-by: Tomas Bortoli > Reported-by: syzbot+39749ed7d9ef6dfb23f6@syzkaller.appspotmail.com > --- > As shown by Syzbot, it is possible to provoke a race between p9_fd_close() > and p9_poll_workfn() that is called to take care of the async read/write work > to do. To make sure p9_fd_close() frees "trans" when it is not used anymore, > it has to explicitly call flush_scheduled_work() before the kfree(). > > net/9p/trans_fd.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c > index bf459ee0feab..76ae134c05d9 100644 > --- a/net/9p/trans_fd.c > +++ b/net/9p/trans_fd.c > @@ -185,6 +185,8 @@ static void p9_mux_poll_stop(struct p9_conn *m) > spin_lock_irqsave(&p9_poll_lock, flags); > list_del_init(&m->poll_pending_link); > spin_unlock_irqrestore(&p9_poll_lock, flags); > + > + flush_scheduled_work(); I suggest we should use flush_work(&p9_poll_work), flush_scheduled_work is not suitable. Thanks. > } > > /** >