Bug 80185 - Please do not hardcode SELinux identifiers in the code
Summary: Please do not hardcode SELinux identifiers in the code
Status: RESOLVED WONTFIX
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: 10.2
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-18 12:26 UTC by Laurent Bigonville
Modified: 2018-09-06 02:35 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Laurent Bigonville 2014-06-18 12:26:24 UTC
Hello,

Currently the mesa code is checking for SELinux booleans ("allow_execmem") to check whether SELinux will allow mapped memory to be executed and otherwise turns the function in a noop.

Hardcoding such booleans (and other identifiers) is probably a bad habit, since custom policies might be written and may perfectly omit these identifiers. Fedora policy for example doesn't have this boolean anymore.

You should probably to try to mmap() in all cases and react accordingly in case of failure when SELinux is enabled (by checking errno maybe?)
Comment 1 Laurent Bigonville 2014-06-18 12:27:26 UTC
An other question might also arise is why
Comment 2 Laurent Bigonville 2014-06-18 12:30:49 UTC
An other question might also arise is why would a failure of the mmap() function considered as an error in one case and not in the case where SELinux would prevent it to succeed?
Comment 3 rhatdan 2014-06-18 12:32:05 UTC
In Fedora the allow_exemem boolean is not set, and this boolean would only effect user space.

getsebool -a | grep execmem
boinc_execmem --> on
cluster_use_execmem --> off
cups_execmem --> off
deny_execmem --> off
httpd_execmem --> off
virt_use_execmem --> off
xserver_execmem --> off

Currently we add booleans for confined services if we see them as necessary.

It would be better if your code just checked if you got EPERM or EACCESS  for errno, and then if you want check if SELInux is enabled and continue with no error.  Especially since you code works fine without WRITEABLE/EXECUTABLE memory.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.