-.\" $OpenBSD: pledge.2,v 1.65 2023/05/19 01:12:23 guenther Exp $
+.\" $OpenBSD: pledge.2,v 1.66 2023/06/02 17:44:29 cheloha Exp $
.\"
.\" Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 19 2023 $
+.Dd $Mdocdate: June 2 2023 $
.Dt PLEDGE 2
.Os
.Sh NAME
.Pa /etc/localtime
and any files below
.Pa /usr/share/zoneinfo .
+.It Xr profil 2 :
+Can only disable profiling.
.It Fn pledge :
Can only reduce permissions for
.Fa promises
.Xr poll 2 ,
.Xr pread 2 ,
.Xr preadv 2 ,
+.Xr profil 2 ,
.Xr pwrite 2 ,
.Xr pwritev 2 ,
.Xr read 2 ,
-/* $OpenBSD: kern_pledge.c,v 1.305 2023/05/19 01:12:23 guenther Exp $ */
+/* $OpenBSD: kern_pledge.c,v 1.306 2023/06/02 17:44:29 cheloha Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
*/
[SYS_sysctl] = PLEDGE_STDIO,
+ /* For moncontrol(3). Only allowed to disable profiling. */
+ [SYS_profil] = PLEDGE_STDIO,
+
/* Support for malloc(3) family of operations */
[SYS_getentropy] = PLEDGE_STDIO,
[SYS_madvise] = PLEDGE_STDIO,
return pledge_fail(p, EPERM, PLEDGE_PROC);
}
+int
+pledge_profil(struct proc *p, u_int scale)
+{
+ if ((p->p_p->ps_flags & PS_PLEDGE) == 0)
+ return 0;
+ if (scale != 0)
+ return pledge_fail(p, EPERM, PLEDGE_STDIO);
+ return 0;
+}
+
int
pledge_protexec(struct proc *p, int prot)
{
-/* $OpenBSD: subr_prof.c,v 1.34 2023/05/30 08:30:01 jsg Exp $ */
+/* $OpenBSD: subr_prof.c,v 1.35 2023/06/02 17:44:29 cheloha Exp $ */
/* $NetBSD: subr_prof.c,v 1.12 1996/04/22 01:38:50 christos Exp $ */
/*-
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/pledge.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/mount.h>
} */ *uap = v;
struct process *pr = p->p_p;
struct uprof *upp;
- int s;
+ int error, s;
+
+ error = pledge_profil(p, SCARG(uap, scale));
+ if (error)
+ return error;
if (SCARG(uap, scale) > (1 << 16))
return (EINVAL);
-/* $OpenBSD: pledge.h,v 1.47 2022/09/01 05:40:46 jsg Exp $ */
+/* $OpenBSD: pledge.h,v 1.48 2023/06/02 17:44:29 cheloha Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
int pledge_fcntl(struct proc *p, int cmd);
int pledge_swapctl(struct proc *p, int cmd);
int pledge_kill(struct proc *p, pid_t pid);
+int pledge_profil(struct proc *, u_int);
int pledge_protexec(struct proc *p, int prot);
#endif /* _KERNEL */