Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp651691rdb; Mon, 29 Jan 2024 13:51:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8+n2Jxst34OA2nmvv8taGy2K3oeZUEMeSvJJez1MRMD0HJJ/p5LbD8LL6LazSL3AJ6DAd X-Received: by 2002:a2e:be8a:0:b0:2cf:4b50:2955 with SMTP id a10-20020a2ebe8a000000b002cf4b502955mr5191146ljr.8.1706565114040; Mon, 29 Jan 2024 13:51:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706565114; cv=pass; d=google.com; s=arc-20160816; b=zsTIqf4NDuErJuzd8btEw80azyvy42xC48951FWBnByA+ubB6j3mIohJ4jtMWvSzX2 U5VjZ2isOA84+tZxX+u/CEbvQ91b6odxgdJ+TV5TlbTBlhUgJBypZtbl/BhS4bl0CbIL JRRNGv+L/hP0g6OvoxXHZ11XJ00mtoP35R6CiWYinUZ0NGhDDihOf0FvRlAMwd5aEV/j 8poWoxhVsvDUjlNqdJE1LGukkVrm7VOdzSymHFNTskTdZFrcrqbLqbkmju+Kk0JvpLeD Dkb20bKzyr/Tkaj0lZ3wQGaQIOmQXcihNTqKVcq/P+GHA0ts+mRqC/Lg7UkcVHwJBayT 4tuw== 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=Tfd5xTsJcQukGIPq2o4aDW4fPhnhHq2OexIddMEq6LQ=; fh=eX1JzOzOHKK2qBkgL2HE21LbusAYvH5qaOoHI8fEg1E=; b=Qbb/8Spb7KhCMFdJR9KS+ZrDLtOmggeKhWwLvHUvc+qwOI8Z2yVc9jyK8T4/YABh2m tDwfgsth2IZWcVYfUwpE4l67AEh7Xs3bwf/8O8kvxgdkOLB3Fu+laR3Er+70zprDtAWG Nj2bKLim1mZU91Fnb/RuVl4Pw4nOTa1UvjVRzdcepHgbkQyPgxodk471Ec8lnXAnfHSN iGhWunUKN66DqZfZVxxICrOGIRU+LeUVH5l4/HE8muK9PCTEyenDHSghxbD2hKBEOJDJ JRuw27AfbhVOf3pjOSab7s5wNEItdpXkCP+J/AJvN+porbQ7lAkEePSzISdmMvpf04W2 tRnQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=fVcN8qVi; 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-43536-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43536-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cn2-20020a0564020ca200b0055f0cd6afcesi1047093edb.642.2024.01.29.13.51.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 13:51:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43536-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=fVcN8qVi; 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-43536-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43536-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C4F8B1F22490 for ; Mon, 29 Jan 2024 21:51:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA008158D89; Mon, 29 Jan 2024 21:51:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="fVcN8qVi" 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 B91AE657C7 for ; Mon, 29 Jan 2024 21:51:43 +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=1706565106; cv=none; b=fTTpvjYzXzwi+jR6YSU1WDp7XDznBZkoPeTIkgCdGaJ/eEQ90oQ031dw7bQg45Ru5zSlAjXh3GcHqR1o48+8puZu7F+t+u/qp7cCzkj51hIH4TCwYRQdxatStfuVk6OwlkRCeyJTM4qx4SG2TKdWIx/2P3YlcMcM3z9nGi96Hx4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706565106; c=relaxed/simple; bh=fckrnZTsRJZ5DuCkaRp8IJe1DM/0YVZkOrx9pNArYXk=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=IBRLYfbqtz8Bo9Bx2F53tJYa/szz6qHXJvdu8JhZKCTjmGsnZh+b0skQIzhM5P//zOZDYwor/zCK10Cv8+9e8YQEvWT+sn0C0Qwst2j4WYXmIlDFchTiDlnvXg7AGyiytmEPX2dmfwoqIvCuf0sTTzH+iLQ2A9GZBponT6RZ7OI= 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=fVcN8qVi; 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=Tfd5xTsJcQukGIPq2o4aDW4fPhnhHq2OexIddMEq6LQ=; t=1706565103; x=1707774703; b=fVcN8qViaQNRsVmJXSmhDGdjaR3JjqV/2a0yRg85v/C1KXA l80SFm4Xm8qN/zFr+tN5h6+hB00DbYj/ijQaX+16aKcX2i8vdeZUh/s93KI0DQXZxwJKfEu5+tfFg SQk655X4EEsBQ8KThIbmoaINsHPg6S5hAn77jmhmk6AeoyJu6TM5WxXN9xegRnNcB9dh9r2ra1g75 g0FHDEt7zywCBfoSB3K5p9YK5TRctqEwWZe3VkBr4tC0XOE/RCoOXLOU9WVkYTcvZENDNarfuFvMp 0v8U2pQElDE12pDfZeh8+SQX6D28/fgNl9CVxt9axNjdnqMWnzSMtA1grDIcGX2A==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rUZXY-000000054r7-1INa; Mon, 29 Jan 2024 22:51:40 +0100 Message-ID: <33df6c78c4c47a8f57a1c2bfe835065becb5a253.camel@sipsolutions.net> Subject: Re: [PATCH 1/2] devcoredump: Remove devcoredump device if failing device is gone From: Johannes Berg To: Rodrigo Vivi Cc: linux-kernel@vger.kernel.org, Jose Souza , Maarten Lankhorst , Greg Kroah-Hartman , "Rafael J . Wysocki" Date: Mon, 29 Jan 2024 22:51:39 +0100 In-Reply-To: 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 Mon, 2024-01-29 at 16:29 -0500, Rodrigo Vivi wrote: > >=20 > > > 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 > >=20 > > > can get some NULL dereferences or use after free. > >=20 > > Not sure I understand this part, how's this related to PCI's .remove? >=20 > Well, this is my secondary concern that the idea of the link_auto_removal > doesn't cover. >=20 > If the failing_device is gone, the 'data cookie' it used to register with > dev_coredumpm(... void *data,...), is also likely gone on a clean removal= . That's on the user. You'll always be able to shoot yourself in the foot. > And to be honest, we shouldn't even count that the registered *read() > function pointer is valid anymore. That's not true: the module cannot be removed, there's a reference to it if you're using dev_coredumpm() correctly (which is to say: pass THIS_MODULE to the struct module *owner argument). > Well, we could indeed. And that would unblock our CI, but I'm afraid > it wouldn't protect the final user from bad memory access on a direct > $ cat /sys/class/devcoredump/devcd/data >=20 > Shouldn't we consider this critical itself to justify this entirely > removal? No? IMHO that's totally on the user. If you absolutely cannot make a standalone dump 'data' pointer (why not?! you can always stick the actual data into a vmalloc chunk and use dev_coredumpv()?) then maybe we can offer ways of removing it when you need to? But I'd rather not, it feels weird to have a need for it. johannes