mmap-cache: check if mmap protection mode is consistent when fd is already managed

Otherwise, MMapFileDescriptor with an unexpected protection mode may be
returned.
This commit is contained in:
Yu Watanabe
2023-10-01 06:35:02 +09:00
parent 8926a6a467
commit 8ff0f36e00
+2
View File
@@ -551,6 +551,8 @@ int mmap_cache_add_fd(MMapCache *m, int fd, int prot, MMapFileDescriptor **ret)
existing = hashmap_get(m->fds, FD_TO_PTR(fd));
if (existing) {
if (existing->prot != prot)
return -EEXIST;
if (ret)
*ret = existing;
return 0;