1. 02 1月, 2017 1 次提交
  2. 06 12月, 2016 1 次提交
    • A
      [iov_iter] new primitives - copy_from_iter_full() and friends · cbbd26b8
      Al Viro 提交于
      copy_from_iter_full(), copy_from_iter_full_nocache() and
      csum_and_copy_from_iter_full() - counterparts of copy_from_iter()
      et.al., advancing iterator only in case of successful full copy
      and returning whether it had been successful or not.
      
      Convert some obvious users.  *NOTE* - do not blindly assume that
      something is a good candidate for those unless you are sure that
      not advancing iov_iter in failure case is the right thing in
      this case.  Anything that does short read/short write kind of
      stuff (or is in a loop, etc.) is unlikely to be a good one.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      cbbd26b8
  3. 18 11月, 2016 1 次提交
  4. 03 11月, 2016 1 次提交
  5. 17 10月, 2016 2 次提交
  6. 28 9月, 2016 1 次提交
  7. 08 9月, 2016 1 次提交
  8. 25 8月, 2016 3 次提交
  9. 29 6月, 2016 1 次提交
  10. 21 6月, 2016 3 次提交
  11. 31 5月, 2016 3 次提交
  12. 20 4月, 2016 1 次提交
  13. 19 4月, 2016 1 次提交
    • L
      usb: gadget: f_fs: Fix EFAULT generation for async read operations · 332a5b44
      Lars-Peter Clausen 提交于
      In the current implementation functionfs generates a EFAULT for async read
      operations if the read buffer size is larger than the URB data size. Since
      a application does not necessarily know how much data the host side is
      going to send it typically supplies a buffer larger than the actual data,
      which will then result in a EFAULT error.
      
      This behaviour was introduced while refactoring the code to use iov_iter
      interface in commit c993c39b ("gadget/function/f_fs.c: use put iov_iter
      into io_data"). The original code took the minimum over the URB size and
      the user buffer size and then attempted to copy that many bytes using
      copy_to_user(). If copy_to_user() could not copy all data a EFAULT error
      was generated. Restore the original behaviour by only generating a EFAULT
      error when the number of bytes copied is not the size of the URB and the
      target buffer has not been fully filled.
      
      Commit 342f39a6 ("usb: gadget: f_fs: fix check in read operation")
      already fixed the same problem for the synchronous read path.
      
      Fixes: c993c39b ("gadget/function/f_fs.c: use put iov_iter into io_data")
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      332a5b44
  14. 05 4月, 2016 1 次提交
    • K
      mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros · 09cbfeaf
      Kirill A. Shutemov 提交于
      PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
      ago with promise that one day it will be possible to implement page
      cache with bigger chunks than PAGE_SIZE.
      
      This promise never materialized.  And unlikely will.
      
      We have many places where PAGE_CACHE_SIZE assumed to be equal to
      PAGE_SIZE.  And it's constant source of confusion on whether
      PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
      especially on the border between fs and mm.
      
      Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
      breakage to be doable.
      
      Let's stop pretending that pages in page cache are special.  They are
      not.
      
      The changes are pretty straight-forward:
      
       - <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
      
       - <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
      
       - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
      
       - page_cache_get() -> get_page();
      
       - page_cache_release() -> put_page();
      
      This patch contains automated changes generated with coccinelle using
      script below.  For some reason, coccinelle doesn't patch header files.
      I've called spatch for them manually.
      
      The only adjustment after coccinelle is revert of changes to
      PAGE_CAHCE_ALIGN definition: we are going to drop it later.
      
      There are few places in the code where coccinelle didn't reach.  I'll
      fix them manually in a separate patch.  Comments and documentation also
      will be addressed with the separate patch.
      
      virtual patch
      
      @@
      expression E;
      @@
      - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
      + E
      
      @@
      expression E;
      @@
      - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
      + E
      
      @@
      @@
      - PAGE_CACHE_SHIFT
      + PAGE_SHIFT
      
      @@
      @@
      - PAGE_CACHE_SIZE
      + PAGE_SIZE
      
      @@
      @@
      - PAGE_CACHE_MASK
      + PAGE_MASK
      
      @@
      expression E;
      @@
      - PAGE_CACHE_ALIGN(E)
      + PAGE_ALIGN(E)
      
      @@
      expression E;
      @@
      - page_cache_get(E)
      + get_page(E)
      
      @@
      expression E;
      @@
      - page_cache_release(E)
      + put_page(E)
      Signed-off-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      09cbfeaf
  15. 04 3月, 2016 5 次提交
    • D
      usb: f_fs: avoid race condition with ffs_epfile_io_complete · ef150884
      Du, Changbin 提交于
      ffs_epfile_io and ffs_epfile_io_complete runs in different context, but
      there is no synchronization between them.
      
      consider the following scenario:
      1) ffs_epfile_io interrupted by sigal while
      wait_for_completion_interruptible
      2) then ffs_epfile_io set ret to -EINTR
      3) just before or during usb_ep_dequeue, the request completed
      4) ffs_epfile_io return with -EINTR
      
      In this case, ffs_epfile_io tell caller no transfer success but actually
      it may has been done. This break the caller's pipe.
      
      Below script can help test it (adbd is the process which lies on f_fs).
      while true
      do
         pkill -19 adbd #SIGSTOP
         pkill -18 adbd #SIGCONT
         sleep 0.1
      done
      
      To avoid this, just dequeue the request first. After usb_ep_dequeue, the
      request must be done or canceled.
      
      With this change, we can ensure no race condition in f_fs driver. But
      actually I found some of the udc driver has analogical issue in its
      dequeue implementation. For example,
      1) the dequeue function hold the controller's lock.
      2) before driver request controller  to stop transfer, a request
         completed.
      3) the controller trigger a interrupt, but its irq handler need wait
         dequeue function to release the lock.
      4) dequeue function give back the request with negative status, and
         release lock.
      5) irq handler get lock but the request has already been given back.
      
      So, the dequeue implementation should take care of this case. IMO, it
      can be done as below steps to dequeue a already started request,
      1) request controller to stop transfer on the given ep. HW know the
         actual transfer status.
      2) after hw stop transfer, driver scan if there are any completed one.
      3) if found, process it with real status. if no, the request can
         canceled.
      Signed-off-by: N"Du, Changbin" <changbin.du@intel.com>
      [mina86@mina86.com: rebased on top of refactoring commits]
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      ef150884
    • M
      usb: f_fs: refactor ffs_epfile_io · ae76e134
      Michal Nazarewicz 提交于
      Eliminate one of the return paths by using a ‘goto error_mutex’ and
      rearrange some if-bodies which results in reduction of the indention level
      and thus hopefully makes the function easier to read and reason about.
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      ae76e134
    • M
      usb: f_fs: replace unnecessary goto with a return · b3591f67
      Michal Nazarewicz 提交于
      In ffs_epfile_io error label points to a return path which includes
      a kfree(data) call.  However, at the beginning of the function data is
      always NULL so some of the early ‘goto error’ can safely be replaced
      with a trivial return statement.
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      b3591f67
    • M
      usb: f_fs: fix ffs_epfile_io returning success on req alloc failure · 3163c79e
      Michal Nazarewicz 提交于
      In the AIO path, if allocating of a request failse, the function simply
      goes to the error_lock path whose end result is returning value of ret.
      However, at this point ret’s value is zero (assigned as return value from
      ffs_mutex_lock).
      
      Fix by adding ‘ret = -ENOMEM’ statement.
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      3163c79e
    • M
      usb: f_fs: fix memory leak when ep changes during transfer · 3de4e205
      Michal Nazarewicz 提交于
      In the ffs_epfile_io function, data buffer is allocated for non-halt
      requests.  Later, after grabing a mutex, the function checks that
      epfile->ep is still ep and if it’s not, it set ret to -ESHUTDOWN and
      follow a path including spin_unlock_irq (just after ‘ret = -ESHUTDOWN’),
      mutex_unlock (after if-else-if-else chain) and returns ret.  Noticeably,
      this does not include freeing of the data buffer.
      
      Fix by introducing a goto which moves control flow to the the end of the
      function where spin_unlock_irq, mutex_unlock and kfree are all called.
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      3de4e205
  16. 19 11月, 2015 1 次提交
  17. 31 7月, 2015 1 次提交
  18. 07 7月, 2015 1 次提交
  19. 26 5月, 2015 3 次提交
    • R
      usb: gadget: f_fs: add extra check before unregister_gadget_item · f14e9ad1
      Rui Miguel Silva 提交于
      ffs_closed can race with configfs_rmdir which will call config_item_release, so
      add an extra check to avoid calling the unregister_gadget_item with an null
      gadget item.
      Signed-off-by: NRui Miguel Silva <rui.silva@linaro.org>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      f14e9ad1
    • R
      usb: gadget: f_fs: fix check in read operation · 342f39a6
      Rui Miguel Silva 提交于
      when copying to iter the size can be different then the iov count,
      the check for full iov is wrong and make any read on request which
      is not the exactly size of iov to return -EFAULT.
      
      So, just check the success of the copy.
      Signed-off-by: NRui Miguel Silva <rui.silva@linaro.org>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      342f39a6
    • K
      usb: gadget: ffs: fix: Always call ffs_closed() in ffs_data_clear() · 49a79d8b
      Krzysztof Opasiak 提交于
      Originally FFS_FL_CALL_CLOSED_CALLBACK flag has been used to
      indicate if we should call ffs_closed_callback().
      
      Commit 4b187fce ("usb: gadget: FunctionFS: add devices
      management code") changed its semantic to indicate if we should
      call ffs_closed() function which does a little bit more.
      
      This situation leads to:
      
      [  122.362269] ------------[ cut here ]------------
      [  122.362287] WARNING: CPU: 2 PID: 2384 at drivers/usb/gadget/function/f_fs.c:3417 ffs_ep0_write+0x730/0x810 [usb_f_fs]()
      [  122.362292] Modules linked in:
      [  122.362555] CPU: 2 PID: 2384 Comm: adbd Tainted: G        W       4.1.0-0.rc4.git0.1.1.fc22.i686 #1
      [  122.362561] Hardware name: To be filled by O.E.M. To be filled by O.E.M./Aptio CRB, BIOS 5.6.5 07/25/2014
      [  122.362567]  c0d1f947 415badfa 00000000 d1029e64 c0a86e54 00000000 d1029e94 c045b937
      [  122.362584]  c0c37f94 00000002 00000950 f9b313d4 00000d59 f9b2ebf0 f9b2ebf0 fffffff0
      [  122.362600]  00000003 deb53d00 d1029ea4 c045ba42 00000009 00000000 d1029f08 f9b2ebf0
      [  122.362617] Call Trace:
      [  122.362633]  [<c0a86e54>] dump_stack+0x41/0x52
      [  122.362645]  [<c045b937>] warn_slowpath_common+0x87/0xc0
      [  122.362658]  [<f9b2ebf0>] ? ffs_ep0_write+0x730/0x810 [usb_f_fs]
      [  122.362668]  [<f9b2ebf0>] ? ffs_ep0_write+0x730/0x810 [usb_f_fs]
      [  122.362678]  [<c045ba42>] warn_slowpath_null+0x22/0x30
      [  122.362689]  [<f9b2ebf0>] ffs_ep0_write+0x730/0x810 [usb_f_fs]
      [  122.362702]  [<f9b2e4c0>] ? ffs_ep0_read+0x380/0x380 [usb_f_fs]
      [  122.362712]  [<c05a1c1f>] __vfs_write+0x2f/0x100
      [  122.362722]  [<c05a42f2>] ? __sb_start_write+0x52/0x110
      [  122.362731]  [<c05a2534>] vfs_write+0x94/0x1b0
      [  122.362740]  [<c0a8a1c0>] ? mutex_lock+0x10/0x30
      [  122.362749]  [<c05a2f41>] SyS_write+0x51/0xb0
      [  122.362759]  [<c0a8c71f>] sysenter_do_call+0x12/0x12
      [  122.362766] ---[ end trace 0673d3467cecf8db ]---
      
      in some cases (reproduction path below). This commit get back
      semantic of that flag and ensures that ffs_closed() is called
      always when needed but ffs_closed_callback() is called only
      if this flag is set.
      
      Reproduction path:
      Compile kernel without any UDC driver or bound some gadget
      to existing one and then:
      
      $ modprobe g_ffs
      $ mount none -t functionfs mount_point
      $ ffs-example mount_point
      
      This will fail with -ENODEV as there is no udc.
      
      $ ffs-example mount_point
      
      This will fail with -EBUSY because ffs_data has not been
      properly cleaned up.
      Signed-off-by: NKrzysztof Opasiak <k.opasiak@samsung.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      49a79d8b
  20. 12 4月, 2015 1 次提交
  21. 26 3月, 2015 1 次提交
  22. 14 3月, 2015 1 次提交
    • C
      fs: split generic and aio kiocb · 04b2fa9f
      Christoph Hellwig 提交于
      Most callers in the kernel want to perform synchronous file I/O, but
      still have to bloat the stack with a full struct kiocb.  Split out
      the parts needed in filesystem code from those in the aio code, and
      only allocate those needed to pass down argument on the stack.  The
      aio code embedds the generic iocb in the one it allocates and can
      easily get back to it by using container_of.
      
      Also add a ->ki_complete method to struct kiocb, this is used to call
      into the aio code and thus removes the dependency on aio for filesystems
      impementing asynchronous operations.  It will also allow other callers
      to substitute their own completion callback.
      
      We also add a new ->ki_flags field to work around the nasty layering
      violation recently introduced in commit 5e33f6 ("usb: gadget: ffs: add
      eventfd notification about ffs events").
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      04b2fa9f
  23. 18 2月, 2015 3 次提交
  24. 27 1月, 2015 2 次提交