Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2874658imm; Fri, 20 Jul 2018 06:29:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfgZ9Gn+O1ISnRFAsI6PwlnLfgtrc6cqAG6i3g5ikqQXbM45h3VmWtjhxBUo3Q00eh4CeSK X-Received: by 2002:a63:d011:: with SMTP id z17-v6mr2085531pgf.272.1532093389671; Fri, 20 Jul 2018 06:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532093389; cv=none; d=google.com; s=arc-20160816; b=Gotm3wRaSLNnGmcqkL+HTHUOEGbd1WBVY9Uj0eA4lijg0Qy5IqswMK3FSKIeMzDARZ lpnzgr1YfsyNykJBUzSbbfBPjzVswdb1PfVjyXdaHd85qCMgnf4wsFqVlRxbp0uKC8yF TpnzIizMAzQUZZCagHPpNalD9AcSLo2S2bn+Wf6OKGurZqSvJn+6KlXa/qPhN81ILuUp kGb/rSolTd0q9XWyXgOhRasSm+pOXSSvofj2o8gq6axK+bXramDGADcJP/Jb0OnoZkg8 qQ2ECGdkdGdsvf8FyLVjHqfw6SfGPTX4yV35UZy1rwjci27HGCGkxgZggXdw2G16kCcN 5kUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=k8XIvvLyAABzUp2LyIk88Y5yrKyYx/KgnzhQ7AveH5g=; b=ADYsYuehJ41E+OO1JCMte9/ThGUgoY4e3wsFaxzhzZgpe+Iw3oW33HtYfNsD95aYi6 EI3SgSyvAL87CgX+pcimgFGJopQXBIoxDNu7viK+CqzujGv7iNG6wULLA7eId9eW1zfP nGVxJnkX/HpkCw1dYlMHUQUa0y68K5+NNWBXWt/tKVHVk9f9qwReZWHKoe646kYqPSZv diyuJAlFg5voZuvZwLLlhNXQ6x4ZzDAncwO/9JgiyMLLmcdcrbkd+blaSQM8J+A0APwl FNV5ab/EiaAXVO5v+u/zY1n2KTo6oRaqv4rGxhTRWmFaULLJziGG4cWHR03OZo1T6CLE Uuqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y8FitExC; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 63-v6si1705161pld.374.2018.07.20.06.29.35; Fri, 20 Jul 2018 06:29:49 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y8FitExC; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731986AbeGTOQl (ORCPT + 99 others); Fri, 20 Jul 2018 10:16:41 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:39275 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731417AbeGTOQk (ORCPT ); Fri, 20 Jul 2018 10:16:40 -0400 Received: by mail-lf1-f67.google.com with SMTP id a134-v6so1807342lfe.6; Fri, 20 Jul 2018 06:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=k8XIvvLyAABzUp2LyIk88Y5yrKyYx/KgnzhQ7AveH5g=; b=Y8FitExC7F5iZif23xx3LdSe0TuupubDZFtPMBqzXgG7I0jMt2SjlaebYLUBntTGNU q7WQ247bpzrV18qcLSV/EZpO7VyT1BENHheyM1jiINmsuHE75P1pV6IS5DdxsMPemOiJ uy0Q1QFs9dteIslCIbH1MbgH4L4tLkNI83xSLzgRv3ICUqaxD3TSUAcGMjSrnETqETE/ OYTVflgfPuKOG3vovE9KxGb/Ij5D4Q49X69635dR4d3AVr5FUlAhuole0SqHIYkp+Zhm C8DSJmpQO3czVNJ0gunuZauLIY5AXNqDxvyNVEm9N8/q6auyVWUwzKN81tFP8/A9xhL8 fw2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k8XIvvLyAABzUp2LyIk88Y5yrKyYx/KgnzhQ7AveH5g=; b=uefAjZlYI1XNSMT0CfWcGksl0y19xOIJz5SjpXXeiX4gNYWo45jIJ9jfgHqohh0tco MHBL0Pr3XCkOqukwpxHFkcX7BuJ69m/9mrVwOFXERGdwi7POFf4vvj7vSJFJEoYzG3Qk CYi30zZ71URtM+DNvNo4DefGlWmzB33ZLU+CW/lhYMPtGkrNiyoD7JndkJu47cpKMykp f8D3gASkDbgXDZIDH/v/AwEVLSleGvSns1z8pfRz2tT2dNffg4jmc2S4ewuFvgOADgtp aNAi5CQSRZw7RnY9JZ/BR3oMVCTGsQ7jdlNCPNXMUUgrqmStGZ6rAPSYbs+RrPFcLKhy GZKw== X-Gm-Message-State: AOUpUlEpQc3OWrSg3vi0mFifoN9p0jXE3Js4lpfuH+JE3jpNHtxzHKYV dyhl+O3Dlk+UMKfgSGorrvM= X-Received: by 2002:a19:cf95:: with SMTP id f143-v6mr1497258lfg.101.1532093301082; Fri, 20 Jul 2018 06:28:21 -0700 (PDT) Received: from debian-tom.lan ([2001:2012:22e:1b00:f2e2:9015:9262:3fde]) by smtp.gmail.com with ESMTPSA id g28-v6sm299029lfh.92.2018.07.20.06.28.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 06:28:20 -0700 (PDT) From: Tomas Bortoli To: ericvh@gmail.com, rminnich@sandia.gov, lucho@ionkov.net Cc: jiangyiwen@huawei.com, davem@davemloft.net, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com, Tomas Bortoli Subject: [PATCH] net/9p/trans_fd.c: fix double list_del() and race in access Date: Fri, 20 Jul 2018 15:28:01 +0200 Message-Id: <20180720132801.22749-1-tomasbortoli@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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; -- 2.11.0