1. 18 10月, 2007 28 次提交
  2. 17 10月, 2007 12 次提交
    • A
      security/ cleanups · cbfee345
      Adrian Bunk 提交于
      This patch contains the following cleanups that are now possible:
      - remove the unused security_operations->inode_xattr_getsuffix
      - remove the no longer used security_operations->unregister_security
      - remove some no longer required exit code
      - remove a bunch of no longer used exports
      Signed-off-by: NAdrian Bunk <bunk@kernel.org>
      Acked-by: NJames Morris <jmorris@namei.org>
      Cc: Chris Wright <chrisw@sous-sol.org>
      Cc: Stephen Smalley <sds@tycho.nsa.gov>
      Cc: Serge Hallyn <serue@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cbfee345
    • S
      Implement file posix capabilities · b5376771
      Serge E. Hallyn 提交于
      Implement file posix capabilities.  This allows programs to be given a
      subset of root's powers regardless of who runs them, without having to use
      setuid and giving the binary all of root's powers.
      
      This version works with Kaigai Kohei's userspace tools, found at
      http://www.kaigai.gr.jp/index.php.  For more information on how to use this
      patch, Chris Friedhoff has posted a nice page at
      http://www.friedhoff.org/fscaps.html.
      
      Changelog:
      	Nov 27:
      	Incorporate fixes from Andrew Morton
      	(security-introduce-file-caps-tweaks and
      	security-introduce-file-caps-warning-fix)
      	Fix Kconfig dependency.
      	Fix change signaling behavior when file caps are not compiled in.
      
      	Nov 13:
      	Integrate comments from Alexey: Remove CONFIG_ ifdef from
      	capability.h, and use %zd for printing a size_t.
      
      	Nov 13:
      	Fix endianness warnings by sparse as suggested by Alexey
      	Dobriyan.
      
      	Nov 09:
      	Address warnings of unused variables at cap_bprm_set_security
      	when file capabilities are disabled, and simultaneously clean
      	up the code a little, by pulling the new code into a helper
      	function.
      
      	Nov 08:
      	For pointers to required userspace tools and how to use
      	them, see http://www.friedhoff.org/fscaps.html.
      
      	Nov 07:
      	Fix the calculation of the highest bit checked in
      	check_cap_sanity().
      
      	Nov 07:
      	Allow file caps to be enabled without CONFIG_SECURITY, since
      	capabilities are the default.
      	Hook cap_task_setscheduler when !CONFIG_SECURITY.
      	Move capable(TASK_KILL) to end of cap_task_kill to reduce
      	audit messages.
      
      	Nov 05:
      	Add secondary calls in selinux/hooks.c to task_setioprio and
      	task_setscheduler so that selinux and capabilities with file
      	cap support can be stacked.
      
      	Sep 05:
      	As Seth Arnold points out, uid checks are out of place
      	for capability code.
      
      	Sep 01:
      	Define task_setscheduler, task_setioprio, cap_task_kill, and
      	task_setnice to make sure a user cannot affect a process in which
      	they called a program with some fscaps.
      
      	One remaining question is the note under task_setscheduler: are we
      	ok with CAP_SYS_NICE being sufficient to confine a process to a
      	cpuset?
      
      	It is a semantic change, as without fsccaps, attach_task doesn't
      	allow CAP_SYS_NICE to override the uid equivalence check.  But since
      	it uses security_task_setscheduler, which elsewhere is used where
      	CAP_SYS_NICE can be used to override the uid equivalence check,
      	fixing it might be tough.
      
      	     task_setscheduler
      		 note: this also controls cpuset:attach_task.  Are we ok with
      		     CAP_SYS_NICE being used to confine to a cpuset?
      	     task_setioprio
      	     task_setnice
      		 sys_setpriority uses this (through set_one_prio) for another
      		 process.  Need same checks as setrlimit
      
      	Aug 21:
      	Updated secureexec implementation to reflect the fact that
      	euid and uid might be the same and nonzero, but the process
      	might still have elevated caps.
      
      	Aug 15:
      	Handle endianness of xattrs.
      	Enforce capability version match between kernel and disk.
      	Enforce that no bits beyond the known max capability are
      	set, else return -EPERM.
      	With this extra processing, it may be worth reconsidering
      	doing all the work at bprm_set_security rather than
      	d_instantiate.
      
      	Aug 10:
      	Always call getxattr at bprm_set_security, rather than
      	caching it at d_instantiate.
      
      [morgan@kernel.org: file-caps clean up for linux/capability.h]
      [bunk@kernel.org: unexport cap_inode_killpriv]
      Signed-off-by: NSerge E. Hallyn <serue@us.ibm.com>
      Cc: Stephen Smalley <sds@tycho.nsa.gov>
      Cc: James Morris <jmorris@namei.org>
      Cc: Chris Wright <chrisw@sous-sol.org>
      Cc: Andrew Morgan <morgan@kernel.org>
      Signed-off-by: NAndrew Morgan <morgan@kernel.org>
      Signed-off-by: NAdrian Bunk <bunk@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b5376771
    • D
      r/o bind mounts: create cleanup helper svc_msnfs() · a8754bee
      Dave Hansen 提交于
      I'm going to be modifying nfsd_rename() shortly to support read-only bind
      mounts.  This #ifdef is around the area I'm patching, and it starts to get
      really ugly if I just try to add my new code by itself.  Using this little
      helper makes things a lot cleaner to use.
      Signed-off-by: NDave Hansen <haveblue@us.ibm.com>
      Acked-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a8754bee
    • D
      r/o bind mounts: give permission() a local 'mnt' variable · c7eb2667
      Dave Hansen 提交于
      First of all, this makes the structure jumping look a little bit cleaner.  So,
      this stands alone as a tiny cleanup.  But, we also need 'mnt' by itself a few
      more times later in this series, so this isn't _just_ a cleanup.
      Signed-off-by: NDave Hansen <haveblue@us.ibm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c7eb2667
    • D
      r/o bind mounts: rearrange may_open() to be r/o friendly · b41572e9
      Dave Hansen 提交于
      may_open() calls vfs_permission() before it does checks for IS_RDONLY(inode).
      It checks _again_ inside of vfs_permission().
      
      The check inside of vfs_permission() is going away eventually.  With the
      mnt_want/drop_write() functions, all of the r/o checks (except for this one)
      are consistently done before calling permission().  Because of this, I'd like
      to use permission() to hold a debugging check to make sure that the
      mnt_want/drop_write() calls are actually being made.
      
      So, to do this:
      1. remove the IS_RDONLY() check from permission()
      2. enforce that you must mnt_want_write() before
         even calling permission()
      3. actually add the debugging check to permission()
      
      We need to rearrange may_open() to do r/o checks before calling permission().
      Here's the patch.
      Signed-off-by: NDave Hansen <haveblue@us.ibm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b41572e9
    • D
      r/o bind mounts: filesystem helpers for custom 'struct file's · ce8d2cdf
      Dave Hansen 提交于
      Why do we need r/o bind mounts?
      
      This feature allows a read-only view into a read-write filesystem.  In the
      process of doing that, it also provides infrastructure for keeping track of
      the number of writers to any given mount.
      
      This has a number of uses.  It allows chroots to have parts of filesystems
      writable.  It will be useful for containers in the future because users may
      have root inside a container, but should not be allowed to write to
      somefilesystems.  This also replaces patches that vserver has had out of the
      tree for several years.
      
      It allows security enhancement by making sure that parts of your filesystem
      read-only (such as when you don't trust your FTP server), when you don't want
      to have entire new filesystems mounted, or when you want atime selectively
      updated.  I've been using the following script to test that the feature is
      working as desired.  It takes a directory and makes a regular bind and a r/o
      bind mount of it.  It then performs some normal filesystem operations on the
      three directories, including ones that are expected to fail, like creating a
      file on the r/o mount.
      
      This patch:
      
      Some filesystems forego the vfs and may_open() and create their own 'struct
      file's.
      
      This patch creates a couple of helper functions which can be used by these
      filesystems, and will provide a unified place which the r/o bind mount code
      may patch.
      
      Also, rename an existing, static-scope init_file() to a less generic name.
      Signed-off-by: NDave Hansen <haveblue@us.ibm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ce8d2cdf
    • M
      fuse: clean up execute permission checking · e8e96157
      Miklos Szeredi 提交于
      Define a new function fuse_refresh_attributes() that conditionally refreshes
      the attributes based on the validity timeout.
      
      In fuse_permission() only refresh the attributes for checking the execute bits
      if necessary.
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e8e96157
    • M
      fuse: no ENOENT from fuse device read · c9c9d7df
      Miklos Szeredi 提交于
      Don't return -ENOENT for a read() on the fuse device when the request was
      aborted.  Instead return -ENODEV, meaning the filesystem has been
      force-umounted or aborted.
      
      Previously ENOENT meant that the request was interrupted, but now the
      'aborted' flag is not set in case of interrupts.
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c9c9d7df
    • M
      fuse: no abort on interrupt · a131de0a
      Miklos Szeredi 提交于
      Don't set 'aborted' flag on a request if it's interrupted.  We have to wait
      for the answer anyway, and this would only a very little time while copying
      the reply.
      
      This means, that write() on the fuse device will not return -ENOENT during
      normal operation, only if the filesystem is aborted by a forced umount or
      through the fusectl interface.
      
      This could simplify userspace code somewhat when backward compatibility with
      earlier kernel versions is not required.
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a131de0a
    • M
      fuse: cleanup in release · 819c4b3b
      Miklos Szeredi 提交于
      Move dput/mntput pair from request_end() to fuse_release_end(), because
      there's no other place they are used.
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      819c4b3b
    • M
      fuse: fix permission checking on sticky directories · ebc14c4d
      Miklos Szeredi 提交于
      The VFS checks sticky bits on the parent directory even if the filesystem
      defines it's own ->permission().  In some situations (sshfs, mountlo, etc) the
      user does have permission to delete a file even if the attribute based
      checking would not allow it.
      
      So work around this by storing the permission bits separately and returning
      them in stat(), but cutting the permission bits off from inode->i_mode.
      
      This is slightly hackish, but it's probably not worth it to add new
      infrastructure in VFS and a slight performance penalty for all filesystems,
      just for the sake of fuse.
      
      [Jan Engelhardt] cosmetic fixes
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ebc14c4d
    • M
      fuse: refresh stale attributes in fuse_permission() · 244f6385
      Miklos Szeredi 提交于
      fuse_permission() didn't refresh inode attributes before using them, even if
      the validity has already expired.
      
      Thanks to Junjiro Okajima for spotting this.
      
      Also remove some old code to unconditionally refresh the attributes on the
      root inode.
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      244f6385