Skip to contentSkip to conversation

Why does SELinux treat access(file, W_OK) the same way as write(fd, "XYZ")?

DISCUSSION Daniel J Walsh 2 participants 2 messages Sep 20, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

Shouldn't the access(file, W_OK) be treated as a getattr rather then a write access?

Several apps including the kernel do access checks on open file descriptors and we end up having to write dontaudit rules on {read write append} when what we really only want to allow the getattr.

Dan

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 8 lines · Daniel J Walsh

Shouldn't the access(file, W_OK) be treated as a getattr rather then a write access?

Several apps including the kernel do access checks on open file descriptors and we end up having to write dontaudit rules on {read write append} when what we really only want to allow the getattr.

From an interface/behavior POV, if an application successfully calls

access(file, W_OK), it expects a subsequent open(file, O_RDWR) to succeed (*). So checking different permissions on access(2) vs. open(2) seems prone to application confusion.

Quoted 1 line

From an implementation POV, access(2) just calls the kernel's

permission() function internally, and thus SELinux sees no difference between it and an open(2). There aren't separate permission checking code paths or security hooks for the two operations, either for DAC or SELinux. The only difference is that access(2) brackets the call to permission() with manipulation of the uid/gid/capabilities so that the check is made against the "real" credentials rather than the "effective" credentials, but such manipulation is not done for the SELinux SID/context.

(*) Unless the application is suid/sgid and the caller was authorized to write but the new fs uid/gid is not.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.