git: b0ef93ae3f63 - stable/15 - Delete error-check code that can never happen.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Mar 2026 05:42:34 UTC
The branch stable/15 has been updated by mckusick:
URL: https://cgit.FreeBSD.org/src/commit/?id=b0ef93ae3f63a31a493d00a8d9e43b411384ef51
commit b0ef93ae3f63a31a493d00a8d9e43b411384ef51
Author: Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2026-03-19 00:45:23 +0000
Commit: Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2026-03-26 05:42:21 +0000
Delete error-check code that can never happen.
Near the top of kern_mmap() that implements the mmap(2) system call,
it sets
prot = PROT_EXTRACT(prot);
with
So prot can only be the three PROT_ flags.
The following test of the user's mmap(2) parameters (near line 275
in vm/vm_mmap.c):
if (prot != PROT_NONE &&
(prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0) {
return (EXTERROR(EINVAL, "invalid prot %#jx", prot));
}
can never fail. This commit deletes it.
No functional change intended.
Reviewed by: kib
Sponsored by: Netflix
(cherry picked from commit 51446d33c6fbc27ce21f54ebb4c27caace48c3be)
---
sys/vm/vm_mmap.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 234586893b59..cb5906440f56 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -271,10 +271,6 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp)
return (EXTERROR(EINVAL,
"both SHARED and PRIVATE set (flags %#jx)", flags));
}
- if (prot != PROT_NONE &&
- (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0) {
- return (EXTERROR(EINVAL, "invalid prot %#jx", prot));
- }
if ((flags & MAP_GUARD) != 0 && (prot != PROT_NONE || fd != -1 ||
pos != 0 || (flags & ~(MAP_FIXED | MAP_GUARD | MAP_EXCL |
MAP_32BIT | MAP_ALIGNMENT_MASK)) != 0)) {