From nobody Fri Nov 01 14:13:09 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xg2rk2sVfz5bpqT; Fri, 01 Nov 2024 14:13:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xg2rk0zZTz4bjB; Fri, 1 Nov 2024 14:13:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730470390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zSp13p7o3KUxWODNYvOrL75goxH5Fy8LcKIDlIQc3vA=; b=wY9gN9Xy+oc0FPrLjWUYP7nIpfD/uhbogLhZBlWE86b3JKUudXo8zKKIyhCwrokkmquycw nojMZ9x8/P+/3aD+N08aOLvIYL7yfJtlQyjKiwNBSCgAdHrfLppPBDHx0e5EEKo7Q/KQGr 4ARSxIeTzX/E2BmeUocLoNW2vKtb5TxkohpyGSYmV3pConYtdYGgCrX8w5pq1x03LguJnc o4TY2zc5oCyIW5WxFOUD0m+WdGmdh1TbdW9RV+GeEqRtoyEs714Rti+xlzAlNA0H60xFSr LNvquSbIAFicrVtVxLCkgihRDjSjGR3OZ345IHjNUM1s1sDtL4taXJ1aVcCxYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730470390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zSp13p7o3KUxWODNYvOrL75goxH5Fy8LcKIDlIQc3vA=; b=DxrnYVNBtvDoisAV7UVBvmAsPTdqxVmTehTPqLaQ7ipbL261Y1TZwGyavcSGudioAMNww7 ZJZzrEHkwEc91temSXRH4SnYpT7ihL7dLjEWuHvx0RbHmX39bZ/1ChUhvUjkfPr8An5vVD bLD0NvzEE3ZM39jiNxpPAsuzo6d5/mE9RXn0yyc373vDgLCTsr2H8o0bAsnk4QCEKVj31y lBWoE8rMM1lhtBngxznCcNzweonYOEBV/Qdx9amVukhy/ppAFWm/hfYjZerLr1gpkAotwD s1hUN7/egw4pdP8uezZ/80ksiyNDV4niZFsjv0rQ5c9tmOcKD6l/MsZotu6mfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730470390; a=rsa-sha256; cv=none; b=qqWLmLsmFd1W9r2+943VGbaP4vNi0uOW9pNF9fwrfEiFp6nQEcb5vPHc7ce4zOIKneHdOT X2amp0lxG8JwEDPnrQcjvT93Uunsuwln1yJYFHefC8Nlq0uKztXI99KVy7jilcR3TeuW1J bI4qSr5U0bdAJo0sAdpwt3neFikSRgK6e/lgzQPgyzSkO6ALwy6Eq0geSZbWZl4SaTvc0e /PqThWc4MePLo7cyzrsY64j2rGwznIRfHWS1Vte/P/9jW6JVei5AfzxFwd9KpATM5EDtzU 7gDfPGq7MVmOMPpyXFn2l85urYn4jrR2kR3pBNPF7RUqnC+z2NFFrkSSCPftSQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xg2rk0ZpPzNjK; Fri, 1 Nov 2024 14:13:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A1ED9Ad059753; Fri, 1 Nov 2024 14:13:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A1ED9Zk059748; Fri, 1 Nov 2024 14:13:09 GMT (envelope-from git) Date: Fri, 1 Nov 2024 14:13:09 GMT Message-Id: <202411011413.4A1ED9Zk059748@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: dc569c894207 - main - miibus: Use a bus_child_deleted method to free ivars for children List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dc569c894207a524b0cb542040b35b0edd57d1c8 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=dc569c894207a524b0cb542040b35b0edd57d1c8 commit dc569c894207a524b0cb542040b35b0edd57d1c8 Author: John Baldwin AuthorDate: 2024-11-01 14:10:01 +0000 Commit: John Baldwin CommitDate: 2024-11-01 14:10:01 +0000 miibus: Use a bus_child_deleted method to free ivars for children If a device was detached (e.g. via devctl) and then re-attached, the ivars would be freed by the previous bus_child_detached method during detach, but device_get_ivars during the subsequent attach would return a stale pointer resulting in a use after free. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47371 --- sys/dev/mii/mii.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/mii/mii.c b/sys/dev/mii/mii.c index 48bbf0d506ce..dde79c189322 100644 --- a/sys/dev/mii/mii.c +++ b/sys/dev/mii/mii.c @@ -58,7 +58,7 @@ MODULE_VERSION(miibus, 1); #include "miibus_if.h" -static bus_child_detached_t miibus_child_detached; +static bus_child_deleted_t miibus_child_deleted; static bus_child_location_t miibus_child_location; static bus_child_pnpinfo_t miibus_child_pnpinfo; static device_detach_t miibus_detach; @@ -84,7 +84,7 @@ static device_method_t miibus_methods[] = { /* bus interface */ DEVMETHOD(bus_print_child, miibus_print_child), DEVMETHOD(bus_read_ivar, miibus_read_ivar), - DEVMETHOD(bus_child_detached, miibus_child_detached), + DEVMETHOD(bus_child_deleted, miibus_child_deleted), DEVMETHOD(bus_child_pnpinfo, miibus_child_pnpinfo), DEVMETHOD(bus_child_location, miibus_child_location), DEVMETHOD(bus_hinted_child, miibus_hinted_child), @@ -167,7 +167,7 @@ miibus_detach(device_t dev) } static void -miibus_child_detached(device_t dev, device_t child) +miibus_child_deleted(device_t dev, device_t child) { struct mii_attach_args *args;