From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752653AbdJ3J5c (ORCPT ); Mon, 30 Oct 2017 05:57:32 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:47810 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbdJ3J53 (ORCPT ); Mon, 30 Oct 2017 05:57:29 -0400 X-Google-Smtp-Source: ABhQp+SoCjjthg+a+o8iXm5bGioUh9fbIXYoD+EKeXVPFnBMKR1oU6kqcYteWMqXPUlXzxhz1y9t+g== Date: Mon, 30 Oct 2017 10:57:26 +0100 From: Johan Hovold To: Lars-Peter Clausen Cc: Johan Hovold , Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] spi: spi-axi: take extra controller reference before deregistration Message-ID: <20171030095726.GA7223@localhost> References: <20171029115625.32385-1-johan@kernel.org> <20171029115625.32385-3-johan@kernel.org> <2a83c1f1-9203-eb97-5595-7a8da7261128@metafoo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2a83c1f1-9203-eb97-5595-7a8da7261128@metafoo.de> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 30, 2017 at 10:48:23AM +0100, Lars-Peter Clausen wrote: > On 10/29/2017 12:56 PM, Johan Hovold wrote: > > Take an extra reference to the controller to avoid use-after-free in > > free_irq() which is called only after the controller has been > > deregistered and freed. > > > > Note that this is not an issue for this particular driver which does not > > use shared interrupts, but free_irq() could otherwise end up accessing > > the freed controller when CONFIG_DEBUG_SHIRQ is set. > > Strictly speaking there is no guarantee that the IRQ handler does not run > until free_irq() has been called. And since the SPI master is referenced in > the IRQ handler there could be an use-after-free condition. So there is kind > of a real issue here as well. But it should be really really hard to trigger > it unless the hardware misbehaves. You're right of course. Let me update the commit message in a v2 of the series. > > Defer controller release until free_irq() returns to prevent this > > from ever becoming an issue should this code be replicated in other > > drivers. > > > > Cc: Lars-Peter Clausen > > Signed-off-by: Johan Hovold > > Acked-by: Lars-Peter Clausen Thanks, Johan