From nobody Fri Feb 25 07:06:48 2022 X-Original-To: bugs@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 D127B19E41B4 for ; Fri, 25 Feb 2022 07:06:49 +0000 (UTC) (envelope-from bugzilla-noreply@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K4gn5186zz4Wpb for ; Fri, 25 Feb 2022 07:06:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 EA0871B605 for ; Fri, 25 Feb 2022 07:06:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 21P76mSE097400 for ; Fri, 25 Feb 2022 07:06:48 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 21P76mos097399 for bugs@FreeBSD.org; Fri, 25 Feb 2022 07:06:48 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 262186] cpu_procctl() should check target process debug permission for some commands? Date: Fri, 25 Feb 2022 07:06:48 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: sigsys@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645772809; 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=rOlMHDcyTtWuLFyoMtBxjyMPIStxNyyc1m6pl8ilq3s=; b=n1C8LvHZoetR1tCGc7dPpPD7XESRQX7jsGM14ZPpKK5KTyrV6IWYRVJdu3tjZdzBDgPlV5 WC4N6LQoNFzPyT68LS/UbkC4i8HmHysey9bEk5d4KvjyQIyisaOMmWB9IWtS2tPraueVnF 1/myPm9zzVcNqDQtALnNevHKIexYWsxYh/dlUi/Q/WI8cuoXztKbB//67+ctPBZ06yvAzH UB2yJdrpqowMdzI7CfjxN3gxYZ8xIJ40cg//XxoUGBk0RDFCq7bNoTUGOoVmzO5x8mBJ06 HLvPW4kmLMs3GPX3QW/707QWKx1zS9GPIC8vhGdp8NGSRJ5Lg6GT0O2MJ2EYsQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645772809; a=rsa-sha256; cv=none; b=A0+qJ5CpOEf4Qigk40hQWiqwP8CnII8CUsDD78h5NfaZ/bM1xn5mi9xDxCgo5QhkBMYkR9 mdElpA2vsQanFOK42FyFENnnJFs+O3dzQrn102db/Qv/M7mKez8sv7RgfBPMCfUwJTKjdV W8jRlaCfx3KIYCvi35b+0B5/ZQKaFxPnboK7GPpZomTk4s83yIHAL6r0259Q7RmNsdV0MK i2bpkBe5/tKHHBm044cFhwIvrjhx0MMhGuarp88yITL0afZ0cC37Z+f6XxrB+3paoRoAdE xz6WbEEN6fXQZ3z/0w8NM+0sRhQQATIJQeED7w3Fg9N421EGBiAUx7f0OqitQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D262186 Bug ID: 262186 Summary: cpu_procctl() should check target process debug permission for some commands? Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: sigsys@gmail.com kern_procctl() generally checks it for commands that change something, but = when it passes the command to cpu_procctl() there's no check. diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 232e53c63952..8a336ad70fcb 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -490,6 +490,7 @@ cpu_procctl(struct thread *td, int idtype, id_t id, int com, void *data) { struct proc *p; int error, val; + bool need_candebug; switch (com) { case PROC_KPTI_CTL: @@ -507,10 +508,12 @@ cpu_procctl(struct thread *td, int idtype, id_t id, i= nt com, void *data) break; } if (com =3D=3D PROC_KPTI_CTL || com =3D=3D PROC_LA_CTL) { + need_candebug =3D true; error =3D copyin(data, &val, sizeof(val)); if (error !=3D 0) break; - } + } else + need_candebug =3D false; if (com =3D=3D PROC_KPTI_CTL && val !=3D PROC_KPTI_CTL_ENABLE_ON_EXEC && val !=3D PROC_KPTI_CTL_DISABLE_ON_EXEC) { @@ -524,7 +527,8 @@ cpu_procctl(struct thread *td, int idtype, id_t id, int com, void *data) error =3D EINVAL; break; } - error =3D pget(id, PGET_CANSEE | PGET_NOTWEXIT | PGET_NOTID= , &p); + error =3D pget(id, (need_candebug ? PGET_CANDEBUG : PGET_CA= NSEE) | + PGET_NOTWEXIT | PGET_NOTID, &p); if (error !=3D 0) break; switch (com) { --=20 You are receiving this mail because: You are the assignee for the bug.=