Skip to content
Snippets Groups Projects
  1. Jul 14, 2023
    • Shyam Prasad N's avatar
      cifs: fix mid leak during reconnection after timeout threshold · 69cba9d3
      Shyam Prasad N authored
      
      When the number of responses with status of STATUS_IO_TIMEOUT
      exceeds a specified threshold (NUM_STATUS_IO_TIMEOUT), we reconnect
      the connection. But we do not return the mid, or the credits
      returned for the mid, or reduce the number of in-flight requests.
      
      This bug could result in the server->in_flight count to go bad,
      and also cause a leak in the mids.
      
      This change moves the check to a few lines below where the
      response is decrypted, even of the response is read from the
      transform header. This way, the code for returning the mids
      can be reused.
      
      Also, the cifs_reconnect was reconnecting just the transport
      connection before. In case of multi-channel, this may not be
      what we want to do after several timeouts. Changed that to
      reconnect the session and the tree too.
      
      Also renamed NUM_STATUS_IO_TIMEOUT to a more appropriate name
      MAX_STATUS_IO_TIMEOUT.
      
      Fixes: 8e670f77 ("Handle STATUS_IO_TIMEOUT gracefully")
      Signed-off-by: default avatarShyam Prasad N <sprasad@microsoft.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      69cba9d3
    • Shyam Prasad N's avatar
      cifs: is_network_name_deleted should return a bool · c071b34f
      Shyam Prasad N authored
      
      Currently, is_network_name_deleted and it's implementations
      do not return anything if the network name did get deleted.
      So the function doesn't fully achieve what it advertizes.
      
      Changed the function to return a bool instead. It will now
      return true if the error returned is STATUS_NETWORK_NAME_DELETED
      and the share (tree id) was found to be connected. It returns
      false otherwise.
      
      Signed-off-by: default avatarShyam Prasad N <sprasad@microsoft.com>
      Acked-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      c071b34f
  2. Jul 13, 2023
    • Paulo Alcantara's avatar
      smb: client: fix missed ses refcounting · bf99f6be
      Paulo Alcantara authored
      
      Use new cifs_smb_ses_inc_refcount() helper to get an active reference
      of @ses and @ses->dfs_root_ses (if set).  This will prevent
      @ses->dfs_root_ses of being put in the next call to cifs_put_smb_ses()
      and thus potentially causing an use-after-free bug.
      
      Fixes: 8e355415 ("cifs: fix sharing of DFS connections")
      Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      bf99f6be
    • Gustavo A. R. Silva's avatar
      smb: client: Fix -Wstringop-overflow issues · f1f047bd
      Gustavo A. R. Silva authored
      pSMB->hdr.Protocol is an array of size 4 bytes, hence when the compiler
      analyzes this line of code
      
      	parm_data = ((char *) &pSMB->hdr.Protocol) + offset;
      
      it legitimately complains about the fact that offset points outside the
      bounds of the array. Notice that the compiler gives priority to the object
      as an array, rather than merely the address of one more byte in a structure
      to wich offset should be added (which seems to be the actual intention of
      the original implementation).
      
      Fix this by explicitly instructing the compiler to treat the code as a
      sequence of bytes in struct smb_com_transaction2_spi_req, and not as an
      array accessed through pointer notation.
      
      Notice that ((char *)pSMB) + sizeof(pSMB->hdr.smb_buf_length) points to
      the same address as ((char *) &pSMB->hdr.Protocol), therefore this results
      in no differences in binary output.
      
      Fixes the following -Wstringop-overflow warnings when built s390
      architecture with defconfig (GCC 13):
        CC [M]  fs/smb/client/cifssmb.o
      In function 'cifs_init_ace',
          inlined from 'posix_acl_to_cifs' at fs/smb/client/cifssmb.c:3046:3,
          inlined from 'cifs_do_set_acl' at fs/smb/client/cifssmb.c:3191:15:
      fs/smb/client/cifssmb.c:2987:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
       2987 |         cifs_ace->cifs_e_perm = local_ace->e_perm;
            |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
      In file included from fs/smb/client/cifssmb.c:27:
      fs/smb/client/cifspdu.h: In function 'cifs_do_set_acl':
      fs/smb/client/cifspdu.h:384:14: note: at offset [7, 11] into destination object 'Protocol' of size 4
        384 |         __u8 Protocol[4];
            |              ^~~~~~~~
      In function 'cifs_init_ace',
          inlined from 'posix_acl_to_cifs' at fs/smb/client/cifssmb.c:3046:3,
          inlined from 'cifs_do_set_acl' at fs/smb/client/cifssmb.c:3191:15:
      fs/smb/client/cifssmb.c:2988:30: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
       2988 |         cifs_ace->cifs_e_tag =  local_ace->e_tag;
            |         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
      fs/smb/client/cifspdu.h: In function 'cifs_do_set_acl':
      fs/smb/client/cifspdu.h:384:14: note: at offset [6, 10] into destination object 'Protocol' of size 4
        384 |         __u8 Protocol[4];
            |              ^~~~~~~~
      
      This helps with the ongoing efforts to globally enable
      -Wstringop-overflow.
      
      Link: https://github.com/KSPP/linux/issues/310
      
      
      Fixes: dc1af4c4 ("cifs: implement set acl method")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      f1f047bd
  3. Jul 11, 2023
  4. Jul 10, 2023
  5. Jul 08, 2023
  6. Jul 06, 2023
  7. Jul 04, 2023
  8. Jul 03, 2023
    • Bob Peterson's avatar
      gfs2: Add quota_change type · 432928c9
      Bob Peterson authored
      
      Function do_qc has two main uses: (1) to re-sync the local quota changes
      (qd) to the master quotas, and (2) normal quota changes. In the case of
      normal quota changes, the change can be positive or negative, as the
      quota usage goes up and down.
      
      Before this patch function do_qc was distinguishing one from another by
      whether the resulting value is or isn't zero: In the case of a re-sync
      (called do_sync) the quota value is moved from the temporary value to a
      master value, so the amount is added to one and subtracted from the
      other. The problem is that since the values can be positive or negative
      we can occasionally run into situations where we are not doing a re-sync
      but the quota change just happens to cancel out the previous value.
      
      In the case of a re-sync extra references and locks are taken, and so
      do_qc needs to release them. In the case of a normal quota change, no
      extra references and locks are taken, so it must not try to release
      them.
      
      The problem is: if the quota change is not a re-sync but the value just
      happens to cancel out the original quota change, the resulting zero
      value fools do_qc into thinking this is a re-sync and therefore it must
      release the extra references. This results in problems, mainly having to
      do with slot reference numbers going smaller than zero.
      
      This patch introduces new constants, QC_SYNC and QC_CHANGE so do_qc can
      really tell the difference. For QC_SYNC calls it must release the extra
      references acquired by gfs2_quota_unlock's call to qd_check_sync. For
      QC_CHANGE calls it does not have extra references to put.
      
      Note that this allows quota changes back to a value of zero, and so I
      removed an assert warning related to that.
      
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      432928c9
    • Andreas Gruenbacher's avatar
      gfs2: Use memcpy_{from,to}_page where appropriate · d68d0c6c
      Andreas Gruenbacher authored
      
      Replace kmap_local_page() + memcpy() + kunmap_local() sequences with
      memcpy_{from,to}_page() where we are not doing anything else with the
      mapped page.
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      d68d0c6c
    • Andreas Gruenbacher's avatar
      gfs2: Convert remaining kmap_atomic calls to kmap_local_page · b0c21c6d
      Andreas Gruenbacher authored
      
      Replace the remaining instances of kmap_atomic() ... kunmap_atomic()
      with kmap_local_page() ... kunmap_local().
      
      In gfs2_write_buf_to_page(), we can call flush_dcache_page() after
      unmapping the page.
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      b0c21c6d
    • Deepak R Varma's avatar
      gfs2: Replace deprecated kmap_atomic with kmap_local_page · 58721bd4
      Deepak R Varma authored
      
      kmap_atomic() is deprecated in favor of kmap_local_{folio,page}().
      
      Therefore, replace kmap_atomic() with kmap_local_page() in
      gfs2_internal_read() and stuffed_readpage().
      
      kmap_atomic() disables page-faults and preemption (the latter only for
      !PREEMPT_RT kernels), However, the code within the mapping/un-mapping in
      gfs2_internal_read() and stuffed_readpage() does not depend on the
      above-mentioned side effects.
      
      Therefore, a mere replacement of the old API with the new one is all that
      is required (i.e., there is no need to explicitly add any calls to
      pagefault_disable() and/or preempt_disable()).
      
      Signed-off-by: default avatarDeepak R Varma <drv@mailo.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      58721bd4
    • Andreas Gruenbacher's avatar
      gfs: Get rid of unnucessary locking in inode_go_dump · f246dd4b
      Andreas Gruenbacher authored
      
      Commit 27a2660f ("gfs2: Dump nrpages for inodes and their glocks")
      added some locking around reading inode->i_data.nrpages.  That locking
      doesn't do anything really, so get rid of it.
      
      With that, the glock argument to ->go_dump() can be made const again as
      well.
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      f246dd4b
    • Andreas Gruenbacher's avatar
      gfs2: gfs2_freeze_lock_shared cleanup · 6c7410f4
      Andreas Gruenbacher authored
      
      All the remaining users of gfs2_freeze_lock_shared() set freeze_gh to
      &sdp->sd_freeze_gh and flags to 0, so remove those two parameters.
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      6c7410f4
    • Andreas Gruenbacher's avatar
      gfs2: Replace sd_freeze_state with SDF_FROZEN flag · 5432af15
      Andreas Gruenbacher authored
      
      Replace sd_freeze_state with a new SDF_FROZEN flag.
      
      There no longer is a need for indicating that a freeze is in progress
      (SDF_STARTING_FREEZE); we are now protecting the critical sections with
      the sd_freeze_mutex.
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      5432af15
    • Andreas Gruenbacher's avatar
      gfs2: Rework freeze / thaw logic · b77b4a48
      Andreas Gruenbacher authored
      
      So far, at mount time, gfs2 would take the freeze glock in shared mode
      and then immediately drop it again, turning it into a cached glock that
      can be reclaimed at any time.  To freeze the filesystem cluster-wide,
      the node initiating the freeze would take the freeze glock in exclusive
      mode, which would cause the freeze glock's freeze_go_sync() callback to
      run on each node.  There, gfs2 would freeze the filesystem and schedule
      gfs2_freeze_func() to run.  gfs2_freeze_func() would re-acquire the
      freeze glock in shared mode, thaw the filesystem, and drop the freeze
      glock again.  The initiating node would keep the freeze glock held in
      exclusive mode.  To thaw the filesystem, the initiating node would drop
      the freeze glock again, which would allow gfs2_freeze_func() to resume
      on all nodes, leaving the filesystem in the thawed state.
      
      It turns out that in freeze_go_sync(), we cannot reliably and safely
      freeze the filesystem.  This is primarily because the final unmount of a
      filesystem takes a write lock on the s_umount rw semaphore before
      calling into gfs2_put_super(), and freeze_go_sync() needs to call
      freeze_super() which also takes a write lock on the same semaphore,
      causing a deadlock.  We could work around this by trying to take an
      active reference on the super block first, which would prevent unmount
      from running at the same time.  But that can fail, and freeze_go_sync()
      isn't actually allowed to fail.
      
      To get around this, this patch changes the freeze glock locking scheme
      as follows:
      
      At mount time, each node takes the freeze glock in shared mode.  To
      freeze a filesystem, the initiating node first freezes the filesystem
      locally and then drops and re-acquires the freeze glock in exclusive
      mode.  All other nodes notice that there is contention on the freeze
      glock in their go_callback callbacks, and they schedule
      gfs2_freeze_func() to run.  There, they freeze the filesystem locally
      and drop and re-acquire the freeze glock before re-thawing the
      filesystem.  This is happening outside of the glock state engine, so
      there, we are allowed to fail.
      
      From a cluster point of view, taking and immediately dropping a glock is
      indistinguishable from taking the glock and only dropping it upon
      contention, so this new scheme is compatible with the old one.
      
      Thanks to Li Dong <lidong@vivo.com> for reporting a locking bug in
      gfs2_freeze_func() in a previous version of this commit.
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      b77b4a48
    • Yang Li's avatar
      xfs: Remove unneeded semicolon · 34acceaa
      Yang Li authored
      
      ./fs/xfs/xfs_extfree_item.c:723:3-4: Unneeded semicolon
      
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5728
      
      
      Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      34acceaa
    • Darrick J. Wong's avatar
      xfs: AGI length should be bounds checked · 2d7d1e7e
      Darrick J. Wong authored
      
      Similar to the recent patch strengthening the AGF agf_length
      verification, the AGI verifier does not check that the AGI length field
      is within known good bounds.  This isn't currently checked by runtime
      kernel code, yet we assume in many places that it is correct and verify
      other metadata against it.
      
      Add length verification to the AGI verifier.  Just like the AGF length
      checking, the length of the AGI must be equal to the size of the AG
      specified in the superblock, unless it is the last AG in the filesystem.
      In that case, it must be less than or equal to sb->sb_agblocks and
      greater than XFS_MIN_AG_BLOCKS, which is the smallest AG a growfs
      operation will allow to exist.
      
      There's only one place in the filesystem that actually uses agi_length,
      but let's not leave it vulnerable to the same weird nonsense that
      generates syzbot bugs, eh?
      
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      2d7d1e7e
    • Christian Brauner's avatar
      ovl: move all parameter handling into params.{c,h} · 7fb7998b
      Christian Brauner authored
      
      While initially I thought that we couldn't move all new mount api
      handling into params.{c,h} it turns out it is possible. So this just
      moves a good chunk of code out of super.c and into params.{c,h}.
      
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      7fb7998b
  9. Jul 02, 2023
Loading