Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp541961rdb; Mon, 29 Jan 2024 09:50:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrCpPo41r09kESfsrmJWMG0d4KbmVrTY9p8lVyLo4H93j5C01A22Fz1sdIXKke7GlmOTwh X-Received: by 2002:a17:902:cec1:b0:1d7:2fa6:bfc2 with SMTP id d1-20020a170902cec100b001d72fa6bfc2mr10388473plg.60.1706550599879; Mon, 29 Jan 2024 09:49:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706550599; cv=pass; d=google.com; s=arc-20160816; b=lA+RNbtxNbRWJfw6jU/8b13s8F3VnOn8A6AF9YgMvtIYUFvr5a2BecPzN2XJ3brKBO eapflVUMWqgPDgiJIZw29tPvtglvRLb9HpOovAkDdELVey2kvbZWFKgcMQ4TaxaaNn8K Ye7rFLeclJxyZGDvtEh1jMIXkDZllhtGdFQqw3ZtJQRzW3mGnxQXyGpXsmSw5AWHX4P3 SnlFFXSQvV+xDAKKJAdRd27NtPlKmErV7HFuBeT3ptAPPAsraTndz9SGvm8HMDoBwC4D SQUH7HiAxkJaBR1HWkb/LFn2NVe4Myk1l4mBDVhEl8e0kw+5i05LiIXJp6i7CHV8FgI7 +67w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=tdBQCntCln6YjRTWw9J7laZp2yLZK0JmRkee2IDva5c=; fh=MrQVr/8azffKf3JGcuirwjG36SmazQMHJiu+bogtt/E=; b=jyVoyOEA2/5uxW9qjpYlbAh2kQbDEOumdMxIpTh+/E9fql3c/RMsA4yyZoOza+G1lD hiaofw8l4fYEX+mEnyotb3DS9iofp22lOaCFH8e2XBTd8uzC+z8njVU/soPAq1K3q71d 6zMXrxUhZ3Dx7mLGAL/GJa4+bHTIJ0NqtxRFj71n/5i4ZIydpGWN/SDvjXCedas8L1dv XKxSBijhmzYgcofIUN43oKrYF8/QtwHcq/eSRfswSP/sZNorqCHn7yyCC5NAbTYP9aZL zw1jX8exgprlNNNrQ8YPi30BWXhy/VP1mn7nBDg9IPYKkfrtmeowGTtt/2Tzx2usvjoF MUWw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=AgG6AqIp; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-kernel+bounces-43236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d11-20020a170902cecb00b001d767df9dd9si6180226plg.333.2024.01.29.09.49.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:49:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=AgG6AqIp; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-kernel+bounces-43236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9D210289AB0 for ; Mon, 29 Jan 2024 17:49:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 829473F9D8; Mon, 29 Jan 2024 17:48:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="AgG6AqIp" Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5599976C8D for ; Mon, 29 Jan 2024 17:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706550500; cv=none; b=jkUZ/392wyi0WscgCzIDhYvuHgk83viKt3joO0PNI6HKf7t511tIDkgIQkFfxJGWRJjubYZ/EyH6prUIyrNZX4gD58Dzcuf4Om9/8J3BqcCfpY4y42WisGvcOoWB/k6LUeTpdeidyNufw+vy75fcZcmjVDr0sFLufauaA1cJexQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706550500; c=relaxed/simple; bh=1OKdWWjsPuvXhemAMkjEw2hVw/EmzYYEOFN9BXfMKek=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=HI8uZ+m1eL2G42CyrITAKfj8+bgW/q2HIqSFXWhzbO9Vuxmn0GRdoaF6mGM1Kc0fwf7JThWnWv6h3VDjimoSdKPIO73QVKz3AJDrmLO/17sfPViNNv8/RgsDN3Rgv7R4M5/n7CKtvTCZXG9uGVvt6xYMBKym2Cw3D5xCqcpOQcU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=AgG6AqIp; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=tdBQCntCln6YjRTWw9J7laZp2yLZK0JmRkee2IDva5c=; t=1706550498; x=1707760098; b=AgG6AqIpvjZwER7KBEdt29px52ZsMdt2536oSRPKJkjTXcU LMw9ngBsApOoOcWGOIiIn4dJrMhlhgSxpEbbD133zmdi4GF6DwRj0fvkRH0BlThtsMvD102qntAmn 6UiPUyR9Cvh3HYSBkHuRxIDbaYdXPR7KrVQIgYk4u4nxnSjamHj592uxs6P24Ptb/yWygdWD9mIZE 7Ra0ahmF038h/BFDKRf/wj7WcjGP6GNxc8mtYWzO0dYv8LatGMw3vKeJLpyzgFhwayIY3fB6CjqHj sTa+tbODMfhfN152vRMUB3zHrAd1uEUJ97ce9ibOvv7Bcs9uO+oAcDmeBuFEHf5Q==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rUVjx-00000004xoN-2z6f; Mon, 29 Jan 2024 18:48:13 +0100 Message-ID: Subject: Re: [PATCH 1/2] devcoredump: Remove devcoredump device if failing device is gone From: Johannes Berg To: Rodrigo Vivi , linux-kernel@vger.kernel.org Cc: Jose Souza , Maarten Lankhorst , Greg Kroah-Hartman , "Rafael J . Wysocki" Date: Mon, 29 Jan 2024 18:48:12 +0100 In-Reply-To: <20240126151121.1076079-1-rodrigo.vivi@intel.com> References: <20240126151121.1076079-1-rodrigo.vivi@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.3 (3.50.3-1.fc39) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-malware-bazaar: not-scanned On Fri, 2024-01-26 at 10:11 -0500, Rodrigo Vivi wrote: > Make dev_coredumpm a real device managed helper, that not only > frees the device after a scheduled delay (DEVCD_TIMEOUT), but > also when the failing/crashed device is gone. >=20 > The module remove for the drivers using devcoredump are currently > broken if attempted between the crash and the DEVCD_TIMEOUT, since > the symbolic sysfs link won't be deleted. Hmm, is it a problem to remove a whole dev when it still has some link here? Maybe we could just make the link be managed/auto-removed? Probably regardless of that you should change the comment in devcd_dev_release() since it's no longer a concern? > On top of that, for PCI devices, the unbind of the device will > call the pci .remove void function, that cannot fail. At that > time, our device is pretty much gone, but the read and free > functions are alive trough the devcoredump device and they ^ through, I guess > can get some NULL dereferences or use after free. Not sure I understand this part, how's this related to PCI's .remove? > So, if the failing-device is gone let's also request for the > devcoredump-device removal using the same mod_delayed_work > as when writing anything through data. The flush cannot be > used since it is synchronous and the devcd would be surely > gone right before the mutex_unlock on the next line. Can we just decouple it instead and remove the symlink? Which is kind of what the comment in devcd_dev_release() says but at the time I wasn't aware of all the devm mechanics etc. I'm thinking this might be annoying in certain recovery cases, e.g. iwlwifi uses this but may sometimes unbind/rebind itself to recover from certain errors, and that'd make the FW dumps disappear. johannes