1. 25 1月, 2014 2 次提交
    • O
      change close_files() to use rcu_dereference_raw(files->fdt) · ce08b62d
      Oleg Nesterov 提交于
      put_files_struct() and close_files() do rcu_read_lock() to make
      rcu_dereference_check_fdtable() happy.
      
      This looks a bit ugly, files_fdtable() just reads the pointer,
      we can simply use rcu_dereference_raw() to avoid the warning.
      
      The patch also changes close_files() to return fdt, this avoids
      another rcu_read_lock()/files_fdtable() in put_files_struct().
      
      I think close_files() needs more cleanups:
      
      	- we do not need xchg() exactly because we are the last
      	  user of this files_struct
      
      	- "if (file)" should be turned into WARN_ON(!file)
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      ce08b62d
    • O
      introduce __fcheck_files() to fix rcu_dereference_check_fdtable(), kill rcu_my_thread_group_empty() · a8d4b834
      Oleg Nesterov 提交于
      rcu_dereference_check_fdtable() looks very wrong,
      
      1. rcu_my_thread_group_empty() was added by 844b9a87 "vfs: fix
         RCU-lockdep false positive due to /proc" but it doesn't really
         fix the problem. A CLONE_THREAD (without CLONE_FILES) task can
         hit the same race with get_files_struct().
      
         And otoh rcu_my_thread_group_empty() can suppress the correct
         warning if the caller is the CLONE_FILES (without CLONE_THREAD)
         task.
      
      2. files->count == 1 check is not really right too. Even if this
         files_struct is not shared it is not safe to access it lockless
         unless the caller is the owner.
      
         Otoh, this check is sub-optimal. files->count == 0 always means
         it is safe to use it lockless even if files != current->files,
         but put_files_struct() has to take rcu_read_lock(). See the next
         patch.
      
      This patch removes the buggy checks and turns fcheck_files() into
      __fcheck_files() which uses rcu_dereference_raw(), the "unshared"
      callers, fget_light() and fget_raw_light(), can use it to avoid
      the warning from RCU-lockdep.
      
      fcheck_files() is trivially reimplemented as rcu_lockdep_assert()
      plus __fcheck_files().
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      a8d4b834
  2. 02 5月, 2013 1 次提交
  3. 19 2月, 2013 1 次提交
  4. 04 1月, 2013 1 次提交
    • G
      misc: remove __dev* attributes. · 6ae14171
      Greg Kroah-Hartman 提交于
      CONFIG_HOTPLUG is going away as an option.  As a result, the __dev*
      markings need to be removed.
      
      This change removes the last of the __dev* markings from the kernel from
      a variety of different, tiny, places.
      
      Based on patches originally written by Bill Pemberton, but redone by me
      in order to handle some of the coding style issues better, by hand.
      
      Cc: Bill Pemberton <wfp5p@virginia.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ae14171
  5. 30 11月, 2012 1 次提交
  6. 29 11月, 2012 1 次提交
  7. 12 11月, 2012 1 次提交
  8. 31 10月, 2012 1 次提交
  9. 10 10月, 2012 1 次提交
    • R
      dup3: Return an error when oldfd == newfd. · aed97647
      Richard W.M. Jones 提交于
      I have tested the attached patch to fix the dup3 regression.
      
      Rich.
      
      From 0944e30e12dec6544b3602626b60ff412375c78f Mon Sep 17 00:00:00 2001
      From: "Richard W.M. Jones" <rjones@redhat.com>
      Date: Tue, 9 Oct 2012 14:42:45 +0100
      Subject: [PATCH] dup3: Return an error when oldfd == newfd.
      
      The following commit:
      
        commit fe17f22d
        Author: Al Viro <viro@zeniv.linux.org.uk>
        Date:   Tue Aug 21 11:48:11 2012 -0400
      
          take purely descriptor-related stuff from fcntl.c to file.c
      
      was supposed to be just code motion, but it dropped the following two
      lines:
      
        if (unlikely(oldfd == newfd))
                return -EINVAL;
      
      from the dup3 system call.  dup3 is not specified by POSIX, so Linux
      can do what it likes.  However the POSIX proposal for dup3 [1] states
      that it should return an error if oldfd == newfd.
      
      [1] http://austingroupbugs.net/view.php?id=411Signed-off-by: NRichard W.M. Jones <rjones@redhat.com>
      Tested-by: NRichard W.M. Jones <rjones@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      aed97647
  10. 27 9月, 2012 18 次提交
  11. 29 2月, 2012 1 次提交
  12. 24 2月, 2012 1 次提交
  13. 20 2月, 2012 2 次提交
    • D
      Replace the fd_sets in struct fdtable with an array of unsigned longs · 1fd36adc
      David Howells 提交于
      Replace the fd_sets in struct fdtable with an array of unsigned longs and then
      use the standard non-atomic bit operations rather than the FD_* macros.
      
      This:
      
       (1) Removes the abuses of struct fd_set:
      
           (a) Since we don't want to allocate a full fd_set the vast majority of the
           	 time, we actually, in effect, just allocate a just-big-enough array of
           	 unsigned longs and cast it to an fd_set type - so why bother with the
           	 fd_set at all?
      
           (b) Some places outside of the core fdtable handling code (such as
           	 SELinux) want to look inside the array of unsigned longs hidden inside
           	 the fd_set struct for more efficient iteration over the entire set.
      
       (2) Eliminates the use of FD_*() macros in the kernel completely.
      
       (3) Permits the __FD_*() macros to be deleted entirely where not exposed to
           userspace.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Link: http://lkml.kernel.org/r/20120216174954.23314.48147.stgit@warthog.procyon.org.ukSigned-off-by: NH. Peter Anvin <hpa@zytor.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      1fd36adc
    • D
      Wrap accesses to the fd_sets in struct fdtable · 1dce27c5
      David Howells 提交于
      Wrap accesses to the fd_sets in struct fdtable (for recording open files and
      close-on-exec flags) so that we can move away from using fd_sets since we
      abuse the fd_set structs by not allocating the full-sized structure under
      normal circumstances and by non-core code looking at the internals of the
      fd_sets.
      
      The first abuse means that use of FD_ZERO() on these fd_sets is not permitted,
      since that cannot be told about their abnormal lengths.
      
      This introduces six wrapper functions for setting, clearing and testing
      close-on-exec flags and fd-is-open flags:
      
      	void __set_close_on_exec(int fd, struct fdtable *fdt);
      	void __clear_close_on_exec(int fd, struct fdtable *fdt);
      	bool close_on_exec(int fd, const struct fdtable *fdt);
      	void __set_open_fd(int fd, struct fdtable *fdt);
      	void __clear_open_fd(int fd, struct fdtable *fdt);
      	bool fd_is_open(int fd, const struct fdtable *fdt);
      
      Note that I've prepended '__' to the names of the set/clear functions because
      they require the caller to hold a lock to use them.
      
      Note also that I haven't added wrappers for looking behind the scenes at the
      the array.  Possibly that should exist too.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Link: http://lkml.kernel.org/r/20120216174942.23314.1364.stgit@warthog.procyon.org.ukSigned-off-by: NH. Peter Anvin <hpa@zytor.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      1dce27c5
  14. 29 4月, 2011 1 次提交
  15. 11 8月, 2010 1 次提交
    • C
      vfs: use kmalloc() to allocate fdmem if possible · a892e2d7
      Changli Gao 提交于
      Use kmalloc() to allocate fdmem if possible.
      
      vmalloc() is used as a fallback solution for fdmem allocation.  A new
      helper function __free_fdtable() is introduced to reduce the lines of
      code.
      
      A potential bug, vfree() a memory allocated by kmalloc(), is fixed.
      
      [akpm@linux-foundation.org: use __GFP_NOWARN, uninline alloc_fdmem() and free_fdmem()]
      Signed-off-by: NChangli Gao <xiaosuo@gmail.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Avi Kivity <avi@redhat.com>
      Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a892e2d7
  16. 15 6月, 2010 1 次提交
  17. 07 3月, 2010 1 次提交
  18. 25 2月, 2010 1 次提交
    • P
      vfs: Apply lockdep-based checking to rcu_dereference() uses · 7dc52157
      Paul E. McKenney 提交于
      Add lockdep-ified RCU primitives to alloc_fd(), files_fdtable()
      and fcheck_files().
      
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: laijs@cn.fujitsu.com
      Cc: dipankar@in.ibm.com
      Cc: mathieu.desnoyers@polymtl.ca
      Cc: josh@joshtriplett.org
      Cc: dvhltc@us.ibm.com
      Cc: niv@us.ibm.com
      Cc: peterz@infradead.org
      Cc: rostedt@goodmis.org
      Cc: Valdis.Kletnieks@vt.edu
      Cc: dhowells@redhat.com
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      LKML-Reference: <1266887105-1528-8-git-send-email-paulmck@linux.vnet.ibm.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      7dc52157
  19. 12 10月, 2009 1 次提交
  20. 01 8月, 2008 1 次提交
  21. 27 7月, 2008 1 次提交
    • A
      [PATCH] fix RLIM_NOFILE handling · 4e1e018e
      Al Viro 提交于
      * dup2() should return -EBADF on exceeded sysctl_nr_open
      * dup() should *not* return -EINVAL even if you have rlimit set to 0;
        it should get -EMFILE instead.
      
      Check for orig_start exceeding rlimit taken to sys_fcntl().
      Failing expand_files() in dup{2,3}() now gets -EMFILE remapped to -EBADF.
      Consequently, remaining checks for rlimit are taken to expand_files().
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      4e1e018e