Skip to content
  1. Jan 05, 2024
  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
    • Coly Li's avatar
      badblocks: avoid checking invalid range in badblocks_check() · 146e843f
      Coly Li authored
      If prev_badblocks() returns '-1', it means no valid badblocks record
      before the checking range. It doesn't make sense to check whether
      the input checking range is overlapped with the non-existed invalid
      front range.
      
      This patch checkes whether 'prev >= 0' is true before calling
      overlap_front(), to void such invalid operations.
      
      Fixes: 3ea3354c
      
       ("badblocks: improve badblocks_check() for multiple ranges handling")
      Reported-and-tested-by: default avatarIra Weiny <ira.weiny@intel.com>
      Signed-off-by: default avatarColy Li <colyli@suse.de>
      Link: https://lore.kernel.org/nvdimm/3035e75a-9be0-4bc3-8d4a-6e52c207f277@leemhuis.info/
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Geliang Tang <geliang.tang@suse.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: NeilBrown <neilb@suse.de>
      Cc: Vishal L Verma <vishal.l.verma@intel.com>
      Cc: Xiao Ni <xni@redhat.com>
      Link: https://lore.kernel.org/r/20231224002820.20234-1-colyli@suse.de
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      146e843f
    • Linus Torvalds's avatar
      Linux 6.7-rc7 · 861deac3
      Linus Torvalds authored
      861deac3
    • Linus Torvalds's avatar
      Merge tag 'x86-urgent-2023-12-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 3f82f1c3
      Linus Torvalds authored
      Pull x86 fixes from Ingo Molnar:
      
       - Fix a secondary CPUs enumeration regression caused by creative MADT
         APIC table entries on certain systems.
      
       - Fix a race in the NOP-patcher that can spuriously trigger crashes on
         bootup.
      
       - Fix a bootup failure regression caused by the parallel bringup code,
         caused by firmware inconsistency between the APIC initialization
         states of the boot and secondary CPUs, on certain systems.
      
      * tag 'x86-urgent-2023-12-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/acpi: Handle bogus MADT APIC tables gracefully
        x86/alternatives: Disable interrupts and sync when optimizing NOPs in place
        x86/alternatives: Sync core before enabling interrupts
        x86/smpboot/64: Handle X2APIC BIOS inconsistency gracefully
      3f82f1c3
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · f969c914
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "Four small fixes, three in drivers with the core one adding a batch
        indicator (for drivers which use it) to the error handler"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: ufs: core: Let the sq_lock protect sq_tail_slot access
        scsi: ufs: qcom: Return ufs_qcom_clk_scale_*() errors in ufs_qcom_clk_scale_notify()
        scsi: core: Always send batch on reset or error handling command
        scsi: bnx2fc: Fix skb double free in bnx2fc_rcv()
      f969c914
    • Linus Torvalds's avatar
      Merge tag 'usb-6.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 4b2ee6d2
      Linus Torvalds authored
      Pull USB / Thunderbolt fixes from Greg KH:
       "Here are some small bugfixes and new device ids for USB and
        Thunderbolt drivers for 6.7-rc7. Included in here are:
      
         - new usb-serial device ids
      
         - thunderbolt driver fixes
      
         - typec driver fix
      
         - usb-storage driver quirk added
      
         - fotg210 driver fix
      
        All of these have been in linux-next with no reported issues"
      
      * tag 'usb-6.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        USB: serial: option: add Quectel EG912Y module support
        USB: serial: ftdi_sio: update Actisense PIDs constant names
        usb: fotg210-hcd: delete an incorrect bounds test
        usb-storage: Add quirk for incorrect WP on Kingston DT Ultimate 3.0 G3
        usb: typec: ucsi: fix gpio-based orientation detection
        net: usb: ax88179_178a: avoid failed operations when device is disconnected
        USB: serial: option: add Quectel RM500Q R13 firmware support
        USB: serial: option: add Foxconn T99W265 with new baseline
        thunderbolt: Fix minimum allocated USB 3.x and PCIe bandwidth
        thunderbolt: Fix memory leak in margining_port_remove()
      4b2ee6d2
    • Linus Torvalds's avatar
      Merge tag 'char-misc-6.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc · a0652eb2
      Linus Torvalds authored
      Pull char / misc driver fixes from Greg KH:
       "Here are a small number of various driver fixes for 6.7-rc7 that
        normally come through the char-misc tree, and one debugfs fix as well.
      
        Included in here are:
      
         - iio and hid sensor driver fixes for a number of small things
      
         - interconnect driver fixes
      
         - brcm_nvmem driver fixes
      
         - debugfs fix for previous fix
      
         - guard() definition in device.h so that many subsystems can start
           using it for 6.8-rc1 (requested by Dan Williams to make future
           merges easier)
      
        All of these have been in linux-next for a while with no reported
        issues"
      
      * tag 'char-misc-6.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (21 commits)
        debugfs: initialize cancellations earlier
        Revert "iio: hid-sensor-als: Add light color temperature support"
        Revert "iio: hid-sensor-als: Add light chromaticity support"
        nvmem: brcm_nvram: store a co...
      a0652eb2
    • Linus Torvalds's avatar
      Merge tag 'input-for-v6.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input · fa655abe
      Linus Torvalds authored
      Pull input updates from Dmitry Torokhov:
      
       - a quirk to AT keyboard driver to skip issuing "GET ID" command when
         8042 is in translated mode and the device is a laptop/portable,
         because the "GET ID" command makes a bunch of recent laptops unhappy
      
       - a quirk to i8042 to disable multiplexed mode on Acer P459-G2-M which
         causes issues on resume
      
       - psmouse will activate native RMI4 protocol support for touchpad on
         ThinkPad L14 G1
      
       - addition of Razer Wolverine V2 ID to xpad gamepad driver
      
       - mapping for airplane mode button in soc_button_array driver for
         TUXEDO laptops
      
       - improved error handling in ipaq-micro-keys driver
      
       - amimouse being prepared for platform remove callback returning void
      
      * tag 'input-for-v6.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
        Input: soc_button_array - add mapping for airplane mode button
        Input: xpad - add Razer Wolverine V2 support
        Input: ipaq-micro-keys - add error handling for devm_kmemdup
        Input: amimouse - convert to platform remove callback returning void
        Input: i8042 - add nomux quirk for Acer P459-G2-M
        Input: atkbd - skip ATKBD_CMD_GETID in translated mode
        Input: psmouse - enable Synaptics InterTouch for ThinkPad L14 G1
      fa655abe
  10. Dec 23, 2023
    • Masahiro Yamada's avatar
      kbuild: fix build ID symlinks to installed debug VDSO files · c1a86271
      Masahiro Yamada authored
      Commit 56769ba4 ("kbuild: unify vdso_install rules") accidentally
      dropped the '.debug' suffix from the build ID symlinks.
      
      Fixes: 56769ba4
      
       ("kbuild: unify vdso_install rules")
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      c1a86271
    • Jialu Xu's avatar
      gen_compile_commands.py: fix path resolve with symlinks in it · 88094615
      Jialu Xu authored
      
      
      When a path contains relative symbolic links, os.path.abspath() might
      not follow the symlinks and instead return the absolute path with just
      the relative paths resolved, resulting in an incorrect path.
      
      1. Say "drivers/hdf/" has some symlinks:
      
          # ls -l drivers/hdf/
          total 364
          drwxrwxr-x 2 ...   4096 ... evdev
          lrwxrwxrwx 1 ...     44 ... framework -> ../../../../../../drivers/hdf_core/framework
          -rw-rw-r-- 1 ... 359010 ... hdf_macro_test.h
          lrwxrwxrwx 1 ...     55 ... inner_api -> ../../../../../../drivers/hdf_core/interfaces/inner_api
          lrwxrwxrwx 1 ...     53 ... khdf -> ../../../../../../drivers/hdf_core/adapter/khdf/linux
          -rw-r--r-- 1 ...     74 ... Makefile
          drwxrwxr-x 3 ...   4096 ... wifi
      
      2. One .cmd file records that:
      
          # head -1 ./framework/core/manager/src/.devmgr_service.o.cmd
          cmd_drivers/hdf/khdf/manager/../../../../framework/core/manager/src/devmgr_service.o := ... \
          /path/to/src/drivers/hdf/khdf/manager/../../../../framework/core/manager/src/devmgr_service.c
      
      3. os.path.abspath returns "/path/to/src/framework/core/manager/src/devmgr_service.c", not correct:
      
          # ./scripts/clang-tools/gen_compile_commands.py
          INFO: Could not add line from ./framework/core/manager/src/.devmgr_service.o.cmd: File \
              /path/to/src/framework/core/manager/src/devmgr_service.c not found
      
      Use os.path.realpath(), which resolves the symlinks and normalizes the paths correctly.
      
          # cat compile_commands.json
          ...
          {
            "command": ...
            "directory": ...
            "file": "/path/to/bla/drivers/hdf_core/framework/core/manager/src/devmgr_service.c"
          },
          ...
      
      Also fix it in parse_arguments().
      
      Signed-off-by: default avatarJialu Xu <xujialu@vimux.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      88094615