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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user