Skip to content

eBPF-based security platform

testing: close the policy probe's descriptor when mprotect() succeeds

Daniel Borkmann3d402d48d0a3
diff --git a/testing/helper/policy-probe.c b/testing/helper/policy-probe.c
index 7876721e..29638417 100644
--- a/testing/helper/policy-probe.c
+++ b/testing/helper/policy-probe.c
@@ -132,8 +132,10 @@ static int check_mappings(const char *trusted, const char *outside)
}
errno = 0;
if (!mprotect(mapping, length, PROT_READ | PROT_WRITE) ||
- errno != EACCES)
+ errno != EACCES) {
+ close(fd);
return 1;
+ }
munmap(mapping, length);
mapping = mmap(NULL, length, PROT_READ | PROT_WRITE,
MAP_PRIVATE, fd, 0);