Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4160453imm; Wed, 5 Sep 2018 11:41:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ6BeTV0OnmVoLw4cN2rD6u6W277D50E2Awd1g6iN1YQsWhWqt1gR9gnkP9pRzhQgua5o9l X-Received: by 2002:a62:225d:: with SMTP id i90-v6mr41749182pfi.246.1536172878610; Wed, 05 Sep 2018 11:41:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536172878; cv=none; d=google.com; s=arc-20160816; b=0PC+/YXoOwVEVfB++JhNuqBVm4R9Hcj24EwgKdNnYFIfe/VROO23hGflpRElmzN1lU la4LUH7SwTjmVsVjsoc5QjkTaAgXJumae2w9TtSeIBGFa7DUVdzSM7od9Z6bEOjLdk2l F1hH5dkGTSK2NzsQjehsceyyBCeGTvWJMQzg9PqYP1l+y+VMyOHLm0vFiQCchDAXl9g/ 5CpSr2H/iAWHq/6td+IHU1KlNqV1Y0IsIePJGxgboGfpdDEjTjRiWWQSQvIjhXhh2hcu cVAofqUnwZK5tY6pZjNXzzjuUpKIzo3lCTpf1BjDMARxfvrUnBqyNwKaE2pcDrxIsHb1 xFMg== 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:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id; bh=O0c008hCcWAGDMfmcme+kNzANUawNBybmvygkvFZb04=; b=oNgL4xndxY7sSE4l0RyU2N8sYJ+gJ1K9cHMU6Fx1PuUbvvF9ZmpFUrv/2WhuX117Dl s+BTTRQ1PNBe+01FIjuioPS7GEpRdKJE/2b7aw4fCsCMCFkKcAkDoY9P/bGvAGPT3jKN WEIQubYMBd4cu188MtrgQjqo/4Siy8Y2+rnJ0az/NATpk4joiAppAOnCSxLp0A/gnvrm zlsNgTqx8Sbv6RYITC8h0LqNq9Wl7H704oa4bmXZmW88S4rVQ/PHzfMmzNsO6YXIz89/ OKBV1w0txFzp9ugc4xHLNX1nedIxX6r3JAvmi/tlAXwBqhUi/Arm0ogjU1aI/vdViLCq 0MZQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10-v6si2778390pgc.105.2018.09.05.11.41.03; Wed, 05 Sep 2018 11:41:18 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727724AbeIEXKs (ORCPT + 99 others); Wed, 5 Sep 2018 19:10:48 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:60443 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727627AbeIEXKs (ORCPT ); Wed, 5 Sep 2018 19:10:48 -0400 Received: from [148.252.241.226] (helo=xylophone) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1fxci0-0004SU-Fa; Wed, 05 Sep 2018 19:39:20 +0100 Message-ID: <1536172759.3024.44.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 026/124] iwlwifi: pcie: fix race in Rx buffer allocator From: Ben Hutchings To: Shaul Triebitz , Luca Coelho Cc: stable@vger.kernel.org, Sasha Levin , Greg Kroah-Hartman , LKML Date: Wed, 05 Sep 2018 19:39:19 +0100 In-Reply-To: <20180804082703.421702408@linuxfoundation.org> References: <20180804082702.434482435@linuxfoundation.org> <20180804082703.421702408@linuxfoundation.org> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2018-08-04 at 11:00 +0200, Greg Kroah-Hartman wrote: > 4.4-stable review patch.  If anyone has any objections, please let me know. > > ------------------ > > From: Shaul Triebitz > > [ Upstream commit 0f22e40053bd5378ad1e3250e65c574fd61c0cd6 ] > > Make sure the rx_allocator worker is canceled before running the > rx_init routine.  rx_init frees and re-allocates all rxb's pages.  The > rx_allocator worker also allocates pages for the used rxb's.  Running > rx_init and rx_allocator simultaniously causes a kernel panic.  Fix > that by canceling the work in rx_init. > > Signed-off-by: Shaul Triebitz > Signed-off-by: Luca Coelho > Signed-off-by: Sasha Levin > Signed-off-by: Greg Kroah-Hartman > --- >  drivers/net/wireless/iwlwifi/pcie/rx.c |    2 ++ >  1 file changed, 2 insertions(+) > > --- a/drivers/net/wireless/iwlwifi/pcie/rx.c > +++ b/drivers/net/wireless/iwlwifi/pcie/rx.c > @@ -713,6 +713,8 @@ int iwl_pcie_rx_init(struct iwl_trans *t >   WQ_HIGHPRI | WQ_UNBOUND, 1); >   INIT_WORK(&rba->rx_alloc, iwl_pcie_rx_allocator_work); >   > + cancel_work_sync(&rba->rx_alloc); > + >   spin_lock(&rba->lock); >   atomic_set(&rba->req_pending, 0); >   atomic_set(&rba->req_ready, 0); This seems to be an incomplete fix. INIT_WORK() will overwrite the list pointers in the work item, so there is still a race condition. I think that the RX initialisation and reinitialisation/reset cases need to be explicitly distinguished. In the initialisation case the driver should do only INIT_WORK() and in the reset case it should do only cancel_work_sync() (although it would be safe to do INIT_WORK() *after* that). Ben. -- Ben Hutchings, Software Developer   Codethink Ltd https://www.codethink.co.uk/ Dale House, 35 Dale Street Manchester, M1 2HF, United Kingdom