git: 22dd3a0df230 - main - pdgetpid(2): add user_pdgetpid

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Wed, 11 Nov 2026 13:21:00 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=22dd3a0df230da613b0ec173605a1275ebce00fb

commit 22dd3a0df230da613b0ec173605a1275ebce00fb
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-11-24 17:55:08 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-11 13:14:42 +0000

    pdgetpid(2): add user_pdgetpid
    
    Effort:         CHERI upstreaming
    Sponsored by:   Innovate UK
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
---
 sys/kern/sys_procdesc.c | 12 +++++++++---
 sys/sys/syscallsubr.h   |  1 +
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c
index 774774bdf4f0..95ce028c6f15 100644
--- a/sys/kern/sys_procdesc.c
+++ b/sys/kern/sys_procdesc.c
@@ -155,14 +155,20 @@ kern_pdgetpid(struct thread *td, int fd, const cap_rights_t *rightsp,
  */
 int
 sys_pdgetpid(struct thread *td, struct pdgetpid_args *uap)
+{
+	return (user_pdgetpid(td, uap->fd, uap->pidp));
+}
+
+int
+user_pdgetpid(struct thread *td, int fd, pid_t *pidp)
 {
 	pid_t pid;
 	int error;
 
-	AUDIT_ARG_FD(uap->fd);
-	error = kern_pdgetpid(td, uap->fd, &cap_pdgetpid_rights, &pid);
+	AUDIT_ARG_FD(fd);
+	error = kern_pdgetpid(td, fd, &cap_pdgetpid_rights, &pid);
 	if (error == 0)
-		error = copyout(&pid, uap->pidp, sizeof(pid));
+		error = copyout(&pid, pidp, sizeof(pid));
 	return (error);
 }
 
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 084f48f75b26..0068f5c16cbc 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -571,6 +571,7 @@ int	user_jail_get(struct thread *td, struct iovec *iovp,
 int	user_jail_set(struct thread *td, struct iovec *iovp,
 	    unsigned int iovcnt, int flags, copyinuio_t *copyinuio_f);
 int	user_kldload(struct thread *td, const char *file);
+int	user_pdgetpid(struct thread *td, int fd, pid_t *pidp);
 int	user_poll(struct thread *td, struct pollfd *fds, u_int nfds,
 	    int timeout);
 int	user_ppoll(struct thread *td, struct pollfd *fds, u_int nfds,