1. 12 10月, 2019 1 次提交
    • L
      9p: Transport error uninitialized · 07f3596c
      Lu Shuaibing 提交于
      [ Upstream commit 0ce772fe79b68f83df40f07f28207b292785c677 ]
      
      The p9_tag_alloc() does not initialize the transport error t_err field.
      The struct p9_req_t *req is allocated and stored in a struct p9_client
      variable. The field t_err is never initialized before p9_conn_cancel()
      checks its value.
      
      KUMSAN(KernelUninitializedMemorySantizer, a new error detection tool)
      reports this bug.
      
      ==================================================================
      BUG: KUMSAN: use of uninitialized memory in p9_conn_cancel+0x2d9/0x3b0
      Read of size 4 at addr ffff88805f9b600c by task kworker/1:2/1216
      
      CPU: 1 PID: 1216 Comm: kworker/1:2 Not tainted 5.2.0-rc4+ #28
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
      Workqueue: events p9_write_work
      Call Trace:
       dump_stack+0x75/0xae
       __kumsan_report+0x17c/0x3e6
       kumsan_report+0xe/0x20
       p9_conn_cancel+0x2d9/0x3b0
       p9_write_work+0x183/0x4a0
       process_one_work+0x4d1/0x8c0
       worker_thread+0x6e/0x780
       kthread+0x1ca/0x1f0
       ret_from_fork+0x35/0x40
      
      Allocated by task 1979:
       save_stack+0x19/0x80
       __kumsan_kmalloc.constprop.3+0xbc/0x120
       kmem_cache_alloc+0xa7/0x170
       p9_client_prepare_req.part.9+0x3b/0x380
       p9_client_rpc+0x15e/0x880
       p9_client_create+0x3d0/0xac0
       v9fs_session_init+0x192/0xc80
       v9fs_mount+0x67/0x470
       legacy_get_tree+0x70/0xd0
       vfs_get_tree+0x4a/0x1c0
       do_mount+0xba9/0xf90
       ksys_mount+0xa8/0x120
       __x64_sys_mount+0x62/0x70
       do_syscall_64+0x6d/0x1e0
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Freed by task 0:
      (stack is not available)
      
      The buggy address belongs to the object at ffff88805f9b6008
       which belongs to the cache p9_req_t of size 144
      The buggy address is located 4 bytes inside of
       144-byte region [ffff88805f9b6008, ffff88805f9b6098)
      The buggy address belongs to the page:
      page:ffffea00017e6d80 refcount:1 mapcount:0 mapping:ffff888068b63740 index:0xffff88805f9b7d90 compound_mapcount: 0
      flags: 0x100000000010200(slab|head)
      raw: 0100000000010200 ffff888068b66450 ffff888068b66450 ffff888068b63740
      raw: ffff88805f9b7d90 0000000000100001 00000001ffffffff 0000000000000000
      page dumped because: kumsan: bad access detected
      ==================================================================
      
      Link: http://lkml.kernel.org/r/20190613070854.10434-1-shuaibinglu@126.comSigned-off-by: NLu Shuaibing <shuaibinglu@126.com>
      [dominique.martinet@cea.fr: grouped the added init with the others]
      Signed-off-by: NDominique Martinet <dominique.martinet@cea.fr>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      07f3596c
  2. 03 7月, 2019 6 次提交
  3. 24 3月, 2019 1 次提交
  4. 13 1月, 2019 1 次提交
    • D
      9p/net: put a lower bound on msize · 6bf97c01
      Dominique Martinet 提交于
      commit 574d356b7a02c7e1b01a1d9cba8a26b3c2888f45 upstream.
      
      If the requested msize is too small (either from command line argument
      or from the server version reply), we won't get any work done.
      If it's *really* too small, nothing will work, and this got caught by
      syzbot recently (on a new kmem_cache_create_usercopy() call)
      
      Just set a minimum msize to 4k in both code paths, until someone
      complains they have a use-case for a smaller msize.
      
      We need to check in both mount option and server reply individually
      because the msize for the first version request would be unchecked
      with just a global check on clnt->msize.
      
      Link: http://lkml.kernel.org/r/1541407968-31350-1-git-send-email-asmadeus@codewreck.org
      Reported-by: syzbot+0c1d61e4db7db94102ca@syzkaller.appspotmail.com
      Signed-off-by: NDominique Martinet <dominique.martinet@cea.fr>
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Latchesar Ionkov <lucho@ionkov.net>
      Cc: stable@vger.kernel.org
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6bf97c01
  5. 13 8月, 2018 8 次提交
  6. 15 7月, 2018 1 次提交
  7. 08 6月, 2018 1 次提交
  8. 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
  9. 20 11月, 2017 1 次提交
  10. 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
  11. 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
  12. 22 4月, 2017 1 次提交
  13. 18 4月, 2017 1 次提交
  14. 02 3月, 2017 1 次提交
  15. 12 1月, 2017 1 次提交
  16. 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
  17. 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
  18. 05 7月, 2015 3 次提交
  19. 12 4月, 2015 4 次提交
  20. 16 7月, 2014 1 次提交
  21. 26 3月, 2014 2 次提交