1. 26 Sep, 2022 1 commit
  2. 23 Aug, 2022 15 commits
    • Alexander Aring's avatar
      fs: dlm: const void resource name parameter · 56171e0d
      Alexander Aring authored
      The resource name parameter should never be changed by DLM so we declare
      it as const. At some point it is handled as a char pointer, a resource
      name can be a non printable ascii string as well. This patch change it
      to handle it as void pointer as it is offered by DLM API.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      56171e0d
    • Alexander Aring's avatar
      fs: dlm: LSFL_CB_DELAY only for kernel lockspaces · 9cb16d42
      Alexander Aring authored
      This patch only set/clear the LSFL_CB_DELAY bit when it's actually a
      kernel lockspace signaled by if ls->ls_callback_wq is set or not set in
      this case. User lockspaces will never evaluate this flag.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      9cb16d42
    • Alexander Aring's avatar
      fs: dlm: remove DLM_LSFL_FS from uapi · 12cda13c
      Alexander Aring authored
      The DLM_LSFL_FS flag is set in lockspaces created directly
      for a kernel user, as opposed to those lockspaces created
      for user space applications.  The user space libdlm allowed
      this flag to be set for lockspaces created from user space,
      but then used by a kernel user.  No kernel user has ever
      used this method, so remove the ability to do it.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      12cda13c
    • Alexander Aring's avatar
      fs: dlm: trace user space callbacks · 7a3de732
      Alexander Aring authored
      This patch adds trace callbacks for user locks. Unfortenately user locks
      are handled in a different way than kernel locks in some cases. User
      locks never call the dlm_lock()/dlm_unlock() kernel API and use the next
      step internal API of dlm. Adding those traces from user API callers
      should make it possible for dlm trace system to see lock handling for
      user locks as well.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      7a3de732
    • Alexander Aring's avatar
      fs: dlm: change ls_clear_proc_locks to spinlock · 296d9d1e
      Alexander Aring authored
      This patch changes the ls_clear_proc_locks to a spinlock because there
      is no need to handle it as a mutex as there is no sleepable context when
      ls_clear_proc_locks is held. This allows us to call those functionality
      in non-sleepable contexts.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      296d9d1e
    • Alexander Aring's avatar
      fs: dlm: remove dlm_del_ast prototype · e152c38d
      Alexander Aring authored
      This patch removes dlm_del_ast() prototype which is not being used in
      the dlm subsystem because there is not implementation for it.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      e152c38d
    • Alexander Aring's avatar
      fs: dlm: handle rcom in else if branch · f45307d3
      Alexander Aring authored
      Currently we handle in dlm_receive_buffer() everything else than a
      DLM_MSG type as DLM_RCOM message. Although a different message than
      DLM_MSG should be a DLM_RCOM we should explicit check on DLM_RCOM and
      drop a log_error() if we see something unexpected.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      f45307d3
    • Alexander Aring's avatar
      fs: dlm: allow lockspaces have zero lvblen · b5c9d37c
      Alexander Aring authored
      A dlm user may not use the DLM_LKF_VALBLK flag in the DLM API,
      so a zero lvblen should be allowed as a lockspace parameter.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      b5c9d37c
    • Alexander Aring's avatar
      fs: dlm: fix invalid derefence of sb_lvbptr · 7175e131
      Alexander Aring authored
      I experience issues when putting a lkbsb on the stack and have sb_lvbptr
      field to a dangled pointer while not using DLM_LKF_VALBLK. It will crash
      with the following kernel message, the dangled pointer is here
      0xdeadbeef as example:
      
      [  102.749317] BUG: unable to handle page fault for address: 00000000deadbeef
      [  102.749320] #PF: supervisor read access in kernel mode
      [  102.749323] #PF: error_code(0x0000) - not-present page
      [  102.749325] PGD 0 P4D 0
      [  102.749332] Oops: 0000 [#1] PREEMPT SMP PTI
      [  102.749336] CPU: 0 PID: 1567 Comm: lock_torture_wr Tainted: G        W         5.19.0-rc3+ #1565
      [  102.749343] Hardware name: Red Hat KVM/RHEL-AV, BIOS 1.16.0-2.module+el8.7.0+15506+033991b0 04/01/2014
      [  102.749344] RIP: 0010:memcpy_erms+0x6/0x10
      [  102.749353] Code: cc cc cc cc eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1 <f3> a4 c3 0f 1f 80 00 00 00 00 48 89 f8 48 83 fa 20 72 7e 40 38 fe
      [  102.749355] RSP: 0018:ffff97a58145fd08 EFLAGS: 00010202
      [  102.749358] RAX: ffff901778b77070 RBX: 0000000000000000 RCX: 0000000000000040
      [  102.749360] RDX: 0000000000000040 RSI: 00000000deadbeef RDI: ffff901778b77070
      [  102.749362] RBP: ffff97a58145fd10 R08: ffff901760b67a70 R09: 0000000000000001
      [  102.749364] R10: ffff9017008e2cb8 R11: 0000000000000001 R12: ffff901760b67a70
      [  102.749366] R13: ffff901760b78f00 R14: 0000000000000003 R15: 0000000000000001
      [  102.749368] FS:  0000000000000000(0000) GS:ffff901876e00000(0000) knlGS:0000000000000000
      [  102.749372] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  102.749374] CR2: 00000000deadbeef CR3: 000000017c49a004 CR4: 0000000000770ef0
      [  102.749376] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  102.749378] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  102.749379] PKRU: 55555554
      [  102.749381] Call Trace:
      [  102.749382]  <TASK>
      [  102.749383]  ? send_args+0xb2/0xd0
      [  102.749389]  send_common+0xb7/0xd0
      [  102.749395]  _unlock_lock+0x2c/0x90
      [  102.749400]  unlock_lock.isra.56+0x62/0xa0
      [  102.749405]  dlm_unlock+0x21e/0x330
      [  102.749411]  ? lock_torture_stats+0x80/0x80 [dlm_locktorture]
      [  102.749416]  torture_unlock+0x5a/0x90 [dlm_locktorture]
      [  102.749419]  ? preempt_count_sub+0xba/0x100
      [  102.749427]  lock_torture_writer+0xbd/0x150 [dlm_locktorture]
      [  102.786186]  kthread+0x10a/0x130
      [  102.786581]  ? kthread_complete_and_exit+0x20/0x20
      [  102.787156]  ret_from_fork+0x22/0x30
      [  102.787588]  </TASK>
      [  102.787855] Modules linked in: dlm_locktorture torture rpcsec_gss_krb5 intel_rapl_msr intel_rapl_common kvm_intel iTCO_wdt iTCO_vendor_support kvm vmw_vsock_virtio_transport qxl irqbypass vmw_vsock_virtio_transport_common drm_ttm_helper crc32_pclmul joydev crc32c_intel ttm vsock virtio_scsi virtio_balloon snd_pcm drm_kms_helper virtio_console snd_timer snd drm soundcore syscopyarea i2c_i801 sysfillrect sysimgblt i2c_smbus pcspkr fb_sys_fops lpc_ich serio_raw
      [  102.792536] CR2: 00000000deadbeef
      [  102.792930] ---[ end trace 0000000000000000 ]---
      
      This patch fixes the issue by checking also on DLM_LKF_VALBLK on exflags
      is set when copying the lvbptr array instead of if it's just null which
      fixes for me the issue.
      
      I think this patch can fix other dlm users as well, depending how they
      handle the init, freeing memory handling of sb_lvbptr and don't set
      DLM_LKF_VALBLK for some dlm_lock() calls. It might a there could be a
      hidden issue all the time. However with checking on DLM_LKF_VALBLK the
      user always need to provide a sb_lvbptr non-null value. There might be
      more intelligent handling between per ls lvblen, DLM_LKF_VALBLK and
      non-null to report the user the way how DLM API is used is wrong but can
      be added for later, this will only fix the current behaviour.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      7175e131
    • Alexander Aring's avatar
      fs: dlm: handle -EINVAL as log_error() · 9ac8ba46
      Alexander Aring authored
      If the user generates -EINVAL it's probably because they are
      using DLM incorrectly.  Change the log level to make these
      errors more visible.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      9ac8ba46
    • Alexander Aring's avatar
      fs: dlm: use __func__ for function name · c2d76a62
      Alexander Aring authored
      Avoid hard-coded function names inside message format strings.
      (Prevents checkpatch warnings.)
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      c2d76a62
    • Alexander Aring's avatar
      fs: dlm: handle -EBUSY first in unlock validation · 420ba3cd
      Alexander Aring authored
      This patch checks for -EBUSY conditions in dlm_unlock() before
      checking for -EINVAL conditions (except for CANCEL and
      FORCEUNLOCK calls where a busy condition is expected.)
      There are no problems with the current ordering of checks,
      but this makes dlm_unlock() consistent with dlm_lock(), and
      may avoid future problems if other checks are added.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      420ba3cd
    • Alexander Aring's avatar
      fs: dlm: handle -EBUSY first in lock arg validation · 44637ca4
      Alexander Aring authored
      During lock arg validation, first check for -EBUSY cases, then for
      -EINVAL cases. The -EINVAL checks look at lkb state variables
      which are not stable when an lkb is busy and would cause an
      -EBUSY result, e.g. lkb->lkb_grmode.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      44637ca4
    • Alexander Aring's avatar
      fs: dlm: fix race between test_bit() and queue_work() · eef6ec9b
      Alexander Aring authored
      This patch fixes a race by using ls_cb_mutex around the bit
      operations and conditional code blocks for LSFL_CB_DELAY.
      
      The function dlm_callback_stop() expects to stop all callbacks and
      flush all currently queued onces. The set_bit() is not enough because
      there can still be queue_work() after the workqueue was flushed.
      To avoid queue_work() after set_bit(), surround both by ls_cb_mutex.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      eef6ec9b
    • Alexander Aring's avatar
      fs: dlm: fix race in lowcomms · 30ea3257
      Alexander Aring authored
      This patch fixes a race between queue_work() in
      _dlm_lowcomms_commit_msg() and srcu_read_unlock(). The queue_work() can
      take the final reference of a dlm_msg and so msg->idx can contain
      garbage which is signaled by the following warning:
      
      [  676.237050] ------------[ cut here ]------------
      [  676.237052] WARNING: CPU: 0 PID: 1060 at include/linux/srcu.h:189 dlm_lowcomms_commit_msg+0x41/0x50
      [  676.238945] Modules linked in: dlm_locktorture torture rpcsec_gss_krb5 intel_rapl_msr intel_rapl_common iTCO_wdt iTCO_vendor_support qxl kvm_intel drm_ttm_helper vmw_vsock_virtio_transport kvm vmw_vsock_virtio_transport_common ttm irqbypass crc32_pclmul joydev crc32c_intel serio_raw drm_kms_helper vsock virtio_scsi virtio_console virtio_balloon snd_pcm drm syscopyarea sysfillrect sysimgblt snd_timer fb_sys_fops i2c_i801 lpc_ich snd i2c_smbus soundcore pcspkr
      [  676.244227] CPU: 0 PID: 1060 Comm: lock_torture_wr Not tainted 5.19.0-rc3+ #1546
      [  676.245216] Hardware name: Red Hat KVM/RHEL-AV, BIOS 1.16.0-2.module+el8.7.0+15506+033991b0 04/01/2014
      [  676.246460] RIP: 0010:dlm_lowcomms_commit_msg+0x41/0x50
      [  676.247132] Code: fe ff ff ff 75 24 48 c7 c6 bd 0f 49 bb 48 c7 c7 38 7c 01 bd e8 00 e7 ca ff 89 de 48 c7 c7 60 78 01 bd e8 42 3d cd ff 5b 5d c3 <0f> 0b eb d8 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48
      [  676.249253] RSP: 0018:ffffa401c18ffc68 EFLAGS: 00010282
      [  676.249855] RAX: 0000000000000001 RBX: 00000000ffff8b76 RCX: 0000000000000006
      [  676.250713] RDX: 0000000000000000 RSI: ffffffffbccf3a10 RDI: ffffffffbcc7b62e
      [  676.251610] RBP: ffffa401c18ffc70 R08: 0000000000000001 R09: 0000000000000001
      [  676.252481] R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000005
      [  676.253421] R13: ffff8b76786ec370 R14: ffff8b76786ec370 R15: ffff8b76786ec480
      [  676.254257] FS:  0000000000000000(0000) GS:ffff8b7777800000(0000) knlGS:0000000000000000
      [  676.255239] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  676.255897] CR2: 00005590205d88b8 CR3: 000000017656c003 CR4: 0000000000770ee0
      [  676.256734] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  676.257567] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  676.258397] PKRU: 55555554
      [  676.258729] Call Trace:
      [  676.259063]  <TASK>
      [  676.259354]  dlm_midcomms_commit_mhandle+0xcc/0x110
      [  676.259964]  queue_bast+0x8b/0xb0
      [  676.260423]  grant_pending_locks+0x166/0x1b0
      [  676.261007]  _unlock_lock+0x75/0x90
      [  676.261469]  unlock_lock.isra.57+0x62/0xa0
      [  676.262009]  dlm_unlock+0x21e/0x330
      [  676.262457]  ? lock_torture_stats+0x80/0x80 [dlm_locktorture]
      [  676.263183]  torture_unlock+0x5a/0x90 [dlm_locktorture]
      [  676.263815]  ? preempt_count_sub+0xba/0x100
      [  676.264361]  ? complete+0x1d/0x60
      [  676.264777]  lock_torture_writer+0xb8/0x150 [dlm_locktorture]
      [  676.265555]  kthread+0x10a/0x130
      [  676.266007]  ? kthread_complete_and_exit+0x20/0x20
      [  676.266616]  ret_from_fork+0x22/0x30
      [  676.267097]  </TASK>
      [  676.267381] irq event stamp: 9579855
      [  676.267824] hardirqs last  enabled at (9579863): [<ffffffffbb14e6f8>] __up_console_sem+0x58/0x60
      [  676.268896] hardirqs last disabled at (9579872): [<ffffffffbb14e6dd>] __up_console_sem+0x3d/0x60
      [  676.270008] softirqs last  enabled at (9579798): [<ffffffffbc200349>] __do_softirq+0x349/0x4c7
      [  676.271438] softirqs last disabled at (9579897): [<ffffffffbb0d54c0>] irq_exit_rcu+0xb0/0xf0
      [  676.272796] ---[ end trace 0000000000000000 ]---
      
      I reproduced this warning with dlm_locktorture test which is currently
      not upstream. However this patch fix the issue by make a additional
      refcount between dlm_lowcomms_new_msg() and dlm_lowcomms_commit_msg().
      In case of the race the kref_put() in dlm_lowcomms_commit_msg() will be
      the final put.
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      30ea3257
  3. 22 Aug, 2022 1 commit
  4. 21 Aug, 2022 17 commits
  5. 20 Aug, 2022 6 commits
    • Linus Torvalds's avatar
      Merge tag 'kbuild-fixes-v6.0' of... · 15b3f48a
      Linus Torvalds authored
      Merge tag 'kbuild-fixes-v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
      
      Pull Kbuild fixes from Masahiro Yamada:
      
       - Fix module versioning broken on some architectures
      
       - Make dummy-tools enable CONFIG_PPC_LONG_DOUBLE_128
      
       - Remove -Wformat-zero-length, which has no warning instance
      
       - Fix the order between drivers and libs in modules.order
      
       - Fix false-positive warnings in clang-analyzer
      
      * tag 'kbuild-fixes-v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
        scripts/clang-tools: Remove DeprecatedOrUnsafeBufferHandling check
        kbuild: fix the modules order between drivers and libs
        scripts/Makefile.extrawarn: Do not disable clang's -Wformat-zero-length
        kbuild: dummy-tools: pretend we understand __LONG_DOUBLE_128__
        modpost: fix module versioning when a symbol lacks valid CRC
      15b3f48a
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v6.0-2022-08-19' of... · 16b3d851
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v6.0-2022-08-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Fix alignment for cpu map masks in event encoding.
      
       - Support reading PERF_FORMAT_LOST, perf tool counterpart for a feature
         that was added in this merge window.
      
       - Sync perf tools copies of kernel headers: socket, msr-index, fscrypt,
         cpufeatures, i915_drm, kvm, vhost, perf_event.
      
      * tag 'perf-tools-fixes-for-v6.0-2022-08-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf tools: Support reading PERF_FORMAT_LOST
        libperf: Add a test case for read formats
        libperf: Handle read format in perf_evsel__read()
        tools headers UAPI: Sync linux/perf_event.h with the kernel sources
        tools headers UAPI: Sync x86's asm/kvm.h with the kernel sources
        tools headers UAPI: Sync KVM's vmx.h header with the kernel sources
        tools include UAPI: Sync linux/vhost.h with the kernel sources
        tools headers kvm s390: Sync headers with the kernel sources
        tools headers UAPI: Sync linux/kvm.h with the kernel sources
        tools headers UAPI: Sync drm/i915_drm.h with the kernel sources
        tools headers cpufeatures: Sync with the kernel sources
        tools headers UAPI: Sync linux/fscrypt.h with the kernel sources
        tools arch x86: Sync the msr-index.h copy with the kernel sources
        perf beauty: Update copy of linux/socket.h with the kernel sources
        perf cpumap: Fix alignment for masks in event encoding
        perf cpumap: Compute mask size in constant time
        perf cpumap: Synthetic events and const/static
        perf cpumap: Const map for max()
      16b3d851
    • Linus Torvalds's avatar
      Merge tag 's390-6.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux · cc1807b9
      Linus Torvalds authored
      Pull s390 updates from Alexander Gordeev:
      
       - Fix a KVM crash on z12 and older machines caused by a wrong
         assumption that Query AP Configuration Information is always
         available.
      
       - Lower severity of excessive Hypervisor filesystem error messages
         when booting under KVM.
      
      * tag 's390-6.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
        s390/ap: fix crash on older machines based on QCI info missing
        s390/hypfs: avoid error message under KVM
      cc1807b9
    • Linus Torvalds's avatar
      Merge tag 'powerpc-6.0-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · 32dd68f1
      Linus Torvalds authored
      Pull powerpc fixes from Michael Ellerman:
      
       - Fix atomic sleep warnings at boot due to get_phb_number() taking a
         mutex with a spinlock held on some machines.
      
       - Add missing PMU selftests to .gitignores.
      
      Thanks to Guenter Roeck and Russell Currey.
      
      * tag 'powerpc-6.0-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
        selftests/powerpc: Add missing PMU selftests to .gitignores
        powerpc/pci: Fix get_phb_number() locking
      32dd68f1
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · f31c32ef
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "A few minor fixes:
      
         - Fix buffer management in SRP to correct a regression with the login
           authentication feature from v5.17
      
         - Don't iterate over non-present ports in mlx5
      
         - Fix an error introduced by the foritify work in cxgb4
      
         - Two bug fixes for the recently merged ERDMA driver
      
         - Unbreak RDMA dmabuf support, a regresion from v5.19"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA: Handle the return code from dma_resv_wait_timeout() properly
        RDMA/erdma: Correct the max_qp and max_cq capacities of the device
        RDMA/erdma: Using the key in FMR WR instead of MR structure
        RDMA/cxgb4: fix accept failure due to increased cpl_t5_pass_accept_rpl size
        RDMA/mlx5: Use the proper number of ports
        IB/iser: Fix login with authentication
      f31c32ef
    • Guru Das Srinagesh's avatar
      scripts/clang-tools: Remove DeprecatedOrUnsafeBufferHandling check · 4be72c1b
      Guru Das Srinagesh authored
      This `clang-analyzer` check flags the use of memset(), suggesting a more
      secure version of the API, such as memset_s(), which does not exist in
      the kernel:
      
        warning: Call to function 'memset' is insecure as it does not provide
        security checks introduced in the C11 standard. Replace with analogous
        functions that support length arguments or provides boundary checks such
        as 'memset_s' in case of C11
        [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
      Signed-off-by: default avatarGuru Das Srinagesh <quic_gurus@quicinc.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      4be72c1b