git: 51446d33c6fb - main - Delete error-check code that can never happen.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 19 Mar 2026 00:47:26 UTC
The branch main has been updated by mckusick:
URL: https://cgit.FreeBSD.org/src/commit/?id=51446d33c6fbc27ce21f54ebb4c27caace48c3be
commit 51446d33c6fbc27ce21f54ebb4c27caace48c3be
Author: Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2026-03-19 00:45:23 +0000
Commit: Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2026-03-19 00:45:23 +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
MFC-after: 1 week
Sponsored by: Netflix
---
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)) {