public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* SELinux/SMACK/TOMOYO: ioctl permissions handling is wrong and nonsensicle
@ 2011-01-21 19:30 Eric Paris
  2011-01-21 19:50 ` Casey Schaufler
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Eric Paris @ 2011-01-21 19:30 UTC (permalink / raw)
  To: linux-kernel, linux-security-module, selinux
  Cc: sds, jmorris, casey, john.johansen, penguin-kernel, takedakn

[I've included an AA person as well in case you ever decide to try to
mediate ioctl operations]

SELinux used to recognize certain individual ioctls and check
permissions based on the knowledge of the individual ioctl.  In commit
242631c49d4cf396 the SELinux code stopped trying to understand
individual ioctls and to instead looked at the ioctl access bits to
determine in we should check read or write for that operation.  This
same suggestion was made to SMACK (and I believe copied into TOMOYO).
But this suggestion is total rubbish.  The ioctl access bits are
actually the access requirements for the structure being passed into the
ioctl, and are completely unrelated to the operation of the ioctl or the
object the ioctl is being performed upon.

Take FS_IOC_FIEMAP as an example.  FS_IOC_FIEMAP is defined as:

FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)

So it has access bits R and W.  What this really means is that the
kernel is going to both read and write to the struct fiemap.  It has
nothing at all to do with the operations that this ioctl might perform
on the file itself!

If anything, our logic is exactly backwards, since an ioctl which writes
to userspace would be 'reading' something from the file and an ioctl
which reads from userspace would be 'writing' something to the file...

I'm planning to revert this SELinux commit, but I want other LSM authors
to realize that (assuming I'm not completely off in the woods somewhere)
you should take a look at your ioctl permissions checking as well....

-Eric


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-01-22  2:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-21 19:30 SELinux/SMACK/TOMOYO: ioctl permissions handling is wrong and nonsensicle Eric Paris
2011-01-21 19:50 ` Casey Schaufler
2011-01-21 21:37 ` Stephen Smalley
2011-01-22  2:01 ` SELinux/SMACK/TOMOYO: ioctl permissions handling is wrong andnonsensicle Tetsuo Handa
2011-01-22  2:15   ` Eric Paris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox