Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AF1AC433F5 for ; Wed, 10 Nov 2021 21:55:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 0DCCE61267 for ; Wed, 10 Nov 2021 21:55:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0DCCE61267 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7410089DA3; Wed, 10 Nov 2021 21:55:27 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A0E489DA3 for ; Wed, 10 Nov 2021 21:55:25 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B35D521B28; Wed, 10 Nov 2021 21:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1636581323; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5s6ry9PrsNAtJBmEbIUu0GOppraw+Wb2T9D1xbL6BxQ=; b=uMr9eCqIeIVOq+qxmFmDB5NAaRO6qjdvdVfYnzw9k7Im/9eOk7thzzYhwoVKzvgP3NDYNn VFPf7dLmzndH6HmTA7CdZNVctCCFsf8Vtb8C6gVyoqctiLPcIeWrrg7ZUJeiquv4PgOnsF x5rkIPY1KyGfIAMVL2NJuAbYb1RkCFs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1636581323; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5s6ry9PrsNAtJBmEbIUu0GOppraw+Wb2T9D1xbL6BxQ=; b=DBtWxijukR/9GBCjipa9ih7mHbHcf9wwW5QPN99eoqqCD9r/Hf8fvyQPfZ/xAOCmwQ5bWF AU9bv6YKQHRPCzBg== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 607E2A3B81; Wed, 10 Nov 2021 21:55:23 +0000 (UTC) Date: Wed, 10 Nov 2021 22:55:23 +0100 Message-ID: From: Takashi Iwai To: Kai Vehmanen In-Reply-To: <20211110210307.1172004-1-kai.vehmanen@linux.intel.com> References: <20211110210307.1172004-1-kai.vehmanen@linux.intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Intel-gfx] [PATCH] ALSA: hda: fix general protection fault in azx_runtime_idle X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Wed, 10 Nov 2021 22:03:07 +0100, Kai Vehmanen wrote: > > Fix a corner case between PCI device driver remove callback and > runtime PM idle callback. > > Following sequence of events can happen: > - at azx_create, context is allocated with devm_kzalloc() and > stored as pci_set_drvdata() > - user-space requests to unbind audio driver > - dd.c:__device_release_driver() calls PCI remove > - pci-driver.c:pci_device_remove() calls the audio > driver azx_remove() callback and this is completed > - pci-driver.c:pm_runtime_put_sync() leads to a call > to rpm_idle() which again calls azx_runtime_idle() > - the azx context object, as returned by dev_get_drvdata(), > is no longer valid > -> access fault in azx_runtime_idle when executing > struct snd_card *card = dev_get_drvdata(dev); > chip = card->private_data; > if (chip->disabled || hda->init_failed) > > This was discovered by i915_module_load test with 5.15.0 based > linux-next tree. > > Example log caught by i915_module_load test with linux-next > https://intel-gfx-ci.01.org/tree/linux-next/ > > <4> [264.038232] general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b73f0: 0000 [#1] PREEMPT SMP NOPTI > <4> [264.038248] CPU: 0 PID: 5374 Comm: i915_module_loa Not tainted 5.15.0-next-20211109-gc8109c2ba35e-next-20211109 #1 > [...] > <4> [264.038267] RIP: 0010:azx_runtime_idle+0x12/0x60 [snd_hda_intel] > [...] > <4> [264.038355] Call Trace: > <4> [264.038359] > <4> [264.038362] __rpm_callback+0x3d/0x110 > <4> [264.038371] rpm_idle+0x27f/0x380 > <4> [264.038376] __pm_runtime_idle+0x3b/0x100 > <4> [264.038382] pci_device_remove+0x6d/0xa0 > <4> [264.038388] device_release_driver_internal+0xef/0x1e0 > <4> [264.038395] unbind_store+0xeb/0x120 > <4> [264.038400] kernfs_fop_write_iter+0x11a/0x1c0 > > Fix the issue by setting drvdata to NULL at end of azx_remove(). > > Signed-off-by: Kai Vehmanen > --- > sound/pci/hda/hda_intel.c | 1 + > 1 file changed, 1 insertion(+) > > Some non-persistent direct links showing the bug trigger on > different platforms with linux-next 20211109: > - https://intel-gfx-ci.01.org/tree/linux-next/next-20211109/fi-tgl-1115g4/igt@i915_module_load@reload.html > - https://intel-gfx-ci.01.org/tree/linux-next/next-20211109/fi-jsl-1/igt@i915_module_load@reload.html > > Notably with 20211110 linux-next, the bug does not trigger: > - https://intel-gfx-ci.01.org/tree/linux-next/next-20211110/fi-tgl-1115g4/igt@i915_module_load@reload.html Is this the case with CONFIG_DEBUG_KOBJECT_RELEASE? This would be the only logical explanation I can think of for now. In anyway, the code change itself looks good, so I took the fix now. thanks, Takashi