From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Subject: Re: [PATCH for-next 05/14] IB/hfi1: Use after free race condition in send context error path Date: Fri, 4 May 2018 12:38:39 -0600 Message-ID: <20180504183839.6wexn5phhiyo6xra@ziepe.ca> References: <20180502133831.20730.42677.stgit@scvm10.sc.intel.com> <20180502134249.20730.78919.stgit@scvm10.sc.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20180502134249.20730.78919.stgit@scvm10.sc.intel.com> Sender: stable-owner@vger.kernel.org To: Dennis Dalessandro Cc: dledford@redhat.com, linux-rdma@vger.kernel.org, "Michael J. Ruhl" , Mike Marciniszyn , stable@vger.kernel.org List-Id: linux-rdma@vger.kernel.org On Wed, May 02, 2018 at 06:42:51AM -0700, Dennis Dalessandro wrote: > From: Michael J. Ruhl > > A pio send egress error can occur when the PSM library attempts to > to send a bad packet. That issue is still being investigated. > > The pio error interrupt handler then attempts to progress the recovery > of the errored pio send context. > > Code inspection reveals that the handling lacks the necessary locking > if that recovery interleaves with a PSM close of the "context" object > contains the pio send context. > > The lack of the locking can cause the recovery to access the already > freed pio send context object and incorrectly deduce that the pio > send context is actually a kernel pio send context as shown by the > NULL deref stack below: > > [] _dev_info+0x6c/0x90 > [] sc_restart+0x70/0x1f0 [hfi1] > [] ? __schedule+0x424/0x9b0 > [] sc_halted+0x15/0x20 [hfi1] > [] process_one_work+0x17a/0x440 > [] worker_thread+0x126/0x3c0 > [] ? manage_workers.isra.24+0x2a0/0x2a0 > [] kthread+0xcf/0xe0 > [] ? insert_kthread_work+0x40/0x40 > [] ret_from_fork+0x58/0x90 > [] ? insert_kthread_work+0x40/0x40 > > This is the best case scenario and other scenarios can corrupt the > already freed memory. > > Fix by adding the necessary locking in the pio send context error > handler. > > Cc: # 4.9.x > Reviewed-by: Mike Marciniszyn > Reviewed-by: Dennis Dalessandro > Signed-off-by: Michael J. Ruhl > Signed-off-by: Dennis Dalessandro > --- > drivers/infiniband/hw/hfi1/chip.c | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) Why are you sending this to for-next not for-rc? Jason