Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5321106imm; Sun, 22 Jul 2018 19:25:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf7NL4Xt/4bYRp+MbtK6H6/wVfaUmDtHQADXZJfGOmUxLwKmzwKlqGwdX9J5Bla43Ru5xxa X-Received: by 2002:a62:9b57:: with SMTP id r84-v6mr11299399pfd.6.1532312744402; Sun, 22 Jul 2018 19:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532312744; cv=none; d=google.com; s=arc-20160816; b=zDccOeoVJ7rVqlbl+n4mIfF1lFiRpEdQikaaeITUuaaTDqgv6dKtMGzflC9SDJ++rW 4mTNGsWGYQu+2mvxvA3b9ro98sxG1Eu6/F80ChSGwE0HBE9whR2paUWzieyOGQLi7Xqe 1jF557o4uurkBxvih9EDaTWbNkfqTn+JjPK9scGqXqr/6MG/hvx4nZmYBTg2qZBFWGDM Mn6+ci7lBF7pYQEjQP8ihzSwNqOWMnIh2XyBBuChk4w/XEgpfi/3Jy/4H45DWOyDm5/D YhS7e7Z/TI5fgGEqbj3LT1x//2L1b03Nf5mUcBEckOafQtKWzNkIBX23wiWuiH2JiYWI 0YSg== 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=dNl8iBdv3sMdY3vKQfW/NtK3vEpv2IXtRQAldJRjR8w=; b=SKkumT4Fa5whjZospSzS8XvNDElJpCdqxj+Q3dsvbKM9xgU9b3ugT3eX89xTQNRw4Q BfKh7RGMecbucdgJ3m1oZxu2Ddrn72uNi0vdeOsoydERrzmMCpUmYzXZ/e7EAg89Ow6e XsfTK04fuCjtjAf5h4H6Fvi1fxkGE9Q3Nk0WL+5taGyAggR/KF4RFODrjpjVsOQ1wED/ 2/LJf7YFfl0qhHNFxi1L6a2WK0gbt5EIO+Fc2CCD6Pm6G5SXXeQTBJs+gc2mLyrqIOCP 8aY1WGpOX5sZGIRIMbt5+e3JIWDonlLqjZA63QXwQoNVvsrW07P/tTDpghewqOGBn0oD joSw== 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 c18-v6si6790645pgp.467.2018.07.22.19.25.29; Sun, 22 Jul 2018 19:25:44 -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 S1731269AbeGWDXc (ORCPT + 99 others); Sun, 22 Jul 2018 23:23:32 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9664 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730798AbeGWDXb (ORCPT ); Sun, 22 Jul 2018 23:23:31 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 34F0873995312; Mon, 23 Jul 2018 10:24:37 +0800 (CST) Received: from [127.0.0.1] (10.177.16.168) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.382.0; Mon, 23 Jul 2018 10:24:34 +0800 Subject: Re: [PATCH] net/9p/trans_fd.c: fix double list_del() and race in access To: Tomas Bortoli , , , References: <20180720132801.22749-1-tomasbortoli@gmail.com> CC: , , , , From: jiangyiwen Message-ID: <5B553C5E.4000200@huawei.com> Date: Mon, 23 Jul 2018 10:24:30 +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: <20180720132801.22749-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 21:28, Tomas Bortoli wrote: > This patch uses list_del_init() instead of list_del() to eliminate "req_list". This to prevent double list_del()'s calls to the same list from provoking a GPF. Furthermore, this patch fixes an access to "req_list" that was made without getting the relative lock. > I suggest you can apply a 72-character line limit to your commit messages. Others looks good to me. Thanks, Yiwen. > Signed-off-by: Tomas Bortoli > Reported-by: syzbot+735d926e9d1317c3310c@syzkaller.appspotmail.com > --- > > net/9p/trans_fd.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c > index a64b01c56e30..131bb1f059e6 100644 > --- a/net/9p/trans_fd.c > +++ b/net/9p/trans_fd.c > @@ -223,7 +223,9 @@ static void p9_conn_cancel(struct p9_conn *m, int err) > > list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) { > p9_debug(P9_DEBUG_ERROR, "call back req %p\n", req); > - list_del(&req->req_list); > + spin_lock_irqsave(&m->client->lock, flags); > + list_del_init(&req->req_list); > + spin_unlock_irqrestore(&m->client->lock, flags); > if (!req->t_err) > req->t_err = err; > p9_client_cb(m->client, req, REQ_STATUS_ERROR); > @@ -369,7 +371,7 @@ static void p9_read_work(struct work_struct *work) > spin_lock(&m->client->lock); > if (m->req->status != REQ_STATUS_ERROR) > status = REQ_STATUS_RCVD; > - list_del(&m->req->req_list); > + list_del_init(&m->req->req_list); > spin_unlock(&m->client->lock); > p9_client_cb(m->client, m->req, status); > m->rc.sdata = NULL; > @@ -684,7 +686,7 @@ static int p9_fd_cancel(struct p9_client *client, struct p9_req_t *req) > spin_lock(&client->lock); > > if (req->status == REQ_STATUS_UNSENT) { > - list_del(&req->req_list); > + list_del_init(&req->req_list); > req->status = REQ_STATUS_FLSHD; > ret = 0; > } > @@ -701,7 +703,7 @@ static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req) > * remove it from the list. > */ > spin_lock(&client->lock); > - list_del(&req->req_list); > + list_del_init(&req->req_list); > spin_unlock(&client->lock); > > return 0; >