Skip to content
  1. Sep 23, 2023
    • Ian Rogers's avatar
      perf tools: Add an option to build without libbfd · a04cce3e
      Ian Rogers authored
      [ Upstream commit 0d1c50ac
      
       ]
      
      Some distributions, like debian, don't link perf with libbfd. Add a
      build flag to make this configuration buildable and testable.
      
      This was inspired by:
      
        https://lore.kernel.org/linux-perf-users/20210910102307.2055484-1-tonyg@leastfixedpoint.com/T/#u
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: tony garnock-jones <tonyg@leastfixedpoint.com>
      Link: http://lore.kernel.org/lkml/20210910225756.729087-1-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Stable-dep-of: 7822a891
      
       ("perf build: Update build rule for generated files")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a04cce3e
    • John Garry's avatar
      perf jevents: Make build dependency on test JSONs · f3701ef6
      John Garry authored
      [ Upstream commit 517db3b5
      
       ]
      
      Currently all JSONs and the mapfile for an arch are dependencies for
      building pmu-events.c
      
      The test JSONs are missing as a dependency, so add them.
      
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/90094733-741c-50e5-ac7d-f5640b5f0bdd@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Stable-dep-of: 7822a891
      
       ("perf build: Update build rule for generated files")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f3701ef6
    • Arnaldo Carvalho de Melo's avatar
      tools features: Add feature test to check if libbfd has buildid support · a12e9ba7
      Arnaldo Carvalho de Melo authored
      [ Upstream commit e71e19a9
      
       ]
      
      Which is needed by the PE executable support, for instance.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jacek Caban <jacek@codeweavers.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Remi Bernon <rbernon@codeweavers.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Stable-dep-of: 7822a891
      
       ("perf build: Update build rule for generated files")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a12e9ba7
    • Zhen Lei's avatar
      kobject: Add sanity check for kset->kobj.ktype in kset_register() · 964e025c
      Zhen Lei authored
      [ Upstream commit 4d0fe8c5
      
       ]
      
      When I register a kset in the following way:
      	static struct kset my_kset;
      	kobject_set_name(&my_kset.kobj, "my_kset");
              ret = kset_register(&my_kset);
      
      A null pointer dereference exception is occurred:
      [ 4453.568337] Unable to handle kernel NULL pointer dereference at \
      virtual address 0000000000000028
      ... ...
      [ 4453.810361] Call trace:
      [ 4453.813062]  kobject_get_ownership+0xc/0x34
      [ 4453.817493]  kobject_add_internal+0x98/0x274
      [ 4453.822005]  kset_register+0x5c/0xb4
      [ 4453.825820]  my_kobj_init+0x44/0x1000 [my_kset]
      ... ...
      
      Because I didn't initialize my_kset.kobj.ktype.
      
      According to the description in Documentation/core-api/kobject.rst:
       - A ktype is the type of object that embeds a kobject.  Every structure
         that embeds a kobject needs a corresponding ktype.
      
      So add sanity check to make sure kset->kobj.ktype is not NULL.
      
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20230805084114.1298-2-thunder.leizhen@huaweicloud.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      964e025c
    • Sakari Ailus's avatar
      media: pci: ipu3-cio2: Initialise timing struct to avoid a compiler warning · 545d1070
      Sakari Ailus authored
      [ Upstream commit 9d7531be
      
       ]
      
      Initialise timing struct in cio2_hw_init() to zero in order to avoid a
      compiler warning. The warning was a false positive.
      
      Reported-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      545d1070
    • Christophe Leroy's avatar
      serial: cpm_uart: Avoid suspicious locking · 44d72e9e
      Christophe Leroy authored
      [ Upstream commit 36ef11d3
      
       ]
      
        CHECK   drivers/tty/serial/cpm_uart/cpm_uart_core.c
      drivers/tty/serial/cpm_uart/cpm_uart_core.c:1271:39: warning: context imbalance in 'cpm_uart_console_write' - unexpected unlock
      
      Allthough 'nolock' is not expected to change, sparse find the following
      form suspicious:
      
      	if (unlikely(nolock)) {
      		local_irq_save(flags);
      	} else {
      		spin_lock_irqsave(&pinfo->port.lock, flags);
      	}
      
      	cpm_uart_early_write(pinfo, s, count, true);
      
      	if (unlikely(nolock)) {
      		local_irq_restore(flags);
      	} else {
      		spin_unlock_irqrestore(&pinfo->port.lock, flags);
      	}
      
      Rewrite it a more obvious form:
      
      	if (unlikely(oops_in_progress)) {
      		local_irq_save(flags);
      		cpm_uart_early_write(pinfo, s, count, true);
      		local_irq_restore(flags);
      	} else {
      		spin_lock_irqsave(&pinfo->port.lock, flags);
      		cpm_uart_early_write(pinfo, s, count, true);
      		spin_unlock_irqrestore(&pinfo->port.lock, flags);
      	}
      
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Link: https://lore.kernel.org/r/f7da5cdc9287960185829cfef681a7d8614efa1f.1691068700.git.christophe.leroy@csgroup.eu
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      44d72e9e
    • Konstantin Shelekhin's avatar
      scsi: target: iscsi: Fix buffer overflow in lio_target_nacl_info_show() · 2cbe6a88
      Konstantin Shelekhin authored
      [ Upstream commit 801f287c
      
       ]
      
      The function lio_target_nacl_info_show() uses sprintf() in a loop to print
      details for every iSCSI connection in a session without checking for the
      buffer length. With enough iSCSI connections it's possible to overflow the
      buffer provided by configfs and corrupt the memory.
      
      This patch replaces sprintf() with sysfs_emit_at() that checks for buffer
      boundries.
      
      Signed-off-by: default avatarKonstantin Shelekhin <k.shelekhin@yadro.com>
      Link: https://lore.kernel.org/r/20230722152657.168859-2-k.shelekhin@yadro.com
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2cbe6a88
    • Ma Ke's avatar
      usb: gadget: fsl_qe_udc: validate endpoint index for ch9 udc · 9cd6b380
      Ma Ke authored
      [ Upstream commit ce9daa2e
      
       ]
      
      We should verify the bound of the array to assure that host
      may not manipulate the index to point past endpoint array.
      
      Signed-off-by: default avatarMa Ke <make_ruc2021@163.com>
      Acked-by: default avatarLi Yang <leoyang.li@nxp.com>
      Link: https://lore.kernel.org/r/20230628081511.186850-1-make_ruc2021@163.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9cd6b380
    • Hans Verkuil's avatar
      media: pci: cx23885: replace BUG with error return · abe0cd27
      Hans Verkuil authored
      [ Upstream commit 2e1796fd
      
       ]
      
      It was completely unnecessary to use BUG in buffer_prepare().
      Just replace it with an error return. This also fixes a smatch warning:
      
      drivers/media/pci/cx23885/cx23885-video.c:422 buffer_prepare() error: uninitialized symbol 'ret'.
      
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      abe0cd27
    • Hans Verkuil's avatar
      media: tuners: qt1010: replace BUG_ON with a regular error · 641e6022
      Hans Verkuil authored
      [ Upstream commit ee630b29
      
       ]
      
      BUG_ON is unnecessary here, and in addition it confuses smatch.
      Replacing this with an error return help resolve this smatch
      warning:
      
      drivers/media/tuners/qt1010.c:350 qt1010_init() error: buffer overflow 'i2c_data' 34 <= 34
      
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      641e6022
    • Zhang Shurong's avatar
      media: az6007: Fix null-ptr-deref in az6007_i2c_xfer() · 991c77fe
      Zhang Shurong authored
      [ Upstream commit 1047f934 ]
      
      In az6007_i2c_xfer, msg is controlled by user. When msg[i].buf
      is null and msg[i].len is zero, former checks on msg[i].buf would be
      passed. Malicious data finally reach az6007_i2c_xfer. If accessing
      msg[i].buf[0] without sanity check, null ptr deref would happen.
      We add check on msg[i].len to prevent crash.
      
      Similar commit:
      commit 0ed554fd
      
      
      ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
      
      Signed-off-by: default avatarZhang Shurong <zhang_shurong@foxmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      991c77fe
    • Zhang Shurong's avatar
      media: anysee: fix null-ptr-deref in anysee_master_xfer · 8dc5b370
      Zhang Shurong authored
      [ Upstream commit c3041126 ]
      
      In anysee_master_xfer, msg is controlled by user. When msg[i].buf
      is null and msg[i].len is zero, former checks on msg[i].buf would be
      passed. Malicious data finally reach anysee_master_xfer. If accessing
      msg[i].buf[0] without sanity check, null ptr deref would happen.
      We add check on msg[i].len to prevent crash.
      
      Similar commit:
      commit 0ed554fd
      
      
      ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
      
      Signed-off-by: default avatarZhang Shurong <zhang_shurong@foxmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      [hverkuil: add spaces around +]
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8dc5b370
    • Zhang Shurong's avatar
      media: af9005: Fix null-ptr-deref in af9005_i2c_xfer · 0c02eb70
      Zhang Shurong authored
      [ Upstream commit f4ee84f2 ]
      
      In af9005_i2c_xfer, msg is controlled by user. When msg[i].buf
      is null and msg[i].len is zero, former checks on msg[i].buf would be
      passed. Malicious data finally reach af9005_i2c_xfer. If accessing
      msg[i].buf[0] without sanity check, null ptr deref would happen.
      We add check on msg[i].len to prevent crash.
      
      Similar commit:
      commit 0ed554fd
      
      
      ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
      
      Signed-off-by: default avatarZhang Shurong <zhang_shurong@foxmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0c02eb70
    • Zhang Shurong's avatar
      media: dw2102: Fix null-ptr-deref in dw2102_i2c_transfer() · beb95504
      Zhang Shurong authored
      [ Upstream commit 5ae544d9 ]
      
      In dw2102_i2c_transfer, msg is controlled by user. When msg[i].buf
      is null and msg[i].len is zero, former checks on msg[i].buf would be
      passed. Malicious data finally reach dw2102_i2c_transfer. If accessing
      msg[i].buf[0] without sanity check, null ptr deref would happen.
      We add check on msg[i].len to prevent crash.
      
      Similar commit:
      commit 950e252c
      
      
      ("[media] dw2102: limit messages to buffer size")
      
      Signed-off-by: default avatarZhang Shurong <zhang_shurong@foxmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      beb95504
    • Zhang Shurong's avatar
      media: dvb-usb-v2: af9035: Fix null-ptr-deref in af9035_i2c_master_xfer · b49c6e5d
      Zhang Shurong authored
      [ Upstream commit 7bf744f2 ]
      
      In af9035_i2c_master_xfer, msg is controlled by user. When msg[i].buf
      is null and msg[i].len is zero, former checks on msg[i].buf would be
      passed. Malicious data finally reach af9035_i2c_master_xfer. If accessing
      msg[i].buf[0] without sanity check, null ptr deref would happen.
      We add check on msg[i].len to prevent crash.
      
      Similar commit:
      commit 0ed554fd
      
      
      ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
      
      Signed-off-by: default avatarZhang Shurong <zhang_shurong@foxmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      [ moved variable declaration to fix build issues in older kernels - gregkh ]
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b49c6e5d
    • ruanjinjie's avatar
      powerpc/pseries: fix possible memory leak in ibmebus_bus_init() · 7ffe14fc
      ruanjinjie authored
      [ Upstream commit afda85b9
      
       ]
      
      If device_register() returns error in ibmebus_bus_init(), name of kobject
      which is allocated in dev_set_name() called in device_add() is leaked.
      
      As comment of device_add() says, it should call put_device() to drop
      the reference count that was set in device_initialize() when it fails,
      so the name can be freed in kobject_cleanup().
      
      Signed-off-by: default avatarruanjinjie <ruanjinjie@huawei.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20221110011929.3709774-1-ruanjinjie@huawei.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7ffe14fc
    • Liu Shixin via Jfs-discussion's avatar
      jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount · 5873df01
      Liu Shixin via Jfs-discussion authored
      [ Upstream commit 6e2bda2c
      
       ]
      
      syzbot found an invalid-free in diUnmount:
      
      BUG: KASAN: double-free in slab_free mm/slub.c:3661 [inline]
      BUG: KASAN: double-free in __kmem_cache_free+0x71/0x110 mm/slub.c:3674
      Free of addr ffff88806f410000 by task syz-executor131/3632
      
       CPU: 0 PID: 3632 Comm: syz-executor131 Not tainted 6.1.0-rc7-syzkaller-00012-gca57f02295f1 #0
       Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
       Call Trace:
        <TASK>
        __dump_stack lib/dump_stack.c:88 [inline]
        dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
        print_address_description+0x74/0x340 mm/kasan/report.c:284
        print_report+0x107/0x1f0 mm/kasan/report.c:395
        kasan_report_invalid_free+0xac/0xd0 mm/kasan/report.c:460
        ____kasan_slab_free+0xfb/0x120
        kasan_slab_free include/linux/kasan.h:177 [inline]
        slab_free_hook mm/slub.c:1724 [inline]
        slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1750
        slab_free mm/slub.c:3661 [inline]
        __kmem_cache_free+0x71/0x110 mm/slub.c:3674
        diUnmount+0xef/0x100 fs/jfs/jfs_imap.c:195
        jfs_umount+0x108/0x370 fs/jfs/jfs_umount.c:63
        jfs_put_super+0x86/0x190 fs/jfs/super.c:194
        generic_shutdown_super+0x130/0x310 fs/super.c:492
        kill_block_super+0x79/0xd0 fs/super.c:1428
        deactivate_locked_super+0xa7/0xf0 fs/super.c:332
        cleanup_mnt+0x494/0x520 fs/namespace.c:1186
        task_work_run+0x243/0x300 kernel/task_work.c:179
        exit_task_work include/linux/task_work.h:38 [inline]
        do_exit+0x664/0x2070 kernel/exit.c:820
        do_group_exit+0x1fd/0x2b0 kernel/exit.c:950
        __do_sys_exit_group kernel/exit.c:961 [inline]
        __se_sys_exit_group kernel/exit.c:959 [inline]
        __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:959
        do_syscall_x64 arch/x86/entry/common.c:50 [inline]
        do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
        entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [...]
      
      JFS_IP(ipimap)->i_imap is not setting to NULL after free in diUnmount.
      If jfs_remount() free JFS_IP(ipimap)->i_imap but then failed at diMount().
      JFS_IP(ipimap)->i_imap will be freed once again.
      Fix this problem by setting JFS_IP(ipimap)->i_imap to NULL after free.
      
      Reported-by: default avatar <syzbot+90a11e6b1e810785c6ff@syzkaller.appspotmail.com>
      Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5873df01
    • Andrew Kanner's avatar
      fs/jfs: prevent double-free in dbUnmount() after failed jfs_remount() · b12ccbfd
      Andrew Kanner authored
      [ Upstream commit cade5397
      
       ]
      
      Syzkaller reported the following issue:
      ==================================================================
      BUG: KASAN: double-free in slab_free mm/slub.c:3787 [inline]
      BUG: KASAN: double-free in __kmem_cache_free+0x71/0x110 mm/slub.c:3800
      Free of addr ffff888086408000 by task syz-executor.4/12750
      [...]
      Call Trace:
       <TASK>
      [...]
       kasan_report_invalid_free+0xac/0xd0 mm/kasan/report.c:482
       ____kasan_slab_free+0xfb/0x120
       kasan_slab_free include/linux/kasan.h:177 [inline]
       slab_free_hook mm/slub.c:1781 [inline]
       slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1807
       slab_free mm/slub.c:3787 [inline]
       __kmem_cache_free+0x71/0x110 mm/slub.c:3800
       dbUnmount+0xf4/0x110 fs/jfs/jfs_dmap.c:264
       jfs_umount+0x248/0x3b0 fs/jfs/jfs_umount.c:87
       jfs_put_super+0x86/0x190 fs/jfs/super.c:194
       generic_shutdown_super+0x130/0x310 fs/super.c:492
       kill_block_super+0x79/0xd0 fs/super.c:1386
       deactivate_locked_super+0xa7/0xf0 fs/super.c:332
       cleanup_mnt+0x494/0x520 fs/namespace.c:1291
       task_work_run+0x243/0x300 kernel/task_work.c:179
       resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
       exit_to_user_mode_loop+0x124/0x150 kernel/entry/common.c:171
       exit_to_user_mode_prepare+0xb2/0x140 kernel/entry/common.c:203
       __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
       syscall_exit_to_user_mode+0x26/0x60 kernel/entry/common.c:296
       do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [...]
       </TASK>
      
      Allocated by task 13352:
       kasan_save_stack mm/kasan/common.c:45 [inline]
       kasan_set_track+0x3d/0x60 mm/kasan/common.c:52
       ____kasan_kmalloc mm/kasan/common.c:371 [inline]
       __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:380
       kmalloc include/linux/slab.h:580 [inline]
       dbMount+0x54/0x980 fs/jfs/jfs_dmap.c:164
       jfs_mount+0x1dd/0x830 fs/jfs/jfs_mount.c:121
       jfs_fill_super+0x590/0xc50 fs/jfs/super.c:556
       mount_bdev+0x26c/0x3a0 fs/super.c:1359
       legacy_get_tree+0xea/0x180 fs/fs_context.c:610
       vfs_get_tree+0x88/0x270 fs/super.c:1489
       do_new_mount+0x289/0xad0 fs/namespace.c:3145
       do_mount fs/namespace.c:3488 [inline]
       __do_sys_mount fs/namespace.c:3697 [inline]
       __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3674
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Freed by task 13352:
       kasan_save_stack mm/kasan/common.c:45 [inline]
       kasan_set_track+0x3d/0x60 mm/kasan/common.c:52
       kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:518
       ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
       kasan_slab_free include/linux/kasan.h:177 [inline]
       slab_free_hook mm/slub.c:1781 [inline]
       slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1807
       slab_free mm/slub.c:3787 [inline]
       __kmem_cache_free+0x71/0x110 mm/slub.c:3800
       dbUnmount+0xf4/0x110 fs/jfs/jfs_dmap.c:264
       jfs_mount_rw+0x545/0x740 fs/jfs/jfs_mount.c:247
       jfs_remount+0x3db/0x710 fs/jfs/super.c:454
       reconfigure_super+0x3bc/0x7b0 fs/super.c:935
       vfs_fsconfig_locked fs/fsopen.c:254 [inline]
       __do_sys_fsconfig fs/fsopen.c:439 [inline]
       __se_sys_fsconfig+0xad5/0x1060 fs/fsopen.c:314
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [...]
      
      JFS_SBI(ipbmap->i_sb)->bmap wasn't set to NULL after kfree() in
      dbUnmount().
      
      Syzkaller uses faultinject to reproduce this KASAN double-free
      warning. The issue is triggered if either diMount() or dbMount() fail
      in jfs_remount(), since diUnmount() or dbUnmount() already happened in
      such a case - they will do double-free on next execution: jfs_umount
      or jfs_remount.
      
      Tested on both upstream and jfs-next by syzkaller.
      
      Reported-and-tested-by: default avatar <syzbot+6a93efb725385bc4b2e9@syzkaller.appspotmail.com>
      Closes: https://lore.kernel.org/all/000000000000471f2d05f1ce8bad@google.com/T/
      Link: https://syzkaller.appspot.com/bug?extid=6a93efb725385bc4b2e9
      Signed-off-by: default avatarAndrew Kanner <andrew.kanner@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b12ccbfd
    • Georg Ottinger's avatar
      ext2: fix datatype of block number in ext2_xattr_set2() · a7fde3d4
      Georg Ottinger authored
      [ Upstream commit e8807634
      
       ]
      
      I run a small server that uses external hard drives for backups. The
      backup software I use uses ext2 filesystems with 4KiB block size and
      the server is running SELinux and therefore relies on xattr. I recently
      upgraded the hard drives from 4TB to 12TB models. I noticed that after
      transferring some TBs I got a filesystem error "Freeing blocks not in
      datazone - block = 18446744071529317386, count = 1" and the backup
      process stopped. Trying to fix the fs with e2fsck resulted in a
      completely corrupted fs. The error probably came from ext2_free_blocks(),
      and because of the large number 18e19 this problem immediately looked
      like some kind of integer overflow. Whereas the 4TB fs was about 1e9
      blocks, the new 12TB is about 3e9 blocks. So, searching the ext2 code,
      I came across the line in fs/ext2/xattr.c:745 where ext2_new_block()
      is called and the resulting block number is stored in the variable block
      as an int datatype. If a block with a block number greater than
      INT32_MAX is returned, this variable overflows and the call to
      sb_getblk() at line fs/ext2/xattr.c:750 fails, then the call to
      ext2_free_blocks() produces the error.
      
      Signed-off-by: default avatarGeorg Ottinger <g.ottinger@gmx.at>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Message-Id: <20230815100340.22121-1-g.ottinger@gmx.at>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a7fde3d4
    • Zhang Shurong's avatar
      md: raid1: fix potential OOB in raid1_remove_disk() · 25a68f22
      Zhang Shurong authored
      [ Upstream commit 8b0472b5 ]
      
      If rddev->raid_disk is greater than mddev->raid_disks, there will be
      an out-of-bounds in raid1_remove_disk(). We have already found
      similar reports as follows:
      
      1) commit d17f744e ("md-raid10: fix KASAN warning")
      2) commit 1ebc2cec
      
       ("dm raid: fix KASAN warning in raid5_remove_disk")
      
      Fix this bug by checking whether the "number" variable is
      valid.
      
      Signed-off-by: default avatarZhang Shurong <zhang_shurong@foxmail.com>
      Reviewed-by: default avatarYu Kuai <yukuai3@huawei.com>
      Link: https://lore.kernel.org/r/tencent_0D24426FAC6A21B69AC0C03CE4143A508F09@qq.com
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      25a68f22
    • Tony Lindgren's avatar
      bus: ti-sysc: Configure uart quirks for k3 SoC · 77918680
      Tony Lindgren authored
      [ Upstream commit 03a711d3
      
       ]
      
      Enable the uart quirks similar to the earlier SoCs. Let's assume we are
      likely going to need a k3 specific quirk mask separate from the earlier
      SoCs, so let's not start changing the revision register mask at this point.
      
      Note that SYSC_QUIRK_LEGACY_IDLE will be needed until we can remove the
      need for pm_runtime_irq_safe() from 8250_omap driver.
      
      Reviewed-by: default avatarNishanth Menon <nm@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      77918680
    • Tuo Li's avatar
      drm/exynos: fix a possible null-pointer dereference due to data race in... · 279e32b7
      Tuo Li authored
      drm/exynos: fix a possible null-pointer dereference due to data race in exynos_drm_crtc_atomic_disable()
      
      [ Upstream commit 2e63972a
      
       ]
      
      The variable crtc->state->event is often protected by the lock
      crtc->dev->event_lock when is accessed. However, it is accessed as a
      condition of an if statement in exynos_drm_crtc_atomic_disable() without
      holding the lock:
      
        if (crtc->state->event && !crtc->state->active)
      
      However, if crtc->state->event is changed to NULL by another thread right
      after the conditions of the if statement is checked to be true, a
      null-pointer dereference can occur in drm_crtc_send_vblank_event():
      
        e->pipe = pipe;
      
      To fix this possible null-pointer dereference caused by data race, the
      spin lock coverage is extended to protect the if statement as well as the
      function call to drm_crtc_send_vblank_event().
      
      Reported-by: default avatarBassCheck <bass@buaa.edu.cn>
      Link: https://sites.google.com/view/basscheck/home
      Signed-off-by: default avatarTuo Li <islituo@gmail.com>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Added relevant link.
      Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      279e32b7
    • Johannes Berg's avatar
      wifi: mac80211_hwsim: drop short frames · 3beb97be
      Johannes Berg authored
      [ Upstream commit fba360a0
      
       ]
      
      While technically some control frames like ACK are shorter and
      end after Address 1, such frames shouldn't be forwarded through
      wmediumd or similar userspace, so require the full 3-address
      header to avoid accessing invalid memory if shorter frames are
      passed in.
      
      Reported-by: default avatar <syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com>
      Reviewed-by: default avatarJeff Johnson <quic_jjohnson@quicinc.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3beb97be
    • GONG, Ruiqi's avatar
      alx: fix OOB-read compiler warning · 6773ea99
      GONG, Ruiqi authored
      [ Upstream commit 3a198c95
      
       ]
      
      The following message shows up when compiling with W=1:
      
      In function ‘fortify_memcpy_chk’,
          inlined from ‘alx_get_ethtool_stats’ at drivers/net/ethernet/atheros/alx/ethtool.c:297:2:
      ./include/linux/fortify-string.h:592:4: error: call to ‘__read_overflow2_field’
      declared with attribute warning: detected read beyond size of field (2nd parameter);
      maybe use struct_group()? [-Werror=attribute-warning]
        592 |    __read_overflow2_field(q_size_field, size);
            |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      In order to get alx stats altogether, alx_get_ethtool_stats() reads
      beyond hw->stats.rx_ok. Fix this warning by directly copying hw->stats,
      and refactor the unnecessarily complicated BUILD_BUG_ON btw.
      
      Signed-off-by: default avatarGONG, Ruiqi <gongruiqi1@huawei.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20230821013218.16142655
      
      -1-gongruiqi@huaweicloud.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6773ea99
    • Giulio Benetti's avatar
      mmc: sdhci-esdhc-imx: improve ESDHC_FLAG_ERR010450 · fd1a177d
      Giulio Benetti authored
      [ Upstream commit 5ae4b0d8
      
       ]
      
      Errata ERR010450 only shows up if voltage is 1.8V, but if the device is
      supplied by 3v3 the errata can be ignored. So let's check for if quirk
      SDHCI_QUIRK2_NO_1_8_V is defined or not before limiting the frequency.
      
      Cc: Jim Reinhart <jimr@tekvox.com>
      Cc: James Autry <jautry@tekvox.com>
      Cc: Matthew Maron <matthewm@tekvox.com>
      Signed-off-by: default avatarGiulio Benetti <giulio.benetti@benettiengineering.com>
      Acked-by: default avatarHaibo Chen <haibo.chen@nxp.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Link: https://lore.kernel.org/r/20230811214853.8623-1-giulio.benetti@benettiengineering.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fd1a177d
    • Alexander Steffen's avatar
      tpm_tis: Resend command to recover from data transfer errors · ff75c853
      Alexander Steffen authored
      [ Upstream commit 280db21e
      
       ]
      
      Similar to the transmission of TPM responses, also the transmission of TPM
      commands may become corrupted. Instead of aborting when detecting such
      issues, try resending the command again.
      
      Signed-off-by: default avatarAlexander Steffen <Alexander.Steffen@infineon.com>
      Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ff75c853
    • Mark O'Donovan's avatar
      crypto: lib/mpi - avoid null pointer deref in mpi_cmp_ui() · 61f5453e
      Mark O'Donovan authored
      [ Upstream commit 9e47a758
      
       ]
      
      During NVMeTCP Authentication a controller can trigger a kernel
      oops by specifying the 8192 bit Diffie Hellman group and passing
      a correctly sized, but zeroed Diffie Hellamn value.
      mpi_cmp_ui() was detecting this if the second parameter was 0,
      but 1 is passed from dh_is_pubkey_valid(). This causes the null
      pointer u->d to be dereferenced towards the end of mpi_cmp_ui()
      
      Signed-off-by: default avatarMark O'Donovan <shiftee@posteo.net>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      61f5453e
    • Dmitry Antipov's avatar
      wifi: mwifiex: fix fortify warning · d1473fc0
      Dmitry Antipov authored
      [ Upstream commit dcce94b8
      
       ]
      
      When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=y,
      I've noticed the following:
      
      In function ‘fortify_memcpy_chk’,
          inlined from ‘mwifiex_construct_tdls_action_frame’ at drivers/net/wireless/marvell/mwifiex/tdls.c:765:3,
          inlined from ‘mwifiex_send_tdls_action_frame’ at drivers/net/wireless/marvell/mwifiex/tdls.c:856:6:
      ./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’
      declared with attribute warning: detected read beyond size of field (2nd parameter);
      maybe use struct_group()? [-Wattribute-warning]
        529 |                         __read_overflow2_field(q_size_field, size);
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      The compiler actually complains on:
      
      memmove(pos + ETH_ALEN, &mgmt->u.action.category,
      	sizeof(mgmt->u.action.u.tdls_discover_resp));
      
      and it happens because the fortification logic interprets this
      as an attempt to overread 1-byte 'u.action.category' member of
      'struct ieee80211_mgmt'. To silence this warning, it's enough
      to pass an address of 'u.action' itself instead of an address
      of its first member.
      
      This also fixes an improper usage of 'sizeof()'. Since 'skb' is
      extended with 'sizeof(mgmt->u.action.u.tdls_discover_resp) + 1'
      bytes (where 1 is actually 'sizeof(mgmt->u.action.category)'),
      I assume that the same number of bytes should be copied.
      
      Suggested-by: default avatarBrian Norris <briannorris@chromium.org>
      Signed-off-by: default avatarDmitry Antipov <dmantipov@yandex.ru>
      Reviewed-by: default avatarBrian Norris <briannorris@chromium.org>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20230629085115.180499-2-dmantipov@yandex.ru
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d1473fc0
    • Dongliang Mu's avatar
      wifi: ath9k: fix printk specifier · 38eb4ef6
      Dongliang Mu authored
      [ Upstream commit 061115fb
      
       ]
      
      Smatch reports:
      
      ath_pci_probe() warn: argument 4 to %lx specifier is cast from pointer
      ath_ahb_probe() warn: argument 4 to %lx specifier is cast from pointer
      
      Fix it by modifying %lx to %p in the printk format string.
      
      Note that with this change, the pointer address will be printed as a
      hashed value by default. This is appropriate because the kernel
      should not leak kernel pointers to user space in an informational
      message. If someone wants to see the real address for debugging
      purposes, this can be achieved with the no_hash_pointers kernel option.
      
      Signed-off-by: default avatarDongliang Mu <dzm91@hust.edu.cn>
      Acked-by: default avatarToke Høiland-Jørgensen <toke@toke.dk>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20230723040403.296723-1-dzm91@hust.edu.cn
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      38eb4ef6
    • Jiri Pirko's avatar
      devlink: remove reload failed checks in params get/set callbacks · 93f4a0b7
      Jiri Pirko authored
      [ Upstream commit 633d76ad ]
      
      The checks in question were introduced by:
      commit 6b4db2e5 ("devlink: Fix use-after-free after a failed reload").
      That fixed an issue of reload with mlxsw driver.
      
      Back then, that was a valid fix, because there was a limitation
      in place that prevented drivers from registering/unregistering params
      when devlink instance was registered.
      
      It was possible to do the fix differently by changing drivers to
      register/unregister params in appropriate places making sure the ops
      operate only on memory which is allocated and initialized. But that,
      as a dependency, would require to remove the limitation mentioned above.
      
      Eventually, this limitation was lifted by:
      commit 1d18bb1a ("devlink: allow registering parameters after the instance")
      
      Also, the alternative fix (which also fixed another issue) was done by:
      commit 74cbc3c0
      
       ("mlxsw: spectrum_acl_tcam: Move devlink param to TCAM code").
      
      Therefore, the checks are no longer relevant. Each driver should make
      sure to have the params registered only when the memory the ops
      are working with is allocated and initialized.
      
      So remove the checks.
      
      Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      93f4a0b7
    • Tomislav Novak's avatar
      hw_breakpoint: fix single-stepping when using bpf_overflow_handler · aadb178c
      Tomislav Novak authored
      [ Upstream commit d11a6987
      
       ]
      
      Arm platforms use is_default_overflow_handler() to determine if the
      hw_breakpoint code should single-step over the breakpoint trigger or
      let the custom handler deal with it.
      
      Since bpf_overflow_handler() currently isn't recognized as a default
      handler, attaching a BPF program to a PERF_TYPE_BREAKPOINT event causes
      it to keep firing (the instruction triggering the data abort exception
      is never skipped). For example:
      
        # bpftrace -e 'watchpoint:0x10000:4:w { print("hit") }' -c ./test
        Attaching 1 probe...
        hit
        hit
        [...]
        ^C
      
      (./test performs a single 4-byte store to 0x10000)
      
      This patch replaces the check with uses_default_overflow_handler(),
      which accounts for the bpf_overflow_handler() case by also testing
      if one of the perf_event_output functions gets invoked indirectly,
      via orig_default_handler.
      
      Signed-off-by: default avatarTomislav Novak <tnovak@meta.com>
      Tested-by: Samuel Gosselin <sgosselin@google.com> # arm64
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/linux-arm-kernel/20220923203644.2731604-1-tnovak@fb.com/
      Link: https://lore.kernel.org/r/20230605191923.1219974-1-tnovak@meta.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aadb178c
    • Yicong Yang's avatar
      perf/smmuv3: Enable HiSilicon Erratum 162001900 quirk for HIP08/09 · cb37e7fa
      Yicong Yang authored
      [ Upstream commit 0242737d
      
       ]
      
      Some HiSilicon SMMU PMCG suffers the erratum 162001900 that the PMU
      disable control sometimes fail to disable the counters. This will lead
      to error or inaccurate data since before we enable the counters the
      counter's still counting for the event used in last perf session.
      
      This patch tries to fix this by hardening the global disable process.
      Before disable the PMU, writing an invalid event type (0xffff) to
      focibly stop the counters. Correspondingly restore each events on
      pmu::pmu_enable().
      
      Signed-off-by: default avatarYicong Yang <yangyicong@hisilicon.com>
      Link: https://lore.kernel.org/r/20230814124012.58013-1-yangyicong@huawei.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cb37e7fa
    • Jiri Slaby (SUSE)'s avatar
      ACPI: video: Add backlight=native DMI quirk for Lenovo Ideapad Z470 · 4de282f4
      Jiri Slaby (SUSE) authored
      [ Upstream commit 96b709be
      
       ]
      
      The Lenovo Ideapad Z470 predates Windows 8, so it defaults to using
      acpi_video for backlight control. But this is not functional on this
      model.
      
      Add a DMI quirk to use the native backlight interface which works.
      
      Link: https://bugzilla.suse.com/show_bug.cgi?id=1208724
      Signed-off-by: default avatarJiri Slaby (SUSE) <jirislaby@kernel.org>
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4de282f4
    • Wander Lairson Costa's avatar
      kernel/fork: beware of __put_task_struct() calling context · d0a13c39
      Wander Lairson Costa authored
      [ Upstream commit d243b344
      
       ]
      
      Under PREEMPT_RT, __put_task_struct() indirectly acquires sleeping
      locks. Therefore, it can't be called from an non-preemptible context.
      
      One practical example is splat inside inactive_task_timer(), which is
      called in a interrupt context:
      
        CPU: 1 PID: 2848 Comm: life Kdump: loaded Tainted: G W ---------
         Hardware name: HP ProLiant DL388p Gen8, BIOS P70 07/15/2012
         Call Trace:
         dump_stack_lvl+0x57/0x7d
         mark_lock_irq.cold+0x33/0xba
         mark_lock+0x1e7/0x400
         mark_usage+0x11d/0x140
         __lock_acquire+0x30d/0x930
         lock_acquire.part.0+0x9c/0x210
         rt_spin_lock+0x27/0xe0
         refill_obj_stock+0x3d/0x3a0
         kmem_cache_free+0x357/0x560
         inactive_task_timer+0x1ad/0x340
         __run_hrtimer+0x8a/0x1a0
         __hrtimer_run_queues+0x91/0x130
         hrtimer_interrupt+0x10f/0x220
         __sysvec_apic_timer_interrupt+0x7b/0xd0
         sysvec_apic_timer_interrupt+0x4f/0xd0
         asm_sysvec_apic_timer_interrupt+0x12/0x20
         RIP: 0033:0x7fff196bf6f5
      
      Instead of calling __put_task_struct() directly, we defer it using
      call_rcu(). A more natural approach would use a workqueue, but since
      in PREEMPT_RT, we can't allocate dynamic memory from atomic context,
      the code would become more complex because we would need to put the
      work_struct instance in the task_struct and initialize it when we
      allocate a new task_struct.
      
      The issue is reproducible with stress-ng:
      
        while true; do
            stress-ng --sched deadline --sched-period 1000000000 \
      	      --sched-runtime 800000000 --sched-deadline \
      	      1000000000 --mmapfork 23 -t 20
        done
      
      Reported-by: default avatarHu Chunyu <chuhu@redhat.com>
      Suggested-by: default avatarOleg Nesterov <oleg@redhat.com>
      Suggested-by: default avatarValentin Schneider <vschneid@redhat.com>
      Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarWander Lairson Costa <wander@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230614122323.37957-2-wander@redhat.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d0a13c39
    • Abhishek Mainkar's avatar
      ACPICA: Add AML_NO_OPERAND_RESOLVE flag to Timer · 3bf4463e
      Abhishek Mainkar authored
      [ Upstream commit 3a21ffdb
      
       ]
      
      ACPICA commit 90310989a0790032f5a0140741ff09b545af4bc5
      
      According to the ACPI specification 19.6.134, no argument is required to be passed for ASL Timer instruction. For taking care of no argument, AML_NO_OPERAND_RESOLVE flag is added to ASL Timer instruction opcode.
      
      When ASL timer instruction interpreted by ACPI interpreter, getting error. After adding AML_NO_OPERAND_RESOLVE flag to ASL Timer instruction opcode, issue is not observed.
      
      =============================================================
      UBSAN: array-index-out-of-bounds in acpica/dswexec.c:401:12 index -1 is out of range for type 'union acpi_operand_object *[9]'
      CPU: 37 PID: 1678 Comm: cat Not tainted
      6.0.0-dev-th500-6.0.y-1+bcf8c46459e407-generic-64k
      HW name: NVIDIA BIOS v1.1.1-d7acbfc-dirty 12/19/2022 Call trace:
       dump_backtrace+0xe0/0x130
       show_stack+0x20/0x60
       dump_stack_lvl+0x68/0x84
       dump_stack+0x18/0x34
       ubsan_epilogue+0x10/0x50
       __ubsan_handle_out_of_bounds+0x80/0x90
       acpi_ds_exec_end_op+0x1bc/0x6d8
       acpi_ps_parse_loop+0x57c/0x618
       acpi_ps_parse_aml+0x1e0/0x4b4
       acpi_ps_execute_method+0x24c/0x2b8
       acpi_ns_evaluate+0x3a8/0x4bc
       acpi_evaluate_object+0x15c/0x37c
       acpi_evaluate_integer+0x54/0x15c
       show_power+0x8c/0x12c [acpi_power_meter]
      
      Link: https://github.com/acpica/acpica/commit/90310989
      Signed-off-by: default avatarAbhishek Mainkar <abmainkar@nvidia.com>
      Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3bf4463e
    • Will Shiu's avatar
      locks: fix KASAN: use-after-free in trace_event_raw_event_filelock_lock · 117fb80c
      Will Shiu authored
      [ Upstream commit 74f6f591
      
       ]
      
      As following backtrace, the struct file_lock request , in posix_lock_inode
      is free before ftrace function using.
      Replace the ftrace function ahead free flow could fix the use-after-free
      issue.
      
      [name:report&]===============================================
      BUG:KASAN: use-after-free in trace_event_raw_event_filelock_lock+0x80/0x12c
      [name:report&]Read at addr f6ffff8025622620 by task NativeThread/16753
      [name:report_hw_tags&]Pointer tag: [f6], memory tag: [fe]
      [name:report&]
      BT:
      Hardware name: MT6897 (DT)
      Call trace:
       dump_backtrace+0xf8/0x148
       show_stack+0x18/0x24
       dump_stack_lvl+0x60/0x7c
       print_report+0x2c8/0xa08
       kasan_report+0xb0/0x120
       __do_kernel_fault+0xc8/0x248
       do_bad_area+0x30/0xdc
       do_tag_check_fault+0x1c/0x30
       do_mem_abort+0x58/0xbc
       el1_abort+0x3c/0x5c
       el1h_64_sync_handler+0x54/0x90
       el1h_64_sync+0x68/0x6c
       trace_event_raw_event_filelock_lock+0x80/0x12c
       posix_lock_inode+0xd0c/0xd60
       do_lock_file_wait+0xb8/0x190
       fcntl_setlk+0x2d8/0x440
      ...
      [name:report&]
      [name:report&]Allocated by task 16752:
      ...
       slab_post_alloc_hook+0x74/0x340
       kmem_cache_alloc+0x1b0/0x2f0
       posix_lock_inode+0xb0/0xd60
      ...
       [name:report&]
       [name:report&]Freed by task 16752:
      ...
        kmem_cache_free+0x274/0x5b0
        locks_dispose_list+0x3c/0x148
        posix_lock_inode+0xc40/0xd60
        do_lock_file_wait+0xb8/0x190
        fcntl_setlk+0x2d8/0x440
        do_fcntl+0x150/0xc18
      ...
      
      Signed-off-by: default avatarWill Shiu <Will.Shiu@mediatek.com>
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      117fb80c
    • Qu Wenruo's avatar
      btrfs: output extra debug info if we failed to find an inline backref · 7afbfde4
      Qu Wenruo authored
      [ Upstream commit 7f72f505
      
       ]
      
      [BUG]
      Syzbot reported several warning triggered inside
      lookup_inline_extent_backref().
      
      [CAUSE]
      As usual, the reproducer doesn't reliably trigger locally here, but at
      least we know the WARN_ON() is triggered when an inline backref can not
      be found, and it can only be triggered when @insert is true. (I.e.
      inserting a new inline backref, which means the backref should already
      exist)
      
      [ENHANCEMENT]
      After the WARN_ON(), dump all the parameters and the extent tree
      leaf to help debug.
      
      Link: https://syzkaller.appspot.com/bug?extid=d6f9ff86c1d804ba2bc6
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7afbfde4
    • Fedor Pchelkin's avatar
      autofs: fix memory leak of waitqueues in autofs_catatonic_mode · 6079dc77
      Fedor Pchelkin authored
      [ Upstream commit ccbe77f7
      
       ]
      
      Syzkaller reports a memory leak:
      
      BUG: memory leak
      unreferenced object 0xffff88810b279e00 (size 96):
        comm "syz-executor399", pid 3631, jiffies 4294964921 (age 23.870s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 08 9e 27 0b 81 88 ff ff  ..........'.....
          08 9e 27 0b 81 88 ff ff 00 00 00 00 00 00 00 00  ..'.............
        backtrace:
          [<ffffffff814cfc90>] kmalloc_trace+0x20/0x90 mm/slab_common.c:1046
          [<ffffffff81bb75ca>] kmalloc include/linux/slab.h:576 [inline]
          [<ffffffff81bb75ca>] autofs_wait+0x3fa/0x9a0 fs/autofs/waitq.c:378
          [<ffffffff81bb88a7>] autofs_do_expire_multi+0xa7/0x3e0 fs/autofs/expire.c:593
          [<ffffffff81bb8c33>] autofs_expire_multi+0x53/0x80 fs/autofs/expire.c:619
          [<ffffffff81bb6972>] autofs_root_ioctl_unlocked+0x322/0x3b0 fs/autofs/root.c:897
          [<ffffffff81bb6a95>] autofs_root_ioctl+0x25/0x30 fs/autofs/root.c:910
          [<ffffffff81602a9c>] vfs_ioctl fs/ioctl.c:51 [inline]
          [<ffffffff81602a9c>] __do_sys_ioctl fs/ioctl.c:870 [inline]
          [<ffffffff81602a9c>] __se_sys_ioctl fs/ioctl.c:856 [inline]
          [<ffffffff81602a9c>] __x64_sys_ioctl+0xfc/0x140 fs/ioctl.c:856
          [<ffffffff84608225>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
          [<ffffffff84608225>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
          [<ffffffff84800087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      autofs_wait_queue structs should be freed if their wait_ctr becomes zero.
      Otherwise they will be lost.
      
      In this case an AUTOFS_IOC_EXPIRE_MULTI ioctl is done, then a new
      waitqueue struct is allocated in autofs_wait(), its initial wait_ctr
      equals 2. After that wait_event_killable() is interrupted (it returns
      -ERESTARTSYS), so that 'wq->name.name == NULL' condition may be not
      satisfied. Actually, this condition can be satisfied when
      autofs_wait_release() or autofs_catatonic_mode() is called and, what is
      also important, wait_ctr is decremented in those places. Upon the exit of
      autofs_wait(), wait_ctr is decremented to 1. Then the unmounting process
      begins: kill_sb calls autofs_catatonic_mode(), which should have freed the
      waitqueues, but it only decrements its usage counter to zero which is not
      a correct behaviour.
      
      edit:imk
      This description is of course not correct. The umount performed as a result
      of an expire is a umount of a mount that has been automounted, it's not the
      autofs mount itself. They happen independently, usually after everything
      mounted within the autofs file system has been expired away. If everything
      hasn't been expired away the automount daemon can still exit leaving mounts
      in place. But expires done in both cases will result in a notification that
      calls autofs_wait_release() with a result status. The problem case is the
      summary execution of of the automount daemon. In this case any waiting
      processes won't be woken up until either they are terminated or the mount
      is umounted.
      end edit: imk
      
      So in catatonic mode we should free waitqueues which counter becomes zero.
      
      edit: imk
      Initially I was concerned that the calling of autofs_wait_release() and
      autofs_catatonic_mode() was not mutually exclusive but that can't be the
      case (obviously) because the queue entry (or entries) is removed from the
      list when either of these two functions are called. Consequently the wait
      entry will be freed by only one of these functions or by the woken process
      in autofs_wait() depending on the order of the calls.
      end edit: imk
      
      Reported-by: default avatar <syzbot+5e53f70e69ff0c0a1c0c@syzkaller.appspotmail.com>
      Suggested-by: default avatarTakeshi Misawa <jeliantsurux@gmail.com>
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Andrei Vagin <avagin@gmail.com>
      Cc: autofs@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Message-Id: <169112719161.7590.6700123246297365841.stgit@donald.themaw.net>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6079dc77
    • Helge Deller's avatar
      parisc: Drop loops_per_jiffy from per_cpu struct · 8c027a57
      Helge Deller authored
      commit 93346da8
      
       upstream.
      
      There is no need to keep a loops_per_jiffy value per cpu. Drop it.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c027a57
    • Wesley Chalmers's avatar
      drm/amd/display: Fix a bug when searching for insert_above_mpcc · 4316b829
      Wesley Chalmers authored
      commit 3d028d5d
      
       upstream.
      
      [WHY]
      Currently, when insert_plane is called with insert_above_mpcc
      parameter that is equal to tree->opp_list, the function returns NULL.
      
      [HOW]
      Instead, the function should insert the plane at the top of the tree.
      
      Cc: Mario Limonciello <mario.limonciello@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarJun Lei <jun.lei@amd.com>
      Acked-by: default avatarTom Chung <chiahsuan.chung@amd.com>
      Signed-off-by: default avatarWesley Chalmers <wesley.chalmers@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4316b829