From nobody Mon Feb 14 20:29:32 2022 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 D34AF194B58F; Mon, 14 Feb 2022 20:29:32 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JyG6N5Xb1z4hvC; Mon, 14 Feb 2022 20:29:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644870572; 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=SSIlprafSCEiJ1oEssINUQ/heuNp4MUMog3qHKEN4FA=; b=ozD96IViSYaA5efUIj/2Gsscd9Lk04dVey5neu/HTgCaOjwf9Zx0mwaZ4EZyP+GDDMOMGM QXz+KTsVyKKltro7f51yxjxF5cHHNfmNCZyuqvYQHnvPXL11dhnfTGnCrCR8CVr8FEqOl0 rWyHPzNS28tW7gewxchv9h9ovAljHay+K7L3BMx3Xe+PG+tRRk43lXFHUexV0G3tYE8dYQ MjtfCMLKMX13OaarP6xZrFxRtAQEKSU192jqEL+G4cXAE9J+6uOaNrEI3wQlVYnn+NxLUH M99zhbPQ+bjkkuUsKF4EzBIycryUSt3Q/tg4H/vbj+SOknOo0spiFJYJf46IKQ== 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 9F6BA1569F; Mon, 14 Feb 2022 20:29:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21EKTWZS090644; Mon, 14 Feb 2022 20:29:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21EKTW6D090643; Mon, 14 Feb 2022 20:29:32 GMT (envelope-from git) Date: Mon, 14 Feb 2022 20:29:32 GMT Message-Id: <202202142029.21EKTW6D090643@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: b6f04039d96c - stable/12 - procctl(2): add consistent shortcut P_ID:0 as curproc 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: b6f04039d96c24d37c87e5e8f84c13521f9b6b8e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644870572; 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=SSIlprafSCEiJ1oEssINUQ/heuNp4MUMog3qHKEN4FA=; b=uDgKYt+ibcc0kFZwCiht0lDED4HeMjdfIB3K2gbKm7pSng2WYyy03mtSsQvM2EyLxhPoCU FKrdMm4sPCaa8DtKDRmUQY9NnRsSWRHURu60D7yNxi1kOnLDA9je2vBh3gHhUUNtIZdDZJ 5ZUN8NcQ6Wtfdea5hNJhx5b0mVkwG6QzX+z9SBrUiTAA3Ak+PBCRdIu0+3QrGPWgkGcS22 iYxgk19eV9VfRBQhBGICIIzZWTQJUga1rrOv04RzLKjZ996a0ZVOQL9zLpjkT/qglsc92Y msm510WRUSlWSGs/oz5IZc1CisFv40Art6wTy0HzPVmf75AnV8Tox7AEdhXwEw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644870572; a=rsa-sha256; cv=none; b=A20IYUVZmGbw0SGyPrCK7rqF+JExlQ8UYlWoedMab7Ve39VT6cyWaGbtvzgNjOipep+Dkh 04vCXcfjOoPpC7p06ab5MIel+dLLkdf9fmR0f4UcvzjWS8++5RlRdJbAGSQwlItqiDD/gY /i8/UxXQanci2FW0o8OL2N7lJgcc0ukhNk08U4mrXXkRvA51lGOyPT1ChlFpk7dty7HeLE c6VIZBxBAHuNZJTvvtpQtSvq+3NMzAPhi7TxNSkV/oRpWjVkvETTrq6S7Tq/rZVYr4HQsw N1nkd1RTon9xinGcmQdwZ01prYycRjP/4iJzRa58Nq3CMT2acP6M87yt+dUxqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=b6f04039d96c24d37c87e5e8f84c13521f9b6b8e commit b6f04039d96c24d37c87e5e8f84c13521f9b6b8e Author: Konstantin Belousov AuthorDate: 2021-10-15 19:01:42 +0000 Commit: Ed Maste CommitDate: 2022-02-14 20:26:47 +0000 procctl(2): add consistent shortcut P_ID:0 as curproc (cherry picked from commit f833ab9dd187328306fa1601330fbc8332392abe) (cherry picked from commit 2e69ba48b97dffa244a4d2d47382b6fbcf6e78f4) --- lib/libc/sys/procctl.2 | 2 ++ sys/kern/kern_procctl.c | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/libc/sys/procctl.2 b/lib/libc/sys/procctl.2 index 80408b73d616..18d3273bfbd6 100644 --- a/lib/libc/sys/procctl.2 +++ b/lib/libc/sys/procctl.2 @@ -62,6 +62,8 @@ The following identifier types are supported: .It Dv P_PID Control the process with the process ID .Fa id . +.Fa id +zero is a shortcut for the calling process ID. .It Dv P_PGID Control processes belonging to the process group with the ID .Fa id . diff --git a/sys/kern/kern_procctl.c b/sys/kern/kern_procctl.c index c87f2bd060ca..b4bbfce9349c 100644 --- a/sys/kern/kern_procctl.c +++ b/sys/kern/kern_procctl.c @@ -740,12 +740,18 @@ kern_procctl(struct thread *td, idtype_t idtype, id_t id, int com, void *data) switch (idtype) { case P_PID: - p = pfind(id); - if (p == NULL) { - error = ESRCH; - break; + if (id == 0) { + p = td->td_proc; + error = 0; + PROC_LOCK(p); + } else { + p = pfind(id); + if (p == NULL) { + error = ESRCH; + break; + } + error = p_cansee(td, p); } - error = p_cansee(td, p); if (error == 0) error = kern_procctl_single(td, p, com, data); PROC_UNLOCK(p);