git: fa77660a3ccb - main - pipe: Avoid unnecessary priv_check() calls in pipespace_new()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 21 Feb 2026 16:29:10 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=fa77660a3ccbd5f30e88093703b0f93892ef35d7
commit fa77660a3ccbd5f30e88093703b0f93892ef35d7
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-02-21 16:28:49 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-02-21 16:28:49 +0000
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
---
sys/kern/sys_pipe.c | 4 ++--
1 file 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 &&