1. 16 5月, 2019 10 次提交
    • D
      rxrpc: Allow the kernel to mark a call as being non-interruptible · b960a34b
      David Howells 提交于
      Allow kernel services using AF_RXRPC to indicate that a call should be
      non-interruptible.  This allows kafs to make things like lock-extension and
      writeback data storage calls non-interruptible.
      
      If this is set, signals will be ignored for operations on that call where
      possible - such as waiting to get a call channel on an rxrpc connection.
      
      It doesn't prevent UDP sendmsg from being interrupted, but that will be
      handled by packet retransmission.
      
      rxrpc_kernel_recv_data() isn't affected by this since that never waits,
      preferring instead to return -EAGAIN and leave the waiting to the caller.
      
      Userspace initiated calls can't be set to be uninterruptible at this time.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      b960a34b
    • D
      afs: Fix error propagation from server record check/update · 0ab4c959
      David Howells 提交于
      afs_check/update_server_record() should be setting fc->error rather than
      fc->ac.error as they're called from within the cursor iteration function.
      
      afs_fs_cursor::error is where the error code of the attempt to call the
      operation on multiple servers is integrated and is the final result,
      whereas afs_addr_cursor::error is used to hold the error from individual
      iterations of the call loop.  (Note there's also an afs_vl_cursor which
      also wraps afs_addr_cursor for accessing VL servers rather than file
      servers).
      
      Fix this by setting fc->error in the afs_check/update_server_record() so
      that any error incurred whilst talking to the VL server correctly
      propagates to the final result.
      
      This results in:
      
      	kAFS: Unexpected error from FS.StoreData -512
      
      being seen, even though the store-data op is non-interruptible.  The error
      is actually coming from the server record update getting interrupted.
      
      Fixes: d2ddc776 ("afs: Overhaul volume and server record caching and fileserver rotation")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      0ab4c959
    • D
      afs: Fix the maximum lifespan of VL and probe calls · 94f699c9
      David Howells 提交于
      If an older AFS server doesn't support an operation, it may accept the call
      and then sit on it forever, happily responding to pings that make kafs
      think that the call is still alive.
      
      Fix this by setting the maximum lifespan of Volume Location service calls
      in particular and probe calls in general so that they don't run on
      endlessly if they're not supported.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      94f699c9
    • D
      afs: Fix "kAFS: AFS vnode with undefined type 0" · 51eba999
      David Howells 提交于
      Under some circumstances afs_select_fileserver() can return without setting
      an error in fc->error.  The problem is in the no_more_servers segment where
      the accumulated errors from attempts to contact various servers are
      integrated into an afs_error-type variable 'e'.  The resultant error code
      is, however, then abandoned.
      
      Fix this by getting the error out of e.error and putting it in 'error' so
      that the next part will store it into fc->error.
      
      Not doing this causes a report like the following:
      
          kAFS: AFS vnode with undefined type 0
          kAFS: A=0 m=0 s=0 v=0
          kAFS: vnode 20000025:1:1
      
      because the code following the server selection loop then sees what it
      thinks is a successful invocation because fc.error is 0.  However, it can't
      apply the status record because it's all zeros.
      
      The report is followed on the first instance with a trace looking something
      like:
      
           dump_stack+0x67/0x8e
           afs_inode_init_from_status.isra.2+0x21b/0x487
           afs_fetch_status+0x119/0x1df
           afs_iget+0x130/0x295
           afs_get_tree+0x31d/0x595
           vfs_get_tree+0x1f/0xe8
           fc_mount+0xe/0x36
           afs_d_automount+0x328/0x3c3
           follow_managed+0x109/0x20a
           lookup_fast+0x3bf/0x3f8
           do_last+0xc3/0x6a4
           path_openat+0x1af/0x236
           do_filp_open+0x51/0xae
           ? _raw_spin_unlock+0x24/0x2d
           ? __alloc_fd+0x1a5/0x1b7
           do_sys_open+0x13b/0x1e8
           do_syscall_64+0x7d/0x1b3
           entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      Fixes: 4584ae96 ("afs: Fix missing net error handling")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      51eba999
    • D
      afs: Fix cell DNS lookup · d5c32c89
      David Howells 提交于
      Currently, once configured, AFS cells are looked up in the DNS at regular
      intervals - which is a waste of resources if those cells aren't being
      used.  It also leads to a problem where cells preloaded, but not
      configured, before the network is brought up end up effectively statically
      configured with no VL servers and are unable to get any.
      
      Fix this by not doing the DNS lookup until the first time a cell is
      touched.  It is waited for if we don't have any cached records yet,
      otherwise the DNS lookup to maintain the record is done in the background.
      
      This has the downside that the first time you touch a cell, you now have to
      wait for the upcall to do the required DNS lookups rather than them already
      being cached.
      
      Further, the record is not replaced if the old record has at least one
      server in it and the new record doesn't have any.
      
      Fixes: 0a5143f2 ("afs: Implement VL server rotation")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      d5c32c89
    • D
      dns_resolver: Allow used keys to be invalidated · d0660f0b
      David Howells 提交于
      Allow used DNS resolver keys to be invalidated after use if the caller is
      doing its own caching of the results.  This reduces the amount of resources
      required.
      
      Fix AFS to invalidate DNS results to kill off permanent failure records
      that get lodged in the resolver keyring and prevent future lookups from
      happening.
      
      Fixes: 0a5143f2 ("afs: Implement VL server rotation")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      d0660f0b
    • D
      afs: Fix afs_cell records to always have a VL server list record · ca1cbbdc
      David Howells 提交于
      Fix it such that afs_cell records always have a VL server list record
      attached, even if it's a dummy one, so that various checks can be removed.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      ca1cbbdc
    • D
      afs: Fix missing lock when replacing VL server list · 6b8812fc
      David Howells 提交于
      When afs_update_cell() replaces the cell->vl_servers list, it uses RCU
      protocol so that proc is protected, but doesn't take ->vl_servers_lock to
      protect afs_start_vl_iteration() (which does actually take a shared lock).
      
      Fix this by making afs_update_cell() take an exclusive lock when replacing
      ->vl_servers.
      
      Fixes: 0a5143f2 ("afs: Implement VL server rotation")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      6b8812fc
    • D
      afs: Fix afs_xattr_get_yfs() to not try freeing an error value · 773e0c40
      David Howells 提交于
      afs_xattr_get_yfs() tries to free yacl, which may hold an error value (say
      if yfs_fs_fetch_opaque_acl() failed and returned an error).
      
      Fix this by allocating yacl up front (since it's a fixed-length struct,
      unlike afs_acl) and passing it in to the RPC function.  This also allows
      the flags to be placed in the object rather than passing them through to
      the RPC function.
      
      Fixes: ae46578b ("afs: Get YFS ACLs and information through xattrs")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      773e0c40
    • D
      afs: Fix incorrect error handling in afs_xattr_get_acl() · cc1dd5c8
      David Howells 提交于
      Fix incorrect error handling in afs_xattr_get_acl() where there appears to
      be a redundant assignment before return, but in fact the return should be a
      goto to the error handling at the end of the function.
      
      Fixes: 260f082b ("afs: Get an AFS3 ACL as an xattr")
      Addresses-Coverity: ("Unused Value")
      Reported-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: Joe Perches <joe@perches.com>
      cc1dd5c8
  2. 15 5月, 2019 1 次提交
    • D
      afs: Fix key leak in afs_release() and afs_evict_inode() · a1b879ee
      David Howells 提交于
      Fix afs_release() to go through the cleanup part of the function if
      FMODE_WRITE is set rather than exiting through vfs_fsync() (which skips the
      cleanup).  The cleanup involves discarding the refs on the key used for
      file ops and the writeback key record.
      
      Also fix afs_evict_inode() to clean up any left over wb keys attached to
      the inode/vnode when it is removed.
      
      Fixes: 5a813276 ("afs: Do better accretion of small writes on newly created content")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      a1b879ee
  3. 07 5月, 2019 11 次提交
    • D
      afs: Implement YFS ACL setting · f5e45463
      David Howells 提交于
      Implement the setting of YFS ACLs in AFS through the interface of setting
      the afs.yfs.acl extended attribute on the file.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      f5e45463
    • D
      afs: Get YFS ACLs and information through xattrs · ae46578b
      David Howells 提交于
      The YFS/AuriStor variant of AFS provides more capable ACLs and provides
      per-volume ACLs and per-file ACLs as well as per-directory ACLs.  It also
      provides some extra information that can be retrieved through four ACLs:
      
       (1) afs.yfs.acl
      
           The YFS file ACL (not the same format as afs.acl).
      
       (2) afs.yfs.vol_acl
      
           The YFS volume ACL.
      
       (3) afs.yfs.acl_inherited
      
           "1" if a file's ACL is inherited from its parent directory, "0"
           otherwise.
      
       (4) afs.yfs.acl_num_cleaned
      
           The number of of ACEs removed from the ACL by the server because the
           PT entries were removed from the PTS database (ie. the subject is no
           longer known).
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      ae46578b
    • J
      afs: implement acl setting · b10494af
      Joe Gorse 提交于
      Implements the setting of ACLs in AFS by means of setting the
      afs.acl extended attribute on the file.
      Signed-off-by: NJoe Gorse <jhgorse@gmail.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      b10494af
    • D
      afs: Get an AFS3 ACL as an xattr · 260f082b
      David Howells 提交于
      Implement an xattr on AFS files called "afs.acl" that retrieves a file's
      ACL.  It returns the raw AFS3 ACL from the result of calling FS.FetchACL,
      leaving any interpretation to userspace.
      
      Note that whilst YFS servers will respond to FS.FetchACL, this will render
      a more-advanced YFS ACL down.  Use "afs.yfs.acl" instead for that.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      260f082b
    • D
      afs: Fix getting the afs.fid xattr · a2f611a3
      David Howells 提交于
      The AFS3 FID is three 32-bit unsigned numbers and is represented as three
      up-to-8-hex-digit numbers separated by colons to the afs.fid xattr.
      However, with the advent of support for YFS, the FID is now a 64-bit volume
      number, a 96-bit vnode/inode number and a 32-bit uniquifier (as before).
      Whilst the sprintf in afs_xattr_get_fid() has been partially updated (it
      currently ignores the upper 32 bits of the 96-bit vnode number), the size
      of the stack-based buffer has not been increased to match, thereby allowing
      stack corruption to occur.
      
      Fix this by increasing the buffer size appropriately and conditionally
      including the upper part of the vnode number if it is non-zero.  The latter
      requires the lower part to be zero-padded if the upper part is non-zero.
      
      Fixes: 3b6492df ("afs: Increase to 64-bit volume ID and 96-bit vnode ID for YFS")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      a2f611a3
    • D
      afs: Fix the afs.cell and afs.volume xattr handlers · c73aa410
      David Howells 提交于
      Fix the ->get handlers for the afs.cell and afs.volume xattrs to pass the
      source data size to memcpy() rather than target buffer size.
      
      Overcopying the source data occasionally causes the kernel to oops.
      
      Fixes: d3e3b7ea ("afs: Add metadata xattrs")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      c73aa410
    • M
      afs: Calculate i_blocks based on file size · c0abbb57
      Marc Dionne 提交于
      While it's not possible to give an accurate number for the blocks
      used on the server, populate i_blocks based on the file size so
      that 'du' can give a reasonable estimate.
      
      The value is rounded up to 1K granularity, for consistency with
      what other AFS clients report, and the servers' 1K usage quota
      unit.  Note that the value calculated by 'du' at the root of a
      volume can still be slightly lower than the quota usage on the
      server, as 0-length files are charged 1 quota block, but are
      reported as occupying 0 blocks.  Again, this is consistent with
      other AFS clients.
      Signed-off-by: NMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      c0abbb57
    • D
      afs: Log more information for "kAFS: AFS vnode with undefined type\n" · b134d687
      David Howells 提交于
      Log more information when "kAFS: AFS vnode with undefined type\n" is
      displayed due to a vnode record being retrieved from the server that
      appears to have a duff file type (usually 0).  This prints more information
      to try and help pin down the problem.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      b134d687
    • S
      io_uring: use cpu_online() to check p->sq_thread_cpu instead of cpu_possible() · 7889f44d
      Shenghui Wang 提交于
      This issue is found by running liburing/test/io_uring_setup test.
      
      When test run, the testcase "attempt to bind to invalid cpu" would not
      pass with messages like:
         io_uring_setup(1, 0xbfc2f7c8), \
      flags: IORING_SETUP_SQPOLL|IORING_SETUP_SQ_AFF, \
      resv: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000, \
      sq_thread_cpu: 2
         expected -1, got 3
         FAIL
      
      On my system, there is:
         CPU(s) possible : 0-3
         CPU(s) online   : 0-1
         CPU(s) offline  : 2-3
         CPU(s) present  : 0-1
      
      The sq_thread_cpu 2 is offline on my system, so the bind should fail.
      But cpu_possible() will pass the check. We shouldn't be able to bind
      to an offline cpu. Use cpu_online() to do the check.
      
      After the change, the testcase run as expected: EINVAL will be returned
      for cpu offlined.
      Reviewed-by: NJeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NShenghui Wang <shhuiw@foxmail.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      7889f44d
    • T
    • C
      io_uring: fix shadowed variable ret return code being not checked · efeb862b
      Colin Ian King 提交于
      Currently variable ret is declared in a while-loop code block that
      shadows another variable ret. When an error occurs in the while-loop
      the error return in ret is not being set in the outer code block and
      so the error check on ret is always going to be checking on the wrong
      ret variable resulting in check that is always going to be true and
      a premature return occurs.
      
      Fix this by removing the declaration of the inner while-loop variable
      ret so that shadowing does not occur.
      
      Addresses-Coverity: ("'Constant' variable guards dead code")
      Fixes: 6b06314c ("io_uring: add file set registration")
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      efeb862b
  4. 06 5月, 2019 1 次提交
    • K
      vfs: pass ppos=NULL to .read()/.write() of FMODE_STREAM files · 438ab720
      Kirill Smelkov 提交于
      This amends commit 10dce8af ("fs: stream_open - opener for
      stream-like files so that read and write can run simultaneously without
      deadlock") in how position is passed into .read()/.write() handler for
      stream-like files:
      
      Rasmus noticed that we currently pass 0 as position and ignore any position
      change if that is done by a file implementation. This papers over bugs if ppos
      is used in files that declare themselves as being stream-like as such bugs will
      go unnoticed. Even if a file implementation is correctly converted into using
      stream_open, its read/write later could be changed to use ppos and even though
      that won't be working correctly, that bug might go unnoticed without someone
      doing wrong behaviour analysis. It is thus better to pass ppos=NULL into
      read/write for stream-like files as that don't give any chance for ppos usage
      bugs because it will oops if ppos is ever used inside .read() or .write().
      
      Note 1: rw_verify_area, new_sync_{read,write} needs to be updated
      because they are called by vfs_read/vfs_write & friends before
      file_operations .read/.write .
      
      Note 2: if file backend uses new-style .read_iter/.write_iter, position
      is still passed into there as non-pointer kiocb.ki_pos . Currently
      stream_open.cocci (semantic patch added by 10dce8af) ignores files
      whose file_operations has *_iter methods.
      Suggested-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Signed-off-by: NKirill Smelkov <kirr@nexedi.com>
      438ab720
  5. 03 5月, 2019 5 次提交
  6. 02 5月, 2019 12 次提交