From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org ([198.145.29.99]:49532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726675AbeLRVoF (ORCPT ); Tue, 18 Dec 2018 16:44:05 -0500 Date: Tue, 18 Dec 2018 16:44:03 -0500 From: Sasha Levin To: "Michael J. Ruhl" Cc: stable@vger.kernel.org Subject: Re: [PATCH] IB/hfi1: Remove race conditions in user_sdma send path Message-ID: <20181218214403.GG2746@sasha-vm> References: <20181218210022.7019.83923.stgit@phstlrhel7.ph.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20181218210022.7019.83923.stgit@phstlrhel7.ph.intel.com> Sender: stable-owner@vger.kernel.org List-ID: On Tue, Dec 18, 2018 at 04:00:22PM -0500, Michael J. Ruhl wrote: >From: Michael J. Ruhl > >commit 28a9a9e83ceae2cee25b9af9ad20d53aaa9ab951 upstream > >Packet queue state is over used to determine SDMA descriptor >availablitity and packet queue request state. > >cpu 0 ret = user_sdma_send_pkts(req, pcount); >cpu 0 if (atomic_read(&pq->n_reqs)) >cpu 1 IRQ user_sdma_txreq_cb calls pq_update() (state to _INACTIVE) >cpu 0 xchg(&pq->state, SDMA_PKT_Q_ACTIVE); > >At this point pq->n_reqs == 0 and pq->state is incorrectly >SDMA_PKT_Q_ACTIVE. The close path will hang waiting for the state >to return to _INACTIVE. > >This can also change the state from _DEFERRED to _ACTIVE. However, >this is a mostly benign race. > >Remove the racy code path. > >Use n_reqs to determine if a packet queue is active or not. > >Cc: # 4.19.x >Reviewed-by: Mitko Haralanov >Reviewed-by: Mike Marciniszyn >Signed-off-by: Michael J. Ruhl >Signed-off-by: Dennis Dalessandro >Signed-off-by: Jason Gunthorpe I've queued all 3 to their respective trees, thank you. -- Thanks, Sasha