ima_mmap_file returning 0 to userspace as mmap result.
I just noticed that trinity was freaking out in places when mmap was returning zero. This surprised me, because I had the mmap_min_addr sysctl set to 64k, so it wasn't a MAP_FIXED mapping that did it.
There's no mention of this return value in the man page, so I dug into the kernel code, and it appears that we do..
sys_mmapvm_mmap_pgoffsecurity_mmap_fileima_file_mmap <- returns 0 if not PROT_EXEC
and then the 0 gets propagated up as a retval all the way to userspace.
It smells to me like we might be violating a standard or two here, and instead of 0 ima should be returning -Esomething
thoughts?
Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 12 lines · Dave Jones
I just noticed that trinity was freaking out in places when mmap was returning zero. This surprised me, because I had the
mmap_min_addrsysctl set to 64k, so it wasn't aMAP_FIXEDmapping that did it.There's no mention of this return value in the man page, so I dug into the kernel code, and it appears that we do..
sys_mmapvm_mmap_pgoffsecurity_mmap_fileima_file_mmap<- returns 0 if notPROT_EXEC
Quoted 6 lines
and then the 0 gets propagated up as a retval all the way to userspace.
It smells to me like we might be violating a standard or two here, and instead of 0 ima should be returning -Esomething
thoughts?
Seems like either EACCESS or ENOTSUP is appropriate; here's the pieces from POSIX:
EACCES The fildes argument is not open for read, regardless of
the protection specified, or fildes is not open for write and PROT_WRITE was specified for a MAP_SHARED type mapping.
ENOTSUP
The implementation does not support the combination of accesses requested in the prot argument.
ENOTSUP seems to be more appropriate in my reading of the above, though I'd somehow more have expected EACCES.
Cheers,
Michael
Signature · 9 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 28 lines · Michael Kerrisk (man-pages)
Quoted 12 lines · Dave Jones
I just noticed that trinity was freaking out in places when mmap was returning zero. This surprised me, because I had the
mmap_min_addrsysctl set to 64k, so it wasn't aMAP_FIXEDmapping that did it.There's no mention of this return value in the man page, so I dug into the kernel code, and it appears that we do..
sys_mmapvm_mmap_pgoffsecurity_mmap_fileima_file_mmap<- returns 0 if notPROT_EXECQuoted 6 lines
and then the 0 gets propagated up as a retval all the way to userspace.
It smells to me like we might be violating a standard or two here, and instead of 0 ima should be returning -Esomething
thoughts?
Seems like either EACCESS or ENOTSUP is appropriate; here's the pieces from POSIX:
EACCES The fildes argument is not open for read, regardless of
the protection specified, or fildes is not open for write andPROT_WRITEwas specified for aMAP_SHAREDtype mapping.
Quoted 6 lines
ENOTSUP
The implementation does not support the combination of accesses requested in the prot argument.ENOTSUP seems to be more appropriate in my reading of the above, though I'd somehow more have expected EACCES.
I just realised that this affects even kernels with CONFIG_IMA unset, because there we just do 'return 0' unconditionally.
Also, it appears that kernels with CONFIG_SECURITY unset will also return a zero for the same reason.
This is kind of a mess, and has been that way for a long time. Fixing this will require user-visible breakage, but in this case I think it's justified as there's no way an app can do the right thing if it gets a 0 back. Linus ?
Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 14 lines · Dave Jones
Quoted 13 lines · Michael Kerrisk (man-pages)
Quoted 12 lines · Dave Jones
I just noticed that trinity was freaking out in places when mmap was returning zero. This surprised me, because I had the
mmap_min_addrsysctl set to 64k, so it wasn't aMAP_FIXEDmapping that did it.There's no mention of this return value in the man page, so I dug into the kernel code, and it appears that we do..
sys_mmapvm_mmap_pgoffsecurity_mmap_fileima_file_mmap<- returns 0 if notPROT_EXEC
Quoted 7 lines
Quoted 1 line
Quoted 1 line
and then the 0 gets propagated up as a retval all the way to userspace.
I just realised that this affects even kernels with
CONFIG_IMAunset, because there we just do 'return 0' unconditionally.Also, it appears that kernels with
CONFIG_SECURITYunset will also return a zero for the same reason.
Hang on, I was misreading that whole security_mmap_file ret handling code. There's something else at work here. I'll dig and get a reproducer.
Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 17 lines · Dave Jones
Quoted 16 lines · Dave Jones
Quoted 14 lines · Michael Kerrisk (man-pages)
Quoted 13 lines · Dave Jones
I just noticed that trinity was freaking out in places when mmap was returning zero. This surprised me, because I had the
mmap_min_addrsysctl set to 64k, so it wasn't aMAP_FIXEDmapping that did it.There's no mention of this return value in the man page, so I dug into the kernel code, and it appears that we do..
sys_mmapvm_mmap_pgoffsecurity_mmap_fileima_file_mmap<- returns 0 if notPROT_EXECand then the 0 gets propagated up as a retval all the way to userspace.
Quoted 8 lines
Quoted 5 lines
I just realised that this affects even kernels with
CONFIG_IMAunset, because there we just do 'return 0' unconditionally.Also, it appears that kernels with
CONFIG_SECURITYunset will also return a zero for the same reason.Hang on, I was misreading that whole
security_mmap_fileret handling code. There's something else at work here. I'll dig and get a reproducer.
According to security.h, it should return 0 if permission is granted. If IMA is not enabled, it should also return 0. What exactly is the problem?
thanks,
Mimi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 16 lines · Mimi Zohar
Quoted 16 lines
Quoted 15 lines
Quoted 9 lines
Quoted 9 lines
There's no mention of this return value in the man page, so I dug into the kernel code, and it appears that we do..
sys_mmapvm_mmap_pgoffsecurity_mmap_fileima_file_mmap<- returns 0 if notPROT_EXECand then the 0 gets propagated up as a retval all the way to userspace.
I just realised that this affects even kernels with
CONFIG_IMAunset, because there we just do 'return 0' unconditionally.Also, it appears that kernels with
CONFIG_SECURITYunset will also return a zero for the same reason.
Quoted 6 lines
Quoted 2 lines
Hang on, I was misreading that whole
security_mmap_fileret handling code. There's something else at work here. I'll dig and get a reproducer.According to
security.h, it should return 0 if permission is granted. If IMA is not enabled, it should also return 0. What exactly is the problem?
Still digging. I managed to get this to reproduce constantly last night, but no luck today. From re-reading the code though, I think IMA/lsm isn't the problem.
Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>