1. 25 7月, 2022 1 次提交
  2. 19 7月, 2022 1 次提交
    • A
      fs: sendfile handles O_NONBLOCK of out_fd · bdeb77bc
      Andrei Vagin 提交于
      sendfile has to return EAGAIN if out_fd is nonblocking and the write into
      it would block.
      
      Here is a small reproducer for the problem:
      
      #define _GNU_SOURCE /* See feature_test_macros(7) */
      #include <fcntl.h>
      #include <stdio.h>
      #include <unistd.h>
      #include <errno.h>
      #include <sys/stat.h>
      #include <sys/types.h>
      #include <sys/sendfile.h>
      
      
      #define FILE_SIZE (1UL << 30)
      int main(int argc, char **argv) {
              int p[2], fd;
      
              if (pipe2(p, O_NONBLOCK))
                      return 1;
      
              fd = open(argv[1], O_RDWR | O_TMPFILE, 0666);
              if (fd < 0)
                      return 1;
              ftruncate(fd, FILE_SIZE);
      
              if (sendfile(p[1], fd, 0, FILE_SIZE) == -1) {
                      fprintf(stderr, "FAIL\n");
              }
              if (sendfile(p[1], fd, 0, FILE_SIZE) != -1 || errno != EAGAIN) {
                      fprintf(stderr, "FAIL\n");
              }
              return 0;
      }
      
      It worked before b964bf53, it is stuck after b964bf53, and it
      works again with this fix.
      
      This regression occurred because do_splice_direct() calls pipe_write
      that handles O_NONBLOCK.  Here is a trace log from the reproducer:
      
       1)               |  __x64_sys_sendfile64() {
       1)               |    do_sendfile() {
       1)               |      __fdget()
       1)               |      rw_verify_area()
       1)               |      __fdget()
       1)               |      rw_verify_area()
       1)               |      do_splice_direct() {
       1)               |        rw_verify_area()
       1)               |        splice_direct_to_actor() {
       1)               |          do_splice_to() {
       1)               |            rw_verify_area()
       1)               |            generic_file_splice_read()
       1) + 74.153 us   |          }
       1)               |          direct_splice_actor() {
       1)               |            iter_file_splice_write() {
       1)               |              __kmalloc()
       1)   0.148 us    |              pipe_lock();
       1)   0.153 us    |              splice_from_pipe_next.part.0();
       1)   0.162 us    |              page_cache_pipe_buf_confirm();
      ... 16 times
       1)   0.159 us    |              page_cache_pipe_buf_confirm();
       1)               |              vfs_iter_write() {
       1)               |                do_iter_write() {
       1)               |                  rw_verify_area()
       1)               |                  do_iter_readv_writev() {
       1)               |                    pipe_write() {
       1)               |                      mutex_lock()
       1)   0.153 us    |                      mutex_unlock();
       1)   1.368 us    |                    }
       1)   1.686 us    |                  }
       1)   5.798 us    |                }
       1)   6.084 us    |              }
       1)   0.174 us    |              kfree();
       1)   0.152 us    |              pipe_unlock();
       1) + 14.461 us   |            }
       1) + 14.783 us   |          }
       1)   0.164 us    |          page_cache_pipe_buf_release();
      ... 16 times
       1)   0.161 us    |          page_cache_pipe_buf_release();
       1)               |          touch_atime()
       1) + 95.854 us   |        }
       1) + 99.784 us   |      }
       1) ! 107.393 us  |    }
       1) ! 107.699 us  |  }
      
      Link: https://lkml.kernel.org/r/20220415005015.525191-1-avagin@gmail.com
      Fixes: b964bf53 ("teach sendfile(2) to handle send-to-pipe directly")
      Signed-off-by: NAndrei Vagin <avagin@gmail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      bdeb77bc
  3. 01 7月, 2022 1 次提交
  4. 27 4月, 2022 1 次提交
  5. 14 3月, 2022 2 次提交
  6. 31 1月, 2022 1 次提交
  7. 27 10月, 2021 1 次提交
  8. 24 8月, 2021 1 次提交
  9. 23 8月, 2021 1 次提交
    • J
      fs: remove mandatory file locking support · f7e33bdb
      Jeff Layton 提交于
      We added CONFIG_MANDATORY_FILE_LOCKING in 2015, and soon after turned it
      off in Fedora and RHEL8. Several other distros have followed suit.
      
      I've heard of one problem in all that time: Someone migrated from an
      older distro that supported "-o mand" to one that didn't, and the host
      had a fstab entry with "mand" in it which broke on reboot. They didn't
      actually _use_ mandatory locking so they just removed the mount option
      and moved on.
      
      This patch rips out mandatory locking support wholesale from the kernel,
      along with the Kconfig option and the Documentation file. It also
      changes the mount code to ignore the "mand" mount option instead of
      erroring out, and to throw a big, ugly warning.
      Signed-off-by: NJeff Layton <jlayton@kernel.org>
      f7e33bdb
  10. 26 1月, 2021 1 次提交
  11. 16 10月, 2020 4 次提交
  12. 03 10月, 2020 3 次提交
  13. 30 9月, 2020 1 次提交
    • L
      autofs: use __kernel_write() for the autofs pipe writing · 90fb7027
      Linus Torvalds 提交于
      autofs got broken in some configurations by commit 13c164b1
      ("autofs: switch to kernel_write") because there is now an extra LSM
      permission check done by security_file_permission() in rw_verify_area().
      
      autofs is one if the few places that really does want the much more
      limited __kernel_write(), because the write is an internal kernel one
      that shouldn't do any user permission checks (it also doesn't need the
      file_start_write/file_end_write logic, since it's just a pipe).
      
      There are a couple of other cases like that - accounting, core dumping,
      and splice - but autofs stands out because it can be built as a module.
      
      As a result, we need to export this internal __kernel_write() function
      again.
      
      We really don't want any other module to use this, but we don't have a
      "EXPORT_SYMBOL_FOR_AUTOFS_ONLY()".  But we can mark it GPL-only to at
      least approximate that "internal use only" for licensing.
      
      While in this area, make autofs pass in NULL for the file position
      pointer, since it's always a pipe, and we now use a NULL file pointer
      for streaming file descriptors (see file_ppos() and commit 438ab720:
      "vfs: pass ppos=NULL to .read()/.write() of FMODE_STREAM files")
      
      This effectively reverts commits 9db97752 ("fs: unexport
      __kernel_write") and 13c164b1 ("autofs: switch to kernel_write").
      
      Fixes: 13c164b1 ("autofs: switch to kernel_write")
      Reported-by: NOndrej Mosnacek <omosnace@redhat.com>
      Acked-by: NChristoph Hellwig <hch@lst.de>
      Acked-by: NAcked-by: Ian Kent <raven@themaw.net>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      90fb7027
  14. 25 9月, 2020 1 次提交
  15. 09 9月, 2020 2 次提交
  16. 30 7月, 2020 1 次提交
  17. 08 7月, 2020 7 次提交
  18. 02 4月, 2020 1 次提交
  19. 24 1月, 2020 2 次提交
  20. 17 8月, 2019 1 次提交
  21. 10 6月, 2019 6 次提交