All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Missing security_inode_readlink() in xfs_file_ioctl()
       [not found] <41DC519D-83A7-4964-A6C8-B16CFEEDB65F@vt.edu>
@ 2018-08-10  9:22 ` Dan Carpenter
  2018-08-10 16:09   ` Darrick J. Wong
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2018-08-10  9:22 UTC (permalink / raw)
  To: TongZhang, linux-xfs
  Cc: security@kernel.org>, darrick.wong, wenbo.s, ahmedmoneeb

Hi XFS devs,

We received this email on security@kernel.org.  This is under
CAP_SYS_ADMIN, but it maybe should also check with selinux?

regards,
dan carpenter

On Thu, Aug 09, 2018 at 05:59:50PM -0700, TongZhang wrote:
> [1.] One line summary of the problem:
> 
> Possible missing security_inode_readlink() in xfs_file_ioctl()
> 
> [2.] Full description of the problem/report:
> 
> We noticed a use of vfs_readlink() in xfs_file_ioctl(), which should have been checked by 
> security_inode_readlink().
> 
> The callgraph is:
> 	xfs_file_ioctl()->xfs_readlink_by_handle()->vfs_readlink()
> 
> This path allows user to do things similar to SyS_readlinkat(), and the parameters are
> user controllable.
> 
> 
> [3.] Keywords: LSM check
> [4.] Kernel information
> [4.1] Kernel Version: 4.14.61
> 
> 
> - Tong

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

* Re: Missing security_inode_readlink() in xfs_file_ioctl()
  2018-08-10  9:22 ` Missing security_inode_readlink() in xfs_file_ioctl() Dan Carpenter
@ 2018-08-10 16:09   ` Darrick J. Wong
  2018-08-10 16:34     ` Linus Torvalds
  2018-08-10 19:02     ` Dan Carpenter
  0 siblings, 2 replies; 7+ messages in thread
From: Darrick J. Wong @ 2018-08-10 16:09 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: TongZhang, linux-xfs, security@kernel.org>, wenbo.s, ahmedmoneeb

On Fri, Aug 10, 2018 at 12:22:29PM +0300, Dan Carpenter wrote:
> Hi XFS devs,
> 
> We received this email on security@kernel.org.  This is under
> CAP_SYS_ADMIN, but it maybe should also check with selinux?

Hmm, so the point of adding a security_inode_readlink call would be to
restrict userland access xfs_readlink_by_handle further in case the
system has a policy whereby even possessing CAP_SYS_ADMIN is not by
itself sufficient to be able to read a symlink?

IOWs, are there security policies where CAP_SYS_ADMIN isn't a "get
access to everything" wildcard?  I imagine the answer is "yes" and
therefore xfs needs the call, but I thought I'd ask first.

--D

> regards,
> dan carpenter
> 
> On Thu, Aug 09, 2018 at 05:59:50PM -0700, TongZhang wrote:
> > [1.] One line summary of the problem:
> > 
> > Possible missing security_inode_readlink() in xfs_file_ioctl()
> > 
> > [2.] Full description of the problem/report:
> > 
> > We noticed a use of vfs_readlink() in xfs_file_ioctl(), which should have been checked by 
> > security_inode_readlink().
> > 
> > The callgraph is:
> > 	xfs_file_ioctl()->xfs_readlink_by_handle()->vfs_readlink()
> > 
> > This path allows user to do things similar to SyS_readlinkat(), and the parameters are
> > user controllable.
> > 
> > 
> > [3.] Keywords: LSM check
> > [4.] Kernel information
> > [4.1] Kernel Version: 4.14.61
> > 
> > 
> > - Tong

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

* Re: Missing security_inode_readlink() in xfs_file_ioctl()
  2018-08-10 16:09   ` Darrick J. Wong
@ 2018-08-10 16:34     ` Linus Torvalds
  2018-08-10 19:02     ` Dan Carpenter
  1 sibling, 0 replies; 7+ messages in thread
From: Linus Torvalds @ 2018-08-10 16:34 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Dan Carpenter, Tong Zhang, linux-xfs, security, wenbo.s, ahmedmoneeb

On Fri, Aug 10, 2018 at 9:09 AM Darrick J. Wong <darrick.wong@oracle.com> wrote:
>
> IOWs, are there security policies where CAP_SYS_ADMIN isn't a "get
> access to everything" wildcard?  I imagine the answer is "yes" and
> therefore xfs needs the call, but I thought I'd ask first.

I think the answer is "no", at least for filesystems where it allows
you to just remount the filesystem entirely.

These reports are from some automated logic that doesn't take "some
capabilities are more equal than others" into account.

                 Linus

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

* Re: Missing security_inode_readlink() in xfs_file_ioctl()
  2018-08-10 16:09   ` Darrick J. Wong
  2018-08-10 16:34     ` Linus Torvalds
@ 2018-08-10 19:02     ` Dan Carpenter
  2018-08-13  7:35       ` Carlos Maiolino
  1 sibling, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2018-08-10 19:02 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: TongZhang, linux-xfs, security@kernel.org>, wenbo.s, ahmedmoneeb

On Fri, Aug 10, 2018 at 09:09:31AM -0700, Darrick J. Wong wrote:
> On Fri, Aug 10, 2018 at 12:22:29PM +0300, Dan Carpenter wrote:
> > Hi XFS devs,
> > 
> > We received this email on security@kernel.org.  This is under
> > CAP_SYS_ADMIN, but it maybe should also check with selinux?
> 
> Hmm, so the point of adding a security_inode_readlink call would be to
> restrict userland access xfs_readlink_by_handle further in case the
> system has a policy whereby even possessing CAP_SYS_ADMIN is not by
> itself sufficient to be able to read a symlink?
> 
> IOWs, are there security policies where CAP_SYS_ADMIN isn't a "get
> access to everything" wildcard?  I imagine the answer is "yes" and
> therefore xfs needs the call, but I thought I'd ask first.
>

Yeah...  Forget about it.  I pushed this out to you without really
thinking about it, just to get it off my todo list and that wasn't the
right thing.

regards,
dan carpenter

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

* Re: Missing security_inode_readlink() in xfs_file_ioctl()
  2018-08-10 19:02     ` Dan Carpenter
@ 2018-08-13  7:35       ` Carlos Maiolino
  2018-08-13  8:30         ` Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: Carlos Maiolino @ 2018-08-13  7:35 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Darrick J. Wong, TongZhang, linux-xfs, security@kernel.org>,
	wenbo.s, ahmedmoneeb

On Fri, Aug 10, 2018 at 10:02:17PM +0300, Dan Carpenter wrote:
> On Fri, Aug 10, 2018 at 09:09:31AM -0700, Darrick J. Wong wrote:
> > On Fri, Aug 10, 2018 at 12:22:29PM +0300, Dan Carpenter wrote:
> > > Hi XFS devs,
> > > 
> > > We received this email on security@kernel.org.  This is under
> > > CAP_SYS_ADMIN, but it maybe should also check with selinux?
> > 
> > Hmm, so the point of adding a security_inode_readlink call would be to
> > restrict userland access xfs_readlink_by_handle further in case the
> > system has a policy whereby even possessing CAP_SYS_ADMIN is not by
> > itself sufficient to be able to read a symlink?
> > 
> > IOWs, are there security policies where CAP_SYS_ADMIN isn't a "get
> > access to everything" wildcard?  I imagine the answer is "yes" and
> > therefore xfs needs the call, but I thought I'd ask first.
> >
> 
> Yeah...  Forget about it.  I pushed this out to you without really
> thinking about it, just to get it off my todo list and that wasn't the
> right thing.
> 

Just thought it was worth to mention...

A long time ago, I've seen implementations where the system administration was
split between a sys admin and a 'security admin', where the security admin
removed some root permissions, and so, some very specific tasks could only be
done by the security admin.
All these were enforced by selinux.
Although, I don't see such implementations in ages, I still think they are out
there.

Cheers

> regards,
> dan carpenter

-- 
Carlos

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

* Re: Missing security_inode_readlink() in xfs_file_ioctl()
  2018-08-13  7:35       ` Carlos Maiolino
@ 2018-08-13  8:30         ` Dan Carpenter
  2018-08-13 22:22           ` Dave Chinner
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2018-08-13  8:30 UTC (permalink / raw)
  To: Darrick J. Wong, TongZhang, linux-xfs, security@kernel.org>,
	wenbo.s, ahmedmoneeb

On Mon, Aug 13, 2018 at 09:35:28AM +0200, Carlos Maiolino wrote:
> On Fri, Aug 10, 2018 at 10:02:17PM +0300, Dan Carpenter wrote:
> > On Fri, Aug 10, 2018 at 09:09:31AM -0700, Darrick J. Wong wrote:
> > > On Fri, Aug 10, 2018 at 12:22:29PM +0300, Dan Carpenter wrote:
> > > > Hi XFS devs,
> > > > 
> > > > We received this email on security@kernel.org.  This is under
> > > > CAP_SYS_ADMIN, but it maybe should also check with selinux?
> > > 
> > > Hmm, so the point of adding a security_inode_readlink call would be to
> > > restrict userland access xfs_readlink_by_handle further in case the
> > > system has a policy whereby even possessing CAP_SYS_ADMIN is not by
> > > itself sufficient to be able to read a symlink?
> > > 
> > > IOWs, are there security policies where CAP_SYS_ADMIN isn't a "get
> > > access to everything" wildcard?  I imagine the answer is "yes" and
> > > therefore xfs needs the call, but I thought I'd ask first.
> > >
> > 
> > Yeah...  Forget about it.  I pushed this out to you without really
> > thinking about it, just to get it off my todo list and that wasn't the
> > right thing.
> > 
> 
> Just thought it was worth to mention...
> 
> A long time ago, I've seen implementations where the system administration was
> split between a sys admin and a 'security admin', where the security admin
> removed some root permissions, and so, some very specific tasks could only be
> done by the security admin.
> All these were enforced by selinux.
> Although, I don't see such implementations in ages, I still think they are out
> there.

That seems like a crazy thing.  Sys admin can write to firmware, so you
can't really separate root from sys admin.  There are so many other
things that you can do with sys admin.

Another possibility is that maybe the NSA uses selinux for logging, to
try out what files Snowden accessed.  But it's sort of weird for us to
try support some application which might not exist.  TongZhang, try
emailing these things directly to the selinux devs.
selinux@tycho.nsa.gov  They're really the best qualified to talk about
missing LSM checks.

regards,
dan carpenter

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

* Re: Missing security_inode_readlink() in xfs_file_ioctl()
  2018-08-13  8:30         ` Dan Carpenter
@ 2018-08-13 22:22           ` Dave Chinner
  0 siblings, 0 replies; 7+ messages in thread
From: Dave Chinner @ 2018-08-13 22:22 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Darrick J. Wong, TongZhang, linux-xfs, security@kernel.org>,
	wenbo.s, ahmedmoneeb

On Mon, Aug 13, 2018 at 11:30:48AM +0300, Dan Carpenter wrote:
> On Mon, Aug 13, 2018 at 09:35:28AM +0200, Carlos Maiolino wrote:
> > On Fri, Aug 10, 2018 at 10:02:17PM +0300, Dan Carpenter wrote:
> > > On Fri, Aug 10, 2018 at 09:09:31AM -0700, Darrick J. Wong wrote:
> > > > On Fri, Aug 10, 2018 at 12:22:29PM +0300, Dan Carpenter wrote:
> > > > > Hi XFS devs,
> > > > > 
> > > > > We received this email on security@kernel.org.  This is under
> > > > > CAP_SYS_ADMIN, but it maybe should also check with selinux?
> > > > 
> > > > Hmm, so the point of adding a security_inode_readlink call would be to
> > > > restrict userland access xfs_readlink_by_handle further in case the
> > > > system has a policy whereby even possessing CAP_SYS_ADMIN is not by
> > > > itself sufficient to be able to read a symlink?
> > > > 
> > > > IOWs, are there security policies where CAP_SYS_ADMIN isn't a "get
> > > > access to everything" wildcard?  I imagine the answer is "yes" and
> > > > therefore xfs needs the call, but I thought I'd ask first.
> > > >
> > > 
> > > Yeah...  Forget about it.  I pushed this out to you without really
> > > thinking about it, just to get it off my todo list and that wasn't the
> > > right thing.
> > > 
> > 
> > Just thought it was worth to mention...
> > 
> > A long time ago, I've seen implementations where the system administration was
> > split between a sys admin and a 'security admin', where the security admin
> > removed some root permissions, and so, some very specific tasks could only be
> > done by the security admin.
> > All these were enforced by selinux.
> > Although, I don't see such implementations in ages, I still think they are out
> > there.
> 
> That seems like a crazy thing.  Sys admin can write to firmware, so you
> can't really separate root from sys admin.  There are so many other
> things that you can do with sys admin.
> 
> Another possibility is that maybe the NSA uses selinux for logging, to
> try out what files Snowden accessed.  But it's sort of weird for us to
> try support some application which might not exist.  TongZhang, try
> emailing these things directly to the selinux devs.
> selinux@tycho.nsa.gov  They're really the best qualified to talk about
> missing LSM checks.

I suspect the the piece of the puzzle that is missing here is that
this is a private XFS _filehandle_ interface. This means it is used
to directly access inodes *without permission checks* by highly
trusted applications that are tightly integrated into filesystem
operation.  e.g. HSMs, userspace file servers, online defrag tools,
backup/restore utilities, etc.

These applications are subject to very different access rules to
"normal" users - they are effectively considered an extension of the
kernel filesystem implementation as the filesystem may not function
correctly without those applications being able to do what they do
without interference. Hence the CAP_SYS_ADMIN check and the complete
absence of any other type of permission check.....

IOWs, denying inode access through these interfaces based on LSM
policy checks will almost certainly cause the applications that use
the private XFS filehandle interfaces to misbehave in unpredictable
ways.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

end of thread, other threads:[~2018-08-14  1:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <41DC519D-83A7-4964-A6C8-B16CFEEDB65F@vt.edu>
2018-08-10  9:22 ` Missing security_inode_readlink() in xfs_file_ioctl() Dan Carpenter
2018-08-10 16:09   ` Darrick J. Wong
2018-08-10 16:34     ` Linus Torvalds
2018-08-10 19:02     ` Dan Carpenter
2018-08-13  7:35       ` Carlos Maiolino
2018-08-13  8:30         ` Dan Carpenter
2018-08-13 22:22           ` Dave Chinner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.