From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FBAAC282CE for ; Fri, 5 Apr 2019 22:45:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5C0142171F for ; Fri, 5 Apr 2019 22:45:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="V1OlmrjV"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uV5MvX+o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C0142171F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1eviouXjMR4lYx68xCWui6M3ZaQsKbspevzRf9vtTy0=; b=V1OlmrjVFdJRdY 62c+drbzCLY9H4YFqlRDHG9ij8alfTi1dRmg7NJ03Br76yofF4AnuOuxXEWi6URJBT91GMM9sLvzf TdRigkIkpVsqI484sBciI3laDzp/X92Iu+tup5YMJdHr+FyNpI9NBTXkLyePw8OMuIm1hQ/tT93A1 R/alfmzm1BLxMfCgZqo609pSzFfSt2AEBkVswTeSEaNyx3NXosIJzeKqUc7wpoPcUieFcyiTX6gjD 91Dj6rgH7G6F4L3jb9sDmhP9LqEDNVjFTvNw0B+EHsC2QFnDGvzp1tbe3lrKSP7QMWVQO3wP69Zd7 D+RA1yPGGDHz1IVIKwPA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hCXa6-0007Vu-4D; Fri, 05 Apr 2019 22:45:06 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hCXa3-0006tf-1U for linux-arm-kernel@lists.infradead.org; Fri, 05 Apr 2019 22:45:04 +0000 Received: by mail-pl1-x642.google.com with SMTP id g12so3757340pll.11 for ; Fri, 05 Apr 2019 15:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aWEecOU3ZLSpruRw1eiZyJO4itUOhyN98xsznH722UA=; b=uV5MvX+ounc9QDg4AN2thG1LOUs6R9PPGD7NB2eY446G3H+GRwcx4eaJw9YUUyW2JB 35yifCkMqN77NqWiW4aujPKxplibGVFnk65ubaRgjGK37aoKJLdhtTpkGF+sAGGhn7Zj wYRe7OSF7OpQFSdbgnYDJzaSEkFcLS94V0dRw2zUw+bv8bFlaEkdorHXA6FwdFMXfgFs 2uJNgoiDytA+c5e6a29NLo6KUccar12jFd+RZ1vtDVD7U164W9NS4rkIHBvoZWXqSglV ikWZ11GmaRaWaDh9A+sPdcAzsATEm3l3oWYbnixjeoX/3Hr0N91xczf2ddFg3rErSOCx RwtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=aWEecOU3ZLSpruRw1eiZyJO4itUOhyN98xsznH722UA=; b=MzQrVA/3kgmk9zgpLTL9pLj6vSUgWT7NyTx5R5O4qzIk5ej7Iu5RA4FXgbrMyiG4kz pUZmG1EJPmNgiw3/oYyna9GStFnClNA72wD8NtSWW0+l9hSOBsEiO1QrMwP6YFyI/9Bm +gppQXXltRLkfztvOHsr1+rVUbH07ctfit3m3vzgdlT7SQWknoNAIxMwN8XSLCH3+/HG mwb+fJ66dVzR2ngWlE+GHpEw8kXGDf+P4RYgaGTIhaQDTf8AC5Wck5fwZFsPNXsM4Jwi 5jZxfq7sitZrDNA5jlV0ZnEUU0wKYAYTJovGa6Iac/Li2A6JsY/Kz1lRR+rLR98z96CN coxQ== X-Gm-Message-State: APjAAAUOStSuquJqhwvjCoGvVztsqWcEpPd8HiSyxbiY55Ls6sx5Cmn7 P7Q3wT78glaVCiWBWM44XzQ= X-Google-Smtp-Source: APXvYqy6EF7mgWkAk54FFi86v2T2k5ihXgjErgXquERF/kqyDItWyXbdLzLXG/U+3J0C+U+WlV8QPQ== X-Received: by 2002:a17:902:9a83:: with SMTP id w3mr15873502plp.241.1554504301077; Fri, 05 Apr 2019 15:45:01 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 20sm30910819pfn.131.2019.04.05.15.44.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2019 15:44:59 -0700 (PDT) Date: Fri, 5 Apr 2019 15:44:58 -0700 From: Guenter Roeck To: Michal Simek Subject: Re: [PATCH] xsysace: Fix error handling in ace_setup Message-ID: <20190405224458.GA19556@roeck-us.net> References: <1550594996-11453-1-git-send-email-linux@roeck-us.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1550594996-11453-1-git-send-email-linux@roeck-us.net> User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190405_154503_087381_013FAE11 X-CRM114-Status: GOOD ( 21.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Tue, Feb 19, 2019 at 08:49:56AM -0800, Guenter Roeck wrote: > If xace hardware reports a bad version number, the error handling code > in ace_setup() calls put_disk(), followed by queue cleanup. However, since > the disk data structure has the queue pointer set, put_disk() also > cleans and releases the queue. This results in blk_cleanup_queue() > accessing an already released data structure, which in turn may result > in a crash such as the following. > This crash is now quite persistent in mainline. The fix didn't make it. Should I stop testing virtex-ml507 with qemu ? Guenter > [ 10.681671] BUG: Kernel NULL pointer dereference at 0x00000040 > [ 10.681826] Faulting instruction address: 0xc0431480 > [ 10.682072] Oops: Kernel access of bad area, sig: 11 [#1] > [ 10.682251] BE PAGE_SIZE=4K PREEMPT Xilinx Virtex440 > [ 10.682387] Modules linked in: > [ 10.682528] CPU: 0 PID: 1 Comm: swapper Tainted: G W 5.0.0-rc6-next-20190218+ #2 > [ 10.682733] NIP: c0431480 LR: c043147c CTR: c0422ad8 > [ 10.682863] REGS: cf82fbe0 TRAP: 0300 Tainted: G W (5.0.0-rc6-next-20190218+) > [ 10.683065] MSR: 00029000 CR: 22000222 XER: 00000000 > [ 10.683236] DEAR: 00000040 ESR: 00000000 > [ 10.683236] GPR00: c043147c cf82fc90 cf82ccc0 00000000 00000000 00000000 00000002 00000000 > [ 10.683236] GPR08: 00000000 00000000 c04310bc 00000000 22000222 00000000 c0002c54 00000000 > [ 10.683236] GPR16: 00000000 00000001 c09aa39c c09021b0 c09021dc 00000007 c0a68c08 00000000 > [ 10.683236] GPR24: 00000001 ced6d400 ced6dcf0 c0815d9c 00000000 00000000 00000000 cedf0800 > [ 10.684331] NIP [c0431480] blk_mq_run_hw_queue+0x28/0x114 > [ 10.684473] LR [c043147c] blk_mq_run_hw_queue+0x24/0x114 > [ 10.684602] Call Trace: > [ 10.684671] [cf82fc90] [c043147c] blk_mq_run_hw_queue+0x24/0x114 (unreliable) > [ 10.684854] [cf82fcc0] [c04315bc] blk_mq_run_hw_queues+0x50/0x7c > [ 10.685002] [cf82fce0] [c0422b24] blk_set_queue_dying+0x30/0x68 > [ 10.685154] [cf82fcf0] [c0423ec0] blk_cleanup_queue+0x34/0x14c > [ 10.685306] [cf82fd10] [c054d73c] ace_probe+0x3dc/0x508 > [ 10.685445] [cf82fd50] [c052d740] platform_drv_probe+0x4c/0xb8 > [ 10.685592] [cf82fd70] [c052abb0] really_probe+0x20c/0x32c > [ 10.685728] [cf82fda0] [c052ae58] driver_probe_device+0x68/0x464 > [ 10.685877] [cf82fdc0] [c052b500] device_driver_attach+0xb4/0xe4 > [ 10.686024] [cf82fde0] [c052b5dc] __driver_attach+0xac/0xfc > [ 10.686161] [cf82fe00] [c0528428] bus_for_each_dev+0x80/0xc0 > [ 10.686314] [cf82fe30] [c0529b3c] bus_add_driver+0x144/0x234 > [ 10.686457] [cf82fe50] [c052c46c] driver_register+0x88/0x15c > [ 10.686610] [cf82fe60] [c09de288] ace_init+0x4c/0xac > [ 10.686742] [cf82fe80] [c0002730] do_one_initcall+0xac/0x330 > [ 10.686888] [cf82fee0] [c09aafd0] kernel_init_freeable+0x34c/0x478 > [ 10.687043] [cf82ff30] [c0002c6c] kernel_init+0x18/0x114 > [ 10.687188] [cf82ff40] [c000f2f0] ret_from_kernel_thread+0x14/0x1c > [ 10.687349] Instruction dump: > [ 10.687435] 3863ffd4 4bfffd70 9421ffd0 7c0802a6 93c10028 7c9e2378 93e1002c 38810008 > [ 10.687637] 7c7f1b78 90010034 4bfffc25 813f008c <81290040> 75290100 4182002c 80810008 > [ 10.688056] ---[ end trace 13c9ff51d41b9d40 ]--- > > Fix the problem by setting the disk queue pointer to NULL before calling > put_disk(). A more comprehensive fix might be to rearrange the code > to check the hardware version before initializing data structures, > but I don't know if this would have undesirable side effects, and > it would increase the complexity of backporting the fix to older kernels. > > Fixes: 74489a91dd43a ("Add support for Xilinx SystemACE CompactFlash interface") > Signed-off-by: Guenter Roeck > Acked-by: Michal Simek > --- > drivers/block/xsysace.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c > index 87ccef4bd69e..32a21b8d1d85 100644 > --- a/drivers/block/xsysace.c > +++ b/drivers/block/xsysace.c > @@ -1090,6 +1090,8 @@ static int ace_setup(struct ace_device *ace) > return 0; > > err_read: > + /* prevent double queue cleanup */ > + ace->gd->queue = NULL; > put_disk(ace->gd); > err_alloc_disk: > blk_cleanup_queue(ace->queue); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel