1. 13 10月, 2021 1 次提交
  2. 14 9月, 2021 1 次提交
    • J
      iov_iter: add helper to save iov_iter state · 8fb0f47a
      Jens Axboe 提交于
      In an ideal world, when someone is passed an iov_iter and returns X bytes,
      then X bytes would have been consumed/advanced from the iov_iter. But we
      have use cases that always consume the entire iterator, a few examples
      of that are iomap and bdev O_DIRECT. This means we cannot rely on the
      state of the iov_iter once we've called ->read_iter() or ->write_iter().
      
      This would be easier if we didn't always have to deal with truncate of
      the iov_iter, as rewinding would be trivial without that. We recently
      added a commit to track the truncate state, but that grew the iov_iter
      by 8 bytes and wasn't the best solution.
      
      Implement a helper to save enough of the iov_iter state to sanely restore
      it after we've called the read/write iterator helpers. This currently
      only works for IOVEC/BVEC/KVEC as that's all we need, support for other
      iterator types are left as an exercise for the reader.
      
      Link: https://lore.kernel.org/linux-fsdevel/CAHk-=wiacKV4Gh-MYjteU0LwNBSGpWrK-Ov25HdqB1ewinrFPg@mail.gmail.com/Signed-off-by: NJens Axboe <axboe@kernel.dk>
      8fb0f47a
  3. 09 9月, 2021 1 次提交
  4. 05 7月, 2021 1 次提交
    • L
      iov_iter: remove uaccess_kernel() warning from iov_iter_init() · a180bd1d
      Linus Torvalds 提交于
      This warning was there to catch any architectures that still use
      CONFIG_SET_FS, and that would mis-use iov_iter_init() for anything that
      wasn't a proper user space pointer.  So that
      
              WARN_ON_ONCE(uaccess_kernel());
      
      makes perfect conceptual sense: you really shouldn't use a kernel
      pointer with set_fs(KERNEL_DS) and then pass it to iov_iter_init().
      
      HOWEVER.
      
      Guenter Roeck reports that this warning actually triggers in no-mmu
      configurations of both ARM and m68k.  And the reason isn't that they
      pass in a kernel pointer under set_fs(KERNEL_DS) at all: the reason is
      that in those configurations, "uaccess_kernel()" is simply not reliable.
      
      Those no-mmu setups set USER_DS and KERNEL_DS to the same values, so you
      can't test for the difference.
      
      In particular, the no-mmu case for ARM does
      
         #define USER_DS                 KERNEL_DS
         #define uaccess_kernel()        (true)
      
      so USER_DS and KERNEL_DS have the same value, and uaccess_kernel() is
      always trivially true.
      
      The m68k case is slightly different and not quite as obvious.  It does
      (spread out over multiple header files just to be extra exciting:
      asm/processor.h, asm/segment.h and asm-generic/uaccess.h):
      
         #define TASK_SIZE       (0xFFFFFFFFUL)
         #define USER_DS         MAKE_MM_SEG(TASK_SIZE)
         #define KERNEL_DS       MAKE_MM_SEG(~0UL)
         #define get_fs()        (current_thread_info()->addr_limit)
         #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
      
      but the end result is the same: uaccess_kernel() will always be true,
      because USER_DS and KERNEL_DS end up having the same value, even if that
      value is defined differently.
      
      This is very arguably a misfeature in those implementations, but in the
      end we don't really care.  All modern architectures have gotten rid of
      set_fs() already, and generic kernel code never uses it.  And while the
      sanity check was a nice idea, an architecture would have to go the extra
      mile to actually break this.
      
      So this well-intentioned warning isn't really all that likely to find
      anything but these known false positives, and as such just isn't worth
      maintaining.
      Reported-by: NGuenter Roeck <linux@roeck-us.net>
      Fixes: 8cd54c1c ("iov_iter: separate direction from flavour")
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a180bd1d
  5. 10 6月, 2021 29 次提交
  6. 03 6月, 2021 5 次提交
  7. 06 5月, 2021 1 次提交
  8. 27 4月, 2021 1 次提交