1. Jan 04, 2024
    • Benjamin Coddington's avatar
      NFSv4: Always ask for type with READDIR · b4d4fd60
      Benjamin Coddington authored
      
      
      Again we have claimed regressions for walking a directory tree, this time
      with the "find" utility which always tries to optimize away asking for any
      attributes until it has a complete list of entries.  This behavior makes
      the readdir plus heuristic do the wrong thing, which causes a storm of
      GETATTRs to determine each entry's type in order to continue the walk.
      
      For v4 add the type attribute to each READDIR request to include it no
      matter the heuristic.  This allows a simple `find` command to proceed
      quickly through a directory tree.
      
      Suggested-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      b4d4fd60
    • Benjamin Coddington's avatar
      pnfs/blocklayout: Don't add zero-length pnfs_block_dev · d76c769c
      Benjamin Coddington authored
      
      
      We noticed a SCSI device that refused to allow READ CAPACITY when the
      device had a PR with exclusive access, registrants only.  The result of
      this situation is that the blocklayout driver adds a pnfs_block_dev of zero
      length which always fails the offset_in_map tests.  Instead of continuously
      trying to do pNFS for this case, just mark the device as unavailable which
      will allow the client to fallback to the MDS for the duration of
      PNFS_DEVICE_RETRY_TIMEOUT.
      
      Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      d76c769c
    • Benjamin Coddington's avatar
      blocklayoutdriver: Fix reference leak of pnfs_device_node · 1530827b
      Benjamin Coddington authored
      The error path for blocklayout's device lookup is missing a reference drop
      for the case where a lookup finds the device, but the device is marked with
      NFS_DEVICEID_UNAVAILABLE.
      
      Fixes: b3dce6a2
      
       ("pnfs/blocklayout: handle transient devices")
      Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      1530827b
    • Anna Schumaker's avatar
      SUNRPC: Fix a suspicious RCU usage warning · 31b62908
      Anna Schumaker authored
      I received the following warning while running cthon against an ontap
      server running pNFS:
      
      [   57.202521] =============================
      [   57.202522] WARNING: suspicious RCU usage
      [   57.202523] 6.7.0-rc3-g2cc14f52 #41492 Not tainted
      [   57.202525] -----------------------------
      [   57.202525] net/sunrpc/xprtmultipath.c:349 RCU-list traversed in non-reader section!!
      [   57.202527]
                     other info that might help us debug this:
      
      [   57.202528]
                     rcu_scheduler_active = 2, debug_locks = 1
      [   57.202529] no locks held by test5/3567.
      [   57.202530]
                     stack backtrace:
      [   57.202532] CPU: 0 PID: 3567 Comm: test5 Not tainted 6.7.0-rc3-g2cc14f52
      
       #41492 5b09971b4965c0aceba19f3eea324a4a806e227e
      [   57.202534] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 2/2/2022
      [   57.202536] Call Trace:
      [   57.202537]  <TASK>
      [   57.202540]  dump_stack_lvl+0x77/0xb0
      [   57.202551]  lockdep_rcu_suspicious+0x154/0x1a0
      [   57.202556]  rpc_xprt_switch_has_addr+0x17c/0x190 [sunrpc ebe02571b9a8ceebf7d98e71675af20c19bdb1f6]
      [   57.202596]  rpc_clnt_setup_test_and_add_xprt+0x50/0x180 [sunrpc ebe02571b9a8ceebf7d98e71675af20c19bdb1f6]
      [   57.202621]  ? rpc_clnt_add_xprt+0x254/0x300 [sunrpc ebe02571b9a8ceebf7d98e71675af20c19bdb1f6]
      [   57.202646]  rpc_clnt_add_xprt+0x27a/0x300 [sunrpc ebe02571b9a8ceebf7d98e71675af20c19bdb1f6]
      [   57.202671]  ? __pfx_rpc_clnt_setup_test_and_add_xprt+0x10/0x10 [sunrpc ebe02571b9a8ceebf7d98e71675af20c19bdb1f6]
      [   57.202696]  nfs4_pnfs_ds_connect+0x345/0x760 [nfsv4 c716d88496ded0ea6d289bbea684fa996f9b57a9]
      [   57.202728]  ? __pfx_nfs4_test_session_trunk+0x10/0x10 [nfsv4 c716d88496ded0ea6d289bbea684fa996f9b57a9]
      [   57.202754]  nfs4_fl_prepare_ds+0x75/0xc0 [nfs_layout_nfsv41_files e3a4187f18ae8a27b630f9feae6831b584a9360a]
      [   57.202760]  filelayout_write_pagelist+0x4a/0x200 [nfs_layout_nfsv41_files e3a4187f18ae8a27b630f9feae6831b584a9360a]
      [   57.202765]  pnfs_generic_pg_writepages+0xbe/0x230 [nfsv4 c716d88496ded0ea6d289bbea684fa996f9b57a9]
      [   57.202788]  __nfs_pageio_add_request+0x3fd/0x520 [nfs 6c976fa593a7c2976f5a0aeb4965514a828e6902]
      [   57.202813]  nfs_pageio_add_request+0x18b/0x390 [nfs 6c976fa593a7c2976f5a0aeb4965514a828e6902]
      [   57.202831]  nfs_do_writepage+0x116/0x1e0 [nfs 6c976fa593a7c2976f5a0aeb4965514a828e6902]
      [   57.202849]  nfs_writepages_callback+0x13/0x30 [nfs 6c976fa593a7c2976f5a0aeb4965514a828e6902]
      [   57.202866]  write_cache_pages+0x265/0x450
      [   57.202870]  ? __pfx_nfs_writepages_callback+0x10/0x10 [nfs 6c976fa593a7c2976f5a0aeb4965514a828e6902]
      [   57.202891]  nfs_writepages+0x141/0x230 [nfs 6c976fa593a7c2976f5a0aeb4965514a828e6902]
      [   57.202913]  do_writepages+0xd2/0x230
      [   57.202917]  ? filemap_fdatawrite_wbc+0x5c/0x80
      [   57.202921]  filemap_fdatawrite_wbc+0x67/0x80
      [   57.202924]  filemap_write_and_wait_range+0xd9/0x170
      [   57.202930]  nfs_wb_all+0x49/0x180 [nfs 6c976fa593a7c2976f5a0aeb4965514a828e6902]
      [   57.202947]  nfs4_file_flush+0x72/0xb0 [nfsv4 c716d88496ded0ea6d289bbea684fa996f9b57a9]
      [   57.202969]  __se_sys_close+0x46/0xd0
      [   57.202972]  do_syscall_64+0x68/0x100
      [   57.202975]  ? do_syscall_64+0x77/0x100
      [   57.202976]  ? do_syscall_64+0x77/0x100
      [   57.202979]  entry_SYSCALL_64_after_hwframe+0x6e/0x76
      [   57.202982] RIP: 0033:0x7fe2b12e4a94
      [   57.202985] Code: 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 80 3d d5 18 0e 00 00 74 13 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 44 c3 0f 1f 00 48 83 ec 18 89 7c 24 0c e8 c3
      [   57.202987] RSP: 002b:00007ffe857ddb38 EFLAGS: 00000202 ORIG_RAX: 0000000000000003
      [   57.202989] RAX: ffffffffffffffda RBX: 00007ffe857dfd68 RCX: 00007fe2b12e4a94
      [   57.202991] RDX: 0000000000002000 RSI: 00007ffe857ddc40 RDI: 0000000000000003
      [   57.202992] RBP: 00007ffe857dfc50 R08: 7fffffffffffffff R09: 0000000065650f49
      [   57.202993] R10: 00007fe2b11f8300 R11: 0000000000000202 R12: 0000000000000000
      [   57.202994] R13: 00007ffe857dfd80 R14: 00007fe2b1445000 R15: 0000000000000000
      [   57.202999]  </TASK>
      
      The problem seems to be that two out of three callers aren't taking the
      rcu_read_lock() before calling the list_for_each_entry_rcu() function in
      rpc_xprt_switch_has_addr(). I fix this by having
      rpc_xprt_switch_has_addr() unconditionaly take the rcu_read_lock(),
      which is okay to do recursively in the case that the lock has already
      been taken by a caller.
      
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      31b62908
    • Anna Schumaker's avatar
      SUNRPC: Create a helper function for accessing the rpc_clnt's xprt_switch · a902f3de
      Anna Schumaker authored
      
      
      This function takes the necessary rcu read lock to dereference the
      client's rpc_xprt_switch and bump the reference count so it doesn't
      disappear underneath us before returning. This does mean that callers
      are responsible for calling xprt_switch_put() on the returned object
      when they are done with it.
      
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      a902f3de
    • Anna Schumaker's avatar
    • Anna Schumaker's avatar
      SUNRPC: Clean up unused variable in rpc_xprt_probe_trunked() · ec677b58
      Anna Schumaker authored
      
      
      We don't use the rpc_xprt_switch anywhere in this function, so let's not
      take an extra reference to in unnecessarily.
      
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      ec677b58
  2. Jan 01, 2024
  3. Dec 31, 2023
  4. Dec 30, 2023
    • Steven Rostedt (Google)'s avatar
      ftrace: Fix modification of direct_function hash while in use · d05cb470
      Steven Rostedt (Google) authored
      Masami Hiramatsu reported a memory leak in register_ftrace_direct() where
      if the number of new entries are added is large enough to cause two
      allocations in the loop:
      
              for (i = 0; i < size; i++) {
                      hlist_for_each_entry(entry, &hash->buckets[i], hlist) {
                              new = ftrace_add_rec_direct(entry->ip, addr, &free_hash);
                              if (!new)
                                      goto out_remove;
                              entry->direct = addr;
                      }
              }
      
      Where ftrace_add_rec_direct() has:
      
              if (ftrace_hash_empty(direct_functions) ||
                  direct_functions->count > 2 * (1 << direct_functions->size_bits)) {
                      struct ftrace_hash *new_hash;
                      int size = ftrace_hash_empty(direct_functions) ? 0 :
                              direct_functions->count + 1;
      
                      if (size < 32)
                              size = 32;
      
                      new_hash = dup_hash(direct_functions, size);
                      if (!new_hash)
                              return NULL;
      
                      *free_hash = direct_functions;
                      direct_functions = new_hash;
              }
      
      The "*free_hash = direct_functions;" can happen twice, losing the previous
      allocation of direct_functions.
      
      But this also exposed a more serious bug.
      
      The modification of direct_functions above is not safe. As
      direct_functions can be referenced at any time to find what direct caller
      it should call, the time between:
      
                      new_hash = dup_hash(direct_functions, size);
       and
                      direct_functions = new_hash;
      
      can have a race with another CPU (or even this one if it gets interrupted),
      and the entries being moved to the new hash are not referenced.
      
      That's because the "dup_hash()" is really misnamed and is really a
      "move_hash()". It moves the entries from the old hash to the new one.
      
      Now even if that was changed, this code is not proper as direct_functions
      should not be updated until the end. That is the best way to handle
      function reference changes, and is the way other parts of ftrace handles
      this.
      
      The following is done:
      
       1. Change add_hash_entry() to return the entry it created and inserted
          into the hash, and not just return success or not.
      
       2. Replace ftrace_add_rec_direct() with add_hash_entry(), and remove
          the former.
      
       3. Allocate a "new_hash" at the start that is made for holding both the
          new hash entries as well as the existing entries in direct_functions.
      
       4. Copy (not move) the direct_function entries over to the new_hash.
      
       5. Copy the entries of the added hash to the new_hash.
      
       6. If everything succeeds, then use rcu_pointer_assign() to update the
          direct_functions with the new_hash.
      
      This simplifies the code and fixes both the memory leak as well as the
      race condition mentioned above.
      
      Link: https://lore.kernel.org/all/170368070504.42064.8960569647118388081.stgit@devnote2/
      Link: https://lore.kernel.org/linux-trace-kernel/20231229115134.08dd5174@gandalf.local.home
      
      
      
      Cc: stable@vger.kernel.org
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Fixes: 763e34e7
      
       ("ftrace: Add register_ftrace_direct()")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      d05cb470
    • Linus Torvalds's avatar
      Merge tag 'gpio-fixes-for-v6.7-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux · f016f754
      Linus Torvalds authored
      Pull gpio fixes from Bartosz Golaszewski:
      
       - Andy steps down as GPIO reviewer
      
       - Kent becomes a reviewer for GPIO uAPI
      
       - add missing intel file to the relevant MAINTAINERS section
      
      * tag 'gpio-fixes-for-v6.7-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
        MAINTAINERS: Add a missing file to the INTEL GPIO section
        MAINTAINERS: Remove Andy from GPIO maintainers
        MAINTAINERS: split out the uAPI into a new section
      f016f754
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v6.7-6' of... · e543d0b5
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v6.7-6' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
      
      Pull x86 platform driver fixes from Ilpo Järvinen:
      
       - Intel PMC GBE LTR regression
      
       - P2SB / PCI deadlock fix
      
      * tag 'platform-drivers-x86-v6.7-6' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
        platform/x86/intel/pmc: Move GBE LTR ignore to suspend callback
        platform/x86/intel/pmc: Allow reenabling LTRs
        platform/x86/intel/pmc: Add suspend callback
        platform/x86: p2sb: Allow p2sb_bar() calls during PCI device probe
      e543d0b5
    • Linus Torvalds's avatar
      Merge tag 'block-6.7-2023-12-29' of git://git.kernel.dk/linux · 09c57a76
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
       "Fix for a badly numbered flag, and a regression fix for the badblocks
        updates from this merge window"
      
      * tag 'block-6.7-2023-12-29' of git://git.kernel.dk/linux:
        block: renumber QUEUE_FLAG_HW_WC
        badblocks: avoid checking invalid range in badblocks_check()
      09c57a76
  5. Dec 29, 2023
  6. Dec 28, 2023
    • Namjae Jeon's avatar
      ksmbd: fix slab-out-of-bounds in smb_strndup_from_utf16() · d10c7787
      Namjae Jeon authored
      
      
      If ->NameOffset/Length is bigger than ->CreateContextsOffset/Length,
      ksmbd_check_message doesn't validate request buffer it correctly.
      So slab-out-of-bounds warning from calling smb_strndup_from_utf16()
      in smb2_open() could happen. If ->NameLength is non-zero, Set the larger
      of the two sums (Name and CreateContext size) as the offset and length of
      the data area.
      
      Reported-by: default avatarYang Chaoming <lometsj@live.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      d10c7787
    • Linus Torvalds's avatar
      Merge tag 'mm-hotfixes-stable-2023-12-27-15-00' of... · f5837722
      Linus Torvalds authored
      Merge tag 'mm-hotfixes-stable-2023-12-27-15-00' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
      
      Pull misc fixes from Andrew Morton:
       "11 hotfixes. 7 are cc:stable and the other 4 address post-6.6 issues
        or are not considered backporting material"
      
      * tag 'mm-hotfixes-stable-2023-12-27-15-00' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
        mailmap: add an old address for Naoya Horiguchi
        mm/memory-failure: cast index to loff_t before shifting it
        mm/memory-failure: check the mapcount of the precise page
        mm/memory-failure: pass the folio and the page to collect_procs()
        selftests: secretmem: floor the memory size to the multiple of page_size
        mm: migrate high-order folios in swap cache correctly
        maple_tree: do not preallocate nodes for slot stores
        mm/filemap: avoid buffered read/write race to read inconsistent data
        kunit: kasan_test: disable fortify string checker on kmalloc_oob_memset
        kexec: select CRYPTO from KEXEC_FILE instead of depending on it
        kexec: fix KEXEC_FILE dependencies
      f5837722
  7. Dec 27, 2023
  8. Dec 26, 2023
  9. Dec 24, 2023