1. 06 4月, 2018 2 次提交
    • C
      net/9p/client.c: fix potential refcnt problem of trans module · 9421c3e6
      Chengguang Xu 提交于
      When specifying trans_mod multiple times in a mount, it will cause an
      inaccurate refcount of the trans module.  Also, in the error case of
      option parsing, we should put the trans module if we have already got
      it.
      
      Link: http://lkml.kernel.org/r/1522154942-57339-1-git-send-email-cgxu519@gmx.comSigned-off-by: NChengguang Xu <cgxu519@gmx.com>
      Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Ron Minnich <rminnich@sandia.gov>
      Cc: Latchesar Ionkov <lucho@ionkov.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9421c3e6
    • G
      net/9p: avoid -ERESTARTSYS leak to userspace · a8522243
      Greg Kurz 提交于
      If it was interrupted by a signal, the 9p client may need to send some
      more requests to the server for cleanup before returning to userspace.
      
      To avoid such a last minute request to be interrupted right away, the
      client memorizes if a signal is pending, clears TIF_SIGPENDING, handles
      the request and calls recalc_sigpending() before returning.
      
      Unfortunately, if the transmission of this cleanup request fails for any
      reason, the transport returns an error and the client propagates it
      right away, without calling recalc_sigpending().
      
      This ends up with -ERESTARTSYS from the initially interrupted request
      crawling up to syscall exit, with TIF_SIGPENDING cleared by the cleanup
      request.  The specific signal handling code, which is responsible for
      converting -ERESTARTSYS to -EINTR is not called, and userspace receives
      the confusing errno value:
      
        open: Unknown error 512 (512)
      
      This is really hard to hit in real life.  I discovered the issue while
      working on hot-unplug of a virtio-9p-pci device with an instrumented
      QEMU allowing to control request completion.
      
      Both p9_client_zc_rpc() and p9_client_rpc() functions have this buggy
      error path actually.  Their code flow is a bit obscure and the best
      thing to do would probably be a full rewrite: to really ensure this
      situation of clearing TIF_SIGPENDING and returning -ERESTARTSYS can
      never happen.
      
      But given the general lack of interest for the 9p code, I won't risk
      breaking more things.  So this patch simply fixes the buggy paths in
      both functions with a trivial label+goto.
      
      Thanks to Laurent Dufour for his help and suggestions on how to find the
      root cause and how to fix it.
      
      Link: http://lkml.kernel.org/r/152062809886.10599.7361006774123053312.stgit@bahia.lanSigned-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NYiwen Jiang <jiangyiwen@huawei.com>
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Ron Minnich <rminnich@sandia.gov>
      Cc: Latchesar Ionkov <lucho@ionkov.net>
      Cc: David Miller <davem@davemloft.net>
      Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a8522243
  2. 20 11月, 2017 1 次提交
  3. 24 10月, 2017 1 次提交
    • T
      net/9p: Switch to wait_event_killable() · 9523feac
      Tuomas Tynkkynen 提交于
      Because userspace gets Very Unhappy when calls like stat() and execve()
      return -EINTR on 9p filesystem mounts. For instance, when bash is
      looking in PATH for things to execute and some SIGCHLD interrupts
      stat(), bash can throw a spurious 'command not found' since it doesn't
      retry the stat().
      
      In practice, hitting the problem is rare and needs a really
      slow/bogged down 9p server.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NTuomas Tynkkynen <tuomas@tuxera.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      9523feac
  4. 11 7月, 2017 1 次提交
    • D
      9p: Implement show_options · c4fac910
      David Howells 提交于
      Implement the show_options superblock op for 9p as part of a bid to get
      rid of s_options and generic_show_options() to make it easier to implement
      a context-based mount where the mount options can be passed individually
      over a file descriptor.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: Eric Van Hensbergen <ericvh@gmail.com>
      cc: Ron Minnich <rminnich@sandia.gov>
      cc: Latchesar Ionkov <lucho@ionkov.net>
      cc: v9fs-developer@lists.sourceforge.net
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      c4fac910
  5. 22 4月, 2017 1 次提交
  6. 18 4月, 2017 1 次提交
  7. 02 3月, 2017 1 次提交
  8. 12 1月, 2017 1 次提交
  9. 28 5月, 2016 1 次提交
    • A
      remove lots of IS_ERR_VALUE abuses · 287980e4
      Arnd Bergmann 提交于
      Most users of IS_ERR_VALUE() in the kernel are wrong, as they
      pass an 'int' into a function that takes an 'unsigned long'
      argument. This happens to work because the type is sign-extended
      on 64-bit architectures before it gets converted into an
      unsigned type.
      
      However, anything that passes an 'unsigned short' or 'unsigned int'
      argument into IS_ERR_VALUE() is guaranteed to be broken, as are
      8-bit integers and types that are wider than 'unsigned long'.
      
      Andrzej Hajda has already fixed a lot of the worst abusers that
      were causing actual bugs, but it would be nice to prevent any
      users that are not passing 'unsigned long' arguments.
      
      This patch changes all users of IS_ERR_VALUE() that I could find
      on 32-bit ARM randconfig builds and x86 allmodconfig. For the
      moment, this doesn't change the definition of IS_ERR_VALUE()
      because there are probably still architecture specific users
      elsewhere.
      
      Almost all the warnings I got are for files that are better off
      using 'if (err)' or 'if (err < 0)'.
      The only legitimate user I could find that we get a warning for
      is the (32-bit only) freescale fman driver, so I did not remove
      the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
      For 9pfs, I just worked around one user whose calling conventions
      are so obscure that I did not dare change the behavior.
      
      I was using this definition for testing:
      
       #define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
             unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))
      
      which ends up making all 16-bit or wider types work correctly with
      the most plausible interpretation of what IS_ERR_VALUE() was supposed
      to return according to its users, but also causes a compile-time
      warning for any users that do not pass an 'unsigned long' argument.
      
      I suggested this approach earlier this year, but back then we ended
      up deciding to just fix the users that are obviously broken. After
      the initial warning that caused me to get involved in the discussion
      (fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
      asked me to send the whole thing again.
      
      [ Updated the 9p parts as per Al Viro  - Linus ]
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Link: https://lkml.org/lkml/2016/1/7/363
      Link: https://lkml.org/lkml/2016/5/27/486
      Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> # For nvmem part
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      287980e4
  10. 23 8月, 2015 1 次提交
    • V
      9p: ensure err is initialized to 0 in p9_client_read/write · 999b8b88
      Vincent Bernat 提交于
      Some use of those functions were providing unitialized values to those
      functions. Notably, when reading 0 bytes from an empty file on a 9P
      filesystem, the return code of read() was not 0.
      
      Tested with this simple program:
      
          #include <assert.h>
          #include <sys/types.h>
          #include <sys/stat.h>
          #include <fcntl.h>
          #include <unistd.h>
      
          int main(int argc, const char **argv)
          {
              assert(argc == 2);
              char buffer[256];
              int fd = open(argv[1], O_RDONLY|O_NOCTTY);
              assert(fd >= 0);
              assert(read(fd, buffer, 0) == 0);
              return 0;
          }
      
      Cc: stable@vger.kernel.org # v4.1
      Signed-off-by: NVincent Bernat <vincent@bernat.im>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      999b8b88
  11. 05 7月, 2015 3 次提交
  12. 12 4月, 2015 4 次提交
  13. 16 7月, 2014 1 次提交
  14. 26 3月, 2014 4 次提交
  15. 10 2月, 2014 1 次提交
  16. 24 11月, 2013 1 次提交
  17. 26 8月, 2013 1 次提交
    • W
      fs/9p: avoid accessing utsname after namespace has been torn down · 50192abe
      Will Deacon 提交于
      During trinity fuzzing in a kvmtool guest, I stumbled across the
      following:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000004
      PC is at v9fs_file_do_lock+0xc8/0x1a0
      LR is at v9fs_file_do_lock+0x48/0x1a0
      [<c01e2ed0>] (v9fs_file_do_lock+0xc8/0x1a0) from [<c0119154>] (locks_remove_flock+0x8c/0x124)
      [<c0119154>] (locks_remove_flock+0x8c/0x124) from [<c00d9bf0>] (__fput+0x58/0x1e4)
      [<c00d9bf0>] (__fput+0x58/0x1e4) from [<c0044340>] (task_work_run+0xac/0xe8)
      [<c0044340>] (task_work_run+0xac/0xe8) from [<c002e36c>] (do_exit+0x6bc/0x8d8)
      [<c002e36c>] (do_exit+0x6bc/0x8d8) from [<c002e674>] (do_group_exit+0x3c/0xb0)
      [<c002e674>] (do_group_exit+0x3c/0xb0) from [<c002e6f8>] (__wake_up_parent+0x0/0x18)
      
      I believe this is due to an attempt to access utsname()->nodename, after
      exit_task_namespaces() has been called, leaving current->nsproxy->uts_ns
      as NULL and causing the above dereference.
      
      A similar issue was fixed for lockd in 9a1b6bf8 ("LOCKD: Don't call
      utsname()->nodename from nlmclnt_setlockargs"), so this patch attempts
      something similar for 9pfs.
      
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Ron Minnich <rminnich@sandia.gov>
      Cc: Latchesar Ionkov <lucho@ionkov.net>
      Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      50192abe
  18. 31 7月, 2013 1 次提交
  19. 08 7月, 2013 4 次提交
  20. 29 5月, 2013 1 次提交
  21. 28 5月, 2013 3 次提交
  22. 12 2月, 2013 2 次提交
    • E
      9p: Modify the stat structures to use kuid_t and kgid_t · 447c5094
      Eric W. Biederman 提交于
      9p has thre strucrtures that can encode inode stat information.  Modify
      all of those structures to contain kuid_t and kgid_t values.  Modify
      he wire encoders and decoders of those structures to use 'u' and 'g' instead of
      'd' in the format string where uids and gids are present.
      
      This results in all kuid and kgid conversion to and from on the wire values
      being performed by the same code in protocol.c where the client is known
      at the time of the conversion.
      
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Ron Minnich <rminnich@gmail.com>
      Cc: Latchesar Ionkov <lucho@ionkov.net>
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      447c5094
    • E
      9p: Transmit kuid and kgid values · f791f7c5
      Eric W. Biederman 提交于
      Modify the p9_client_rpc format specifiers of every function that
      directly transmits a uid or a gid from 'd' to 'u' or 'g' as
      appropriate.
      
      Modify those same functions to take kuid_t and kgid_t parameters
      instead of uid_t and gid_t parameters.
      
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Ron Minnich <rminnich@gmail.com>
      Cc: Latchesar Ionkov <lucho@ionkov.net>
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      f791f7c5
  23. 07 9月, 2012 1 次提交
    • S
      net/9p: Check errno validity · 43def35c
      Simon Derr 提交于
      While working on a modified server I had the Linux clients crash
      a few times. This lead me to find this:
      
      Some error codes are directly extracted from the server replies.
      A malformed server reply could contain an invalid error code, with a
      very large value. If this value is then passed to ERR_PTR() it will
      not be properly detected as an error code by IS_ERR() and as a result
      the kernel will dereference an invalid pointer.
      
      This patch tries to avoid this.
      Signed-off-by: NSimon Derr <simon.derr@bull.net>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      43def35c
  24. 05 6月, 2012 1 次提交
  25. 04 6月, 2012 1 次提交
    • J
      net: Remove casts to same type · e3192690
      Joe Perches 提交于
      Adding casts of objects to the same type is unnecessary
      and confusing for a human reader.
      
      For example, this cast:
      
      	int y;
      	int *p = (int *)&y;
      
      I used the coccinelle script below to find and remove these
      unnecessary casts.  I manually removed the conversions this
      script produces of casts with __force and __user.
      
      @@
      type T;
      T *p;
      @@
      
      -	(T *)p
      +	p
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e3192690