From nobody Mon Oct 07 00:16:13 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 4XMKSZ2Fnqz5Yks9; Mon, 07 Oct 2024 00:16:14 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XMKSZ1J3Wz4Hwl; Mon, 7 Oct 2024 00:16:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728260174; 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=wyRFxUccHMmfpIxjuhdNjEIcT8Q64KxugvJpHwgVFR8=; b=u6F6sn4dlBNDGyUD65wdMvzPCBCZ8wIA5Cnj+UdLuCCxrLPiyqHp0jZo1WNrBjW7A+ASQd hAGrqA7loApt7XtzNlQAtL6zXvDmSjK37vs0sEmyZBzokwYojOO9N+uiI6TPVkhkIyjCbx XkTQKNBb8aVzPi79Vats48ASMfCMzj8HCinj0NESh8XC5Ue9/R2G34Yj+Oj/D+w2KFE99c 9VXje3C7v9xrKayRs+VCGE9iR9rSWdb66QUiie3z1AXZYWsoLYcwU4pkOetXwpGRSBSvDd ULRy0b6vltdrrZ9qr7uGN9Plg5UX8/XYvRfMlFelB5a17xfRcsKUgJ779DTqUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728260174; 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=wyRFxUccHMmfpIxjuhdNjEIcT8Q64KxugvJpHwgVFR8=; b=qkjQNAdxXxzhtUbIe8/knUg90YilBV4tX1+Zm9PWyOuV+CFh+PjefeflpmOyxBVUQjs5bs gc59sxpJfg9+PmpuBRoDqVnnyef1RX304PvlvcnJf8e/sQc1z5F8XExHQv/oigLvV+qbR0 GD5GGqGQVqzfqcUbcuF1H5PEj95iJjeJla26BMt3buuublL1SrVdFlMwVBGTe+qfg3NugD 3PwgBBcEqgg2zpfOw04Zz2FqRMcncpYSnHyyV+srl8wOgVoHUDbzcX4wX5YV3lhl6RwvwJ si7i/WyK+7146ZMRG0QeaDg5tCot0LkxETPnkwikJRLogHSOU1CUO3glibEfoA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728260174; a=rsa-sha256; cv=none; b=irwgXRMCtOQPcESbDCrvO/yRAsLs5ac0eYd8uNjw44u7gdhfiSiM2q8vxMipcBYh9NiXnB JcOepSdp5SOHDqYfqwuF0715fG5hLDxOB6a6+C+7yUSgJpl9/7DKvHO3Mk21XXKhi27iEf bG6cz6bcuYrepKu0GSP3AGYLAVej8XXDyeSLOn5O8emQ324jbOveWQy2V9cbmuudmcu1n9 sduu1c30o7KWTiABhwuVl8K9c85FPp2AddvwPg5kvpOWo9RUHAkopHAcDCQuFhdrSegMut uX3BFxVzxCYT8ynimJRlI/WtzGdXWc78LNLBDPQRNbIobvyZho2fa39rq+v+/g== 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 4XMKSZ077CzPJ0; Mon, 7 Oct 2024 00:16:14 +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 4970GDLf080351; Mon, 7 Oct 2024 00:16:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4970GDe1080348; Mon, 7 Oct 2024 00:16:13 GMT (envelope-from git) Date: Mon, 7 Oct 2024 00:16:13 GMT Message-Id: <202410070016.4970GDe1080348@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: fdd100a7150e - main - devctl: Add missing validation to DEV_RESET 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fdd100a7150e34d8d98cb38e701b3cb073208653 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fdd100a7150e34d8d98cb38e701b3cb073208653 commit fdd100a7150e34d8d98cb38e701b3cb073208653 Author: Mark Johnston AuthorDate: 2024-10-06 22:56:40 +0000 Commit: Mark Johnston CommitDate: 2024-10-07 00:16:07 +0000 devctl: Add missing validation to DEV_RESET As in other ioctls which access the parent bus, we need to check for a NULL parent here. Otherwise it's possible to trigger a null pointer dereference by resetting the root device. Reported by: Elliott Mitchell Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D46965 --- sys/kern/subr_bus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 7fe46995ee54..d0c41b59dbb6 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -5859,6 +5859,10 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, error = EINVAL; break; } + if (device_get_parent(dev) == NULL) { + error = EINVAL; + break; + } error = BUS_RESET_CHILD(device_get_parent(dev), dev, req->dr_flags); break;