aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-02-21 16:28:49 +0000
committerMark Johnston <markj@FreeBSD.org>2026-02-21 16:28:49 +0000
commitfa77660a3ccbd5f30e88093703b0f93892ef35d7 (patch)
tree66cd3497996a03a21247f6391143c3cac7941edf
parent0fa6ce255661acc984a45deaf2d710149b957ce6 (diff)
pipe: Avoid unnecessary priv_check() calls in pipespace_new()
Running out of pipe map KVA is a rare case, so reorder checks accordingly, presuming that calling priv_check() is more expensive than the calculation. In particular, priv_check() might not be cheap to evaluate if MAC hooks are installed. Reviewed by: olce, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D55378
-rw-r--r--sys/kern/sys_pipe.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 6531cea31423..e928de1cd776 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -592,8 +592,8 @@ retry:
}
vm_map_lock(pipe_map);
- if (priv_check(curthread, PRIV_PIPEBUF) != 0 && maxpipekva / 100 *
- (100 - pipebuf_reserv) < amountpipekva + size) {
+ if (maxpipekva / 100 * (100 - pipebuf_reserv) < amountpipekva + size &&
+ priv_check(curthread, PRIV_PIPEBUF) != 0) {
vm_map_unlock(pipe_map);
chgpipecnt(cpipe->pipe_pair->pp_owner->cr_ruidinfo, -size, 0);
if (cpipe->pipe_buffer.buffer == NULL &&