1. 12 1月, 2023 40 次提交
    • M
      ACPI: video: Don't enable fallback path for creating ACPI backlight by default · 9c152189
      Mario Limonciello 提交于
      [ Upstream commit 5aa9d943 ]
      
      The ACPI video detection code has a module parameter
      `register_backlight_delay` which is currently configured to 8 seconds.
      This means that if after 8 seconds of booting no native driver has created
      a backlight device then the code will attempt to make an ACPI video
      backlight device.
      
      This was intended as a safety mechanism with the backlight overhaul that
      occurred in kernel 6.1, but as it doesn't appear necesssary set it to be
      disabled by default.
      Suggested-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NMario Limonciello <mario.limonciello@amd.com>
      Reviewed-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9c152189
    • M
      drm/amd/display: Report to ACPI video if no panels were found · adaf41b5
      Mario Limonciello 提交于
      [ Upstream commit c573e240 ]
      
      On desktop APUs amdgpu doesn't create a native backlight device
      as no eDP panels are found.  However if the BIOS has reported
      backlight control methods in the ACPI tables then an acpi_video0
      backlight device will be made 8 seconds after boot.
      
      This has manifested in a power slider on a number of desktop APUs
      ranging from Ryzen 5000 through Ryzen 7000 on various motherboard
      manufacturers. To avoid this, report to the acpi video detection
      that the system does not have any panel connected in the native
      driver.
      
      Link: https://bugzilla.redhat.com/show_bug.cgi?id=1783786Reported-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NMario Limonciello <mario.limonciello@amd.com>
      Reviewed-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      adaf41b5
    • M
      ACPI: video: Allow GPU drivers to report no panels · 0ba8892d
      Mario Limonciello 提交于
      [ Upstream commit 00a73410 ]
      
      The current logic for the ACPI backlight detection will create
      a backlight device if no native or vendor drivers have created
      8 seconds after the system has booted if the ACPI tables
      included backlight control methods.
      
      If the GPU drivers have loaded, they may be able to report whether
      any LCD panels were found.  Allow using this information to factor
      in whether to enable the fallback logic for making an acpi_video0
      backlight device.
      Suggested-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NMario Limonciello <mario.limonciello@amd.com>
      Reviewed-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      0ba8892d
    • Y
      nvme: fix multipath crash caused by flush request when blktrace is enabled · 183c2aae
      Yanjun Zhang 提交于
      [ Upstream commit 3659fb5a ]
      
      The flush request initialized by blk_kick_flush has NULL bio,
      and it may be dealt with nvme_end_req during io completion.
      When blktrace is enabled, nvme_trace_bio_complete with multipath
      activated trying to access NULL pointer bio from flush request
      results in the following crash:
      
      [ 2517.831677] BUG: kernel NULL pointer dereference, address: 000000000000001a
      [ 2517.835213] #PF: supervisor read access in kernel mode
      [ 2517.838724] #PF: error_code(0x0000) - not-present page
      [ 2517.842222] PGD 7b2d51067 P4D 0
      [ 2517.845684] Oops: 0000 [#1] SMP NOPTI
      [ 2517.849125] CPU: 2 PID: 732 Comm: kworker/2:1H Kdump: loaded Tainted: G S                5.15.67-0.cl9.x86_64 #1
      [ 2517.852723] Hardware name: XFUSION 2288H V6/BC13MBSBC, BIOS 1.13 07/27/2022
      [ 2517.856358] Workqueue: nvme_tcp_wq nvme_tcp_io_work [nvme_tcp]
      [ 2517.859993] RIP: 0010:blk_add_trace_bio_complete+0x6/0x30
      [ 2517.863628] Code: 1f 44 00 00 48 8b 46 08 31 c9 ba 04 00 10 00 48 8b 80 50 03 00 00 48 8b 78 50 e9 e5 fe ff ff 0f 1f 44 00 00 41 54 49 89 f4 55 <0f> b6 7a 1a 48 89 d5 e8 3e 1c 2b 00 48 89 ee 4c 89 e7 5d 89 c1 ba
      [ 2517.871269] RSP: 0018:ff7f6a008d9dbcd0 EFLAGS: 00010286
      [ 2517.875081] RAX: ff3d5b4be00b1d50 RBX: 0000000002040002 RCX: ff3d5b0a270f2000
      [ 2517.878966] RDX: 0000000000000000 RSI: ff3d5b0b021fb9f8 RDI: 0000000000000000
      [ 2517.882849] RBP: ff3d5b0b96a6fa00 R08: 0000000000000001 R09: 0000000000000000
      [ 2517.886718] R10: 000000000000000c R11: 000000000000000c R12: ff3d5b0b021fb9f8
      [ 2517.890575] R13: 0000000002000000 R14: ff3d5b0b021fb1b0 R15: 0000000000000018
      [ 2517.894434] FS:  0000000000000000(0000) GS:ff3d5b42bfc80000(0000) knlGS:0000000000000000
      [ 2517.898299] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 2517.902157] CR2: 000000000000001a CR3: 00000004f023e005 CR4: 0000000000771ee0
      [ 2517.906053] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [ 2517.909930] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [ 2517.913761] PKRU: 55555554
      [ 2517.917558] Call Trace:
      [ 2517.921294]  <TASK>
      [ 2517.924982]  nvme_complete_rq+0x1c3/0x1e0 [nvme_core]
      [ 2517.928715]  nvme_tcp_recv_pdu+0x4d7/0x540 [nvme_tcp]
      [ 2517.932442]  nvme_tcp_recv_skb+0x4f/0x240 [nvme_tcp]
      [ 2517.936137]  ? nvme_tcp_recv_pdu+0x540/0x540 [nvme_tcp]
      [ 2517.939830]  tcp_read_sock+0x9c/0x260
      [ 2517.943486]  nvme_tcp_try_recv+0x65/0xa0 [nvme_tcp]
      [ 2517.947173]  nvme_tcp_io_work+0x64/0x90 [nvme_tcp]
      [ 2517.950834]  process_one_work+0x1e8/0x390
      [ 2517.954473]  worker_thread+0x53/0x3c0
      [ 2517.958069]  ? process_one_work+0x390/0x390
      [ 2517.961655]  kthread+0x10c/0x130
      [ 2517.965211]  ? set_kthread_struct+0x40/0x40
      [ 2517.968760]  ret_from_fork+0x1f/0x30
      [ 2517.972285]  </TASK>
      
      To avoid this situation, add a NULL check for req->bio before
      calling trace_block_bio_complete.
      Signed-off-by: NYanjun Zhang <zhangyanjun@cestc.cn>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      183c2aae
    • J
      io_uring/cancel: re-grab ctx mutex after finishing wait · a288e98a
      Jens Axboe 提交于
      [ Upstream commit 23fffb2f ]
      
      If we have a signal pending during cancelations, it'll cause the
      task_work run to return an error. Since we didn't run task_work, the
      current task is left in TASK_INTERRUPTIBLE state when we need to
      re-grab the ctx mutex, and the kernel will rightfully complain about
      that.
      
      Move the lock grabbing for the error cases outside the loop to avoid
      that issue.
      
      Reported-by: syzbot+7df055631cd1be4586fd@syzkaller.appspotmail.com
      Link: https://lore.kernel.org/io-uring/0000000000003a14a905f05050b0@google.com/Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a288e98a
    • P
      drm/amdkfd: Fix double release compute pasid · a02c07b6
      Philip Yang 提交于
      [ Upstream commit 1a799c4c ]
      
      If kfd_process_device_init_vm returns failure after vm is converted to
      compute vm and vm->pasid set to compute pasid, KFD will not take
      pdd->drm_file reference. As a result, drm close file handler maybe
      called to release the compute pasid before KFD process destroy worker to
      release the same pasid and set vm->pasid to zero, this generates below
      WARNING backtrace and NULL pointer access.
      
      Add helper amdgpu_amdkfd_gpuvm_set_vm_pasid and call it at the last step
      of kfd_process_device_init_vm, to ensure vm pasid is the original pasid
      if acquiring vm failed or is the compute pasid with pdd->drm_file
      reference taken to avoid double release same pasid.
      
       amdgpu: Failed to create process VM object
       ida_free called for id=32770 which is not allocated.
       WARNING: CPU: 57 PID: 72542 at ../lib/idr.c:522 ida_free+0x96/0x140
       RIP: 0010:ida_free+0x96/0x140
       Call Trace:
        amdgpu_pasid_free_delayed+0xe1/0x2a0 [amdgpu]
        amdgpu_driver_postclose_kms+0x2d8/0x340 [amdgpu]
        drm_file_free.part.13+0x216/0x270 [drm]
        drm_close_helper.isra.14+0x60/0x70 [drm]
        drm_release+0x6e/0xf0 [drm]
        __fput+0xcc/0x280
        ____fput+0xe/0x20
        task_work_run+0x96/0xc0
        do_exit+0x3d0/0xc10
      
       BUG: kernel NULL pointer dereference, address: 0000000000000000
       RIP: 0010:ida_free+0x76/0x140
       Call Trace:
        amdgpu_pasid_free_delayed+0xe1/0x2a0 [amdgpu]
        amdgpu_driver_postclose_kms+0x2d8/0x340 [amdgpu]
        drm_file_free.part.13+0x216/0x270 [drm]
        drm_close_helper.isra.14+0x60/0x70 [drm]
        drm_release+0x6e/0xf0 [drm]
        __fput+0xcc/0x280
        ____fput+0xe/0x20
        task_work_run+0x96/0xc0
        do_exit+0x3d0/0xc10
      Signed-off-by: NPhilip Yang <Philip.Yang@amd.com>
      Reviewed-by: NFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a02c07b6
    • P
      drm/amdkfd: Fix kfd_process_device_init_vm error handling · 9d74d1f5
      Philip Yang 提交于
      [ Upstream commit 29d48b87 ]
      
      Should only destroy the ib_mem and let process cleanup worker to free
      the outstanding BOs. Reset the pointer in pdd->qpd structure, to avoid
      NULL pointer access in process destroy worker.
      
       BUG: kernel NULL pointer dereference, address: 0000000000000010
       Call Trace:
        amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel+0x46/0xb0 [amdgpu]
        kfd_process_device_destroy_cwsr_dgpu+0x40/0x70 [amdgpu]
        kfd_process_destroy_pdds+0x71/0x190 [amdgpu]
        kfd_process_wq_release+0x2a2/0x3b0 [amdgpu]
        process_one_work+0x2a1/0x600
        worker_thread+0x39/0x3d0
      Signed-off-by: NPhilip Yang <Philip.Yang@amd.com>
      Reviewed-by: NFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9d74d1f5
    • L
      drm/amdgpu: Fix size validation for non-exclusive domains (v4) · 8ba7c55e
      Luben Tuikov 提交于
      [ Upstream commit 7554886d ]
      
      Fix amdgpu_bo_validate_size() to check whether the TTM domain manager for the
      requested memory exists, else we get a kernel oops when dereferencing "man".
      
      v2: Make the patch standalone, i.e. not dependent on local patches.
      v3: Preserve old behaviour and just check that the manager pointer is not
          NULL.
      v4: Complain if GTT domain requested and it is uninitialized--most likely a
          bug.
      
      Cc: Alex Deucher <Alexander.Deucher@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Cc: AMD Graphics <amd-gfx@lists.freedesktop.org>
      Signed-off-by: NLuben Tuikov <luben.tuikov@amd.com>
      Reviewed-by: NChristian König <christian.koenig@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8ba7c55e
    • Y
      ASoC: SOF: mediatek: initialize panic_info to zero · b48f8c9a
      YC Hung 提交于
      [ Upstream commit 7bd220f2 ]
      
      Coverity spotted that panic_info is not initialized to zero in
      mtk_adsp_dump. Using uninitialized value panic_info.linenum when
      calling snd_sof_get_status. Fix this coverity by initializing
      panic_info struct as zero.
      Signed-off-by: NYC Hung <yc.hung@mediatek.com>
      Reviewed-by: NCurtis Malainey <cujomalainey@chromium.org>
      Link: https://lore.kernel.org/r/20221213115617.25086-1-yc.hung@mediatek.comSigned-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      b48f8c9a
    • H
      ASoC: Intel: bytcr_rt5640: Add quirk for the Advantech MICA-071 tablet · ee887708
      Hans de Goede 提交于
      [ Upstream commit a1dec9d7 ]
      
      The Advantech MICA-071 tablet deviates from the defaults for
      a non CR Bay Trail based tablet in several ways:
      
      1. It uses an analog MIC on IN3 rather then using DMIC1
      2. It only has 1 speaker
      3. It needs the OVCD current threshold to be set to 1500uA instead of
         the default 2000uA to reliable differentiate between headphones vs
         headsets
      
      Add a quirk with these settings for this tablet.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Acked-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20221213123246.11226-1-hdegoede@redhat.comSigned-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      ee887708
    • D
      9p/client: fix data race on req->status · 30f3e4af
      Dominique Martinet 提交于
      [ Upstream commit 1a4f69ef ]
      
      KCSAN reported a race between writing req->status in p9_client_cb and
      accessing it in p9_client_rpc's wait_event.
      
      Accesses to req itself is protected by the data barrier (writing req
      fields, write barrier, writing status // reading status, read barrier,
      reading other req fields), but status accesses themselves apparently
      also must be annotated properly with WRITE_ONCE/READ_ONCE when we
      access it without locks.
      
      Follows:
       - error paths writing status in various threads all can notify
      p9_client_rpc, so these all also need WRITE_ONCE
       - there's a similar read loop in trans_virtio for zc case that also
      needs READ_ONCE
       - other reads in trans_fd should be protected by the trans_fd lock and
      lists state machine, as corresponding writers all are within trans_fd
      and should be under the same lock. If KCSAN complains on them we likely
      will have something else to fix as well, so it's better to leave them
      unmarked and look again if required.
      
      Link: https://lkml.kernel.org/r/20221205124756.426350-1-asmadeus@codewreck.orgReported-by: NNaresh Kamboju <naresh.kamboju@linaro.org>
      Suggested-by: NMarco Elver <elver@google.com>
      Acked-by: NMarco Elver <elver@google.com>
      Reviewed-by: NChristian Schoenebeck <linux_oss@crudebyte.com>
      Signed-off-by: NDominique Martinet <asmadeus@codewreck.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      30f3e4af
    • K
      ASoC: SOF: Revert: "core: unregister clients and machine drivers in .shutdown" · f6e54852
      Kai Vehmanen 提交于
      [ Upstream commit 44fda61d ]
      
      The unregister machine drivers call is not safe to do when
      kexec is used. Kexec-lite gets blocked with following backtrace:
      
      [   84.943749] Freezing user space processes ... (elapsed 0.111 seconds) done.
      [  246.784446] INFO: task kexec-lite:5123 blocked for more than 122 seconds.
      [  246.819035] Call Trace:
      [  246.821782]  <TASK>
      [  246.824186]  __schedule+0x5f9/0x1263
      [  246.828231]  schedule+0x87/0xc5
      [  246.831779]  snd_card_disconnect_sync+0xb5/0x127
      ...
      [  246.889249]  snd_sof_device_shutdown+0xb4/0x150
      [  246.899317]  pci_device_shutdown+0x37/0x61
      [  246.903990]  device_shutdown+0x14c/0x1d6
      [  246.908391]  kernel_kexec+0x45/0xb9
      
      This reverts commit 83bfc7e7.
      Reported-by: NRicardo Ribalda <ribalda@chromium.org>
      Cc: Ricardo Ribalda <ribalda@chromium.org>
      Signed-off-by: NKai Vehmanen <kai.vehmanen@linux.intel.com>
      Reviewed-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Reviewed-by: NPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
      Reviewed-by: NRanjani Sridharan <ranjani.sridharan@linux.intel.com>
      Link: https://lore.kernel.org/r/20221209114529.3909192-3-kai.vehmanen@linux.intel.comSigned-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f6e54852
    • L
      hfs/hfsplus: avoid WARN_ON() for sanity check, use proper error handling · 45917be9
      Linus Torvalds 提交于
      [ Upstream commit cb7a95af ]
      
      Commit 55d1cbbb ("hfs/hfsplus: use WARN_ON for sanity check") fixed
      a build warning by turning a comment into a WARN_ON(), but it turns out
      that syzbot then complains because it can trigger said warning with a
      corrupted hfs image.
      
      The warning actually does warn about a bad situation, but we are much
      better off just handling it as the error it is.  So rather than warn
      about us doing bad things, stop doing the bad things and return -EIO.
      
      While at it, also fix a memory leak that was introduced by an earlier
      fix for a similar syzbot warning situation, and add a check for one case
      that historically wasn't handled at all (ie neither comment nor
      subsequent WARN_ON).
      
      Reported-by: syzbot+7bb7cd3595533513a9e7@syzkaller.appspotmail.com
      Fixes: 55d1cbbb ("hfs/hfsplus: use WARN_ON for sanity check")
      Fixes: 8d824e69 ("hfs: fix OOB Read in __hfs_brec_find")
      Link: https://lore.kernel.org/lkml/000000000000dbce4e05f170f289@google.com/Tested-by: NMichael Schmitz <schmitzmic@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Viacheslav Dubeyko <slava@dubeyko.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      45917be9
    • A
      usb: dwc3: xilinx: include linux/gpio/consumer.h · f190519b
      Arnd Bergmann 提交于
      [ Upstream commit e498a044 ]
      
      The newly added gpio consumer calls cause a build failure in configurations
      that fail to include the right header implicitly:
      
      drivers/usb/dwc3/dwc3-xilinx.c: In function 'dwc3_xlnx_init_zynqmp':
      drivers/usb/dwc3/dwc3-xilinx.c:207:22: error: implicit declaration of function 'devm_gpiod_get_optional'; did you mean 'devm_clk_get_optional'? [-Werror=implicit-function-declaration]
        207 |         reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
            |                      ^~~~~~~~~~~~~~~~~~~~~~~
            |                      devm_clk_get_optional
      
      Fixes: ca05b382 ("usb: dwc3: xilinx: Add gpio-reset support")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20230103121755.956027-1-arnd@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f190519b
    • J
      udf: Fix extension of the last extent in the file · 2d1dbb03
      Jan Kara 提交于
      [ Upstream commit 83c7423d ]
      
      When extending the last extent in the file within the last block, we
      wrongly computed the length of the last extent. This is mostly a
      cosmetical problem since the extent does not contain any data and the
      length will be fixed up by following operations but still.
      
      Fixes: 1f3868f0 ("udf: Fix extending file within last block")
      Signed-off-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      2d1dbb03
    • Z
      caif: fix memory leak in cfctrl_linkup_request() · 3ad47c8a
      Zhengchao Shao 提交于
      [ Upstream commit fe69230f ]
      
      When linktype is unknown or kzalloc failed in cfctrl_linkup_request(),
      pkt is not released. Add release process to error path.
      
      Fixes: b482cd20 ("net-caif: add CAIF core protocol stack")
      Fixes: 8d545c8f ("caif: Disconnect without waiting for response")
      Signed-off-by: NZhengchao Shao <shaozhengchao@huawei.com>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Link: https://lore.kernel.org/r/20230104065146.1153009-1-shaozhengchao@huawei.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      3ad47c8a
    • P
      net/ulp: prevent ULP without clone op from entering the LISTEN status · 7d242f4a
      Paolo Abeni 提交于
      [ Upstream commit 2c02d41d ]
      
      When an ULP-enabled socket enters the LISTEN status, the listener ULP data
      pointer is copied inside the child/accepted sockets by sk_clone_lock().
      
      The relevant ULP can take care of de-duplicating the context pointer via
      the clone() operation, but only MPTCP and SMC implement such op.
      
      Other ULPs may end-up with a double-free at socket disposal time.
      
      We can't simply clear the ULP data at clone time, as TLS replaces the
      socket ops with custom ones assuming a valid TLS ULP context is
      available.
      
      Instead completely prevent clone-less ULP sockets from entering the
      LISTEN status.
      
      Fixes: 734942cc ("tcp: ULP infrastructure")
      Reported-by: Nslipper <slipper.alive@gmail.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/4b80c3d1dbe3d0ab072f80450c202d9bc88b4b03.1672740602.git.pabeni@redhat.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      7d242f4a
    • C
      qed: allow sleep in qed_mcp_trace_dump() · 50c81b35
      Caleb Sander 提交于
      [ Upstream commit 5401c3e0 ]
      
      By default, qed_mcp_cmd_and_union() delays 10us at a time in a loop
      that can run 500K times, so calls to qed_mcp_nvm_rd_cmd()
      may block the current thread for over 5s.
      We observed thread scheduling delays over 700ms in production,
      with stacktraces pointing to this code as the culprit.
      
      qed_mcp_trace_dump() is called from ethtool, so sleeping is permitted.
      It already can sleep in qed_mcp_halt(), which calls qed_mcp_cmd().
      Add a "can sleep" parameter to qed_find_nvram_image() and
      qed_nvram_read() so they can sleep during qed_mcp_trace_dump().
      qed_mcp_trace_get_meta_info() and qed_mcp_trace_read_meta(),
      called only by qed_mcp_trace_dump(), allow these functions to sleep.
      I can't tell if the other caller (qed_grc_dump_mcp_hw_dump()) can sleep,
      so keep b_can_sleep set to false when it calls these functions.
      
      An example stacktrace from a custom warning we added to the kernel
      showing a thread that has not scheduled despite long needing resched:
      [ 2745.362925,17] ------------[ cut here ]------------
      [ 2745.362941,17] WARNING: CPU: 23 PID: 5640 at arch/x86/kernel/irq.c:233 do_IRQ+0x15e/0x1a0()
      [ 2745.362946,17] Thread not rescheduled for 744 ms after irq 99
      [ 2745.362956,17] Modules linked in: ...
      [ 2745.363339,17] CPU: 23 PID: 5640 Comm: lldpd Tainted: P           O    4.4.182+ #202104120910+6d1da174272d.61x
      [ 2745.363343,17] Hardware name: FOXCONN MercuryB/Quicksilver Controller, BIOS H11P1N09 07/08/2020
      [ 2745.363346,17]  0000000000000000 ffff885ec07c3ed8 ffffffff8131eb2f ffff885ec07c3f20
      [ 2745.363358,17]  ffffffff81d14f64 ffff885ec07c3f10 ffffffff81072ac2 ffff88be98ed0000
      [ 2745.363369,17]  0000000000000063 0000000000000174 0000000000000074 0000000000000000
      [ 2745.363379,17] Call Trace:
      [ 2745.363382,17]  <IRQ>  [<ffffffff8131eb2f>] dump_stack+0x8e/0xcf
      [ 2745.363393,17]  [<ffffffff81072ac2>] warn_slowpath_common+0x82/0xc0
      [ 2745.363398,17]  [<ffffffff81072b4c>] warn_slowpath_fmt+0x4c/0x50
      [ 2745.363404,17]  [<ffffffff810d5a8e>] ? rcu_irq_exit+0xae/0xc0
      [ 2745.363408,17]  [<ffffffff817c99fe>] do_IRQ+0x15e/0x1a0
      [ 2745.363413,17]  [<ffffffff817c7ac9>] common_interrupt+0x89/0x89
      [ 2745.363416,17]  <EOI>  [<ffffffff8132aa74>] ? delay_tsc+0x24/0x50
      [ 2745.363425,17]  [<ffffffff8132aa04>] __udelay+0x34/0x40
      [ 2745.363457,17]  [<ffffffffa04d45ff>] qed_mcp_cmd_and_union+0x36f/0x7d0 [qed]
      [ 2745.363473,17]  [<ffffffffa04d5ced>] qed_mcp_nvm_rd_cmd+0x4d/0x90 [qed]
      [ 2745.363490,17]  [<ffffffffa04e1dc7>] qed_mcp_trace_dump+0x4a7/0x630 [qed]
      [ 2745.363504,17]  [<ffffffffa04e2556>] ? qed_fw_asserts_dump+0x1d6/0x1f0 [qed]
      [ 2745.363520,17]  [<ffffffffa04e4ea7>] qed_dbg_mcp_trace_get_dump_buf_size+0x37/0x80 [qed]
      [ 2745.363536,17]  [<ffffffffa04ea881>] qed_dbg_feature_size+0x61/0xa0 [qed]
      [ 2745.363551,17]  [<ffffffffa04eb427>] qed_dbg_all_data_size+0x247/0x260 [qed]
      [ 2745.363560,17]  [<ffffffffa0482c10>] qede_get_regs_len+0x30/0x40 [qede]
      [ 2745.363566,17]  [<ffffffff816c9783>] ethtool_get_drvinfo+0xe3/0x190
      [ 2745.363570,17]  [<ffffffff816cc152>] dev_ethtool+0x1362/0x2140
      [ 2745.363575,17]  [<ffffffff8109bcc6>] ? finish_task_switch+0x76/0x260
      [ 2745.363580,17]  [<ffffffff817c2116>] ? __schedule+0x3c6/0x9d0
      [ 2745.363585,17]  [<ffffffff810dbd50>] ? hrtimer_start_range_ns+0x1d0/0x370
      [ 2745.363589,17]  [<ffffffff816c1e5b>] ? dev_get_by_name_rcu+0x6b/0x90
      [ 2745.363594,17]  [<ffffffff816de6a8>] dev_ioctl+0xe8/0x710
      [ 2745.363599,17]  [<ffffffff816a58a8>] sock_do_ioctl+0x48/0x60
      [ 2745.363603,17]  [<ffffffff816a5d87>] sock_ioctl+0x1c7/0x280
      [ 2745.363608,17]  [<ffffffff8111f393>] ? seccomp_phase1+0x83/0x220
      [ 2745.363612,17]  [<ffffffff811e3503>] do_vfs_ioctl+0x2b3/0x4e0
      [ 2745.363616,17]  [<ffffffff811e3771>] SyS_ioctl+0x41/0x70
      [ 2745.363619,17]  [<ffffffff817c6ffe>] entry_SYSCALL_64_fastpath+0x1e/0x79
      [ 2745.363622,17] ---[ end trace f6954aa440266421 ]---
      
      Fixes: c965db44 ("qed: Add support for debug data collection")
      Signed-off-by: NCaleb Sander <csander@purestorage.com>
      Acked-by: NAlok Prasad <palok@marvell.com>
      Link: https://lore.kernel.org/r/20230103233021.1457646-1-csander@purestorage.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      50c81b35
    • M
      ublk: honor IO_URING_F_NONBLOCK for handling control command · 4e0c2961
      Ming Lei 提交于
      [ Upstream commit fa8e442e ]
      
      Most of control command handlers may sleep, so return -EAGAIN in case
      of IO_URING_F_NONBLOCK to defer the handling into io wq context.
      
      Fixes: 71f28f31 ("ublk_drv: add io_uring based userspace block driver")
      Reported-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20230104133235.836536-1-ming.lei@redhat.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      4e0c2961
    • Z
      drm/i915/gvt: fix double free bug in split_2MB_gtt_entry · 1022519d
      Zheng Wang 提交于
      [ Upstream commit 4a61648a ]
      
      If intel_gvt_dma_map_guest_page failed, it will call
      ppgtt_invalidate_spt, which will finally free the spt.
      But the caller function ppgtt_populate_spt_by_guest_entry
      does not notice that, it will free spt again in its error
      path.
      
      Fix this by canceling the mapping of DMA address and freeing sub_spt.
      Besides, leave the handle of spt destroy to caller function instead
      of callee function when error occurs.
      
      Fixes: b901b252 ("drm/i915/gvt: Add 2M huge gtt support")
      Signed-off-by: NZheng Wang <zyytlz.wz@163.com>
      Reviewed-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20221229165641.1192455-1-zyytlz.wz@163.comSigned-off-by: NSasha Levin <sashal@kernel.org>
      1022519d
    • D
      drm/i915: unpin on error in intel_vgpu_shadow_mm_pin() · 20a07570
      Dan Carpenter 提交于
      [ Upstream commit 3792fc50 ]
      
      Call intel_vgpu_unpin_mm() on this error path.
      
      Fixes: 41874148 ("drm/i915/gvt: Adding ppgtt to GVT GEM context after shadow pdps settled.")
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/Y3OQ5tgZIVxyQ/WV@kiliReviewed-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      20a07570
    • N
      perf stat: Fix handling of --for-each-cgroup with --bpf-counters to match non BPF mode · c776df09
      Namhyung Kim 提交于
      [ Upstream commit 54b353a2 ]
      
      The --for-each-cgroup can have the same cgroup multiple times, but this
      confuses BPF counters (since they have the same cgroup id), making only
      the last cgroup events to be counted.
      
      Let's check the cgroup name before adding a new entry to the cgroups
      list.
      
      Before:
      
        $ sudo ./perf stat -a --bpf-counters --for-each-cgroup /,/ sleep 1
      
         Performance counter stats for 'system wide':
      
             <not counted> msec cpu-clock                        /
             <not counted>      context-switches                 /
             <not counted>      cpu-migrations                   /
             <not counted>      page-faults                      /
             <not counted>      cycles                           /
             <not counted>      instructions                     /
             <not counted>      branches                         /
             <not counted>      branch-misses                    /
                  8,016.04 msec cpu-clock                        /                #    7.998 CPUs utilized
                     6,152      context-switches                 /                #  767.461 /sec
                       250      cpu-migrations                   /                #   31.187 /sec
                       442      page-faults                      /                #   55.139 /sec
               613,111,487      cycles                           /                #    0.076 GHz
               280,599,604      instructions                     /                #    0.46  insn per cycle
                57,692,724      branches                         /                #    7.197 M/sec
                 3,385,168      branch-misses                    /                #    5.87% of all branches
      
               1.002220125 seconds time elapsed
      
      After it becomes similar to the non-BPF mode:
      
        $ sudo ./perf stat -a --bpf-counters --for-each-cgroup /,/  sleep 1
      
         Performance counter stats for 'system wide':
      
                  8,013.38 msec cpu-clock                        /                #    7.998 CPUs utilized
                     6,859      context-switches                 /                #  855.944 /sec
                       334      cpu-migrations                   /                #   41.680 /sec
                       345      page-faults                      /                #   43.053 /sec
               782,326,119      cycles                           /                #    0.098 GHz
               471,645,724      instructions                     /                #    0.60  insn per cycle
                94,963,430      branches                         /                #   11.851 M/sec
                 3,685,511      branch-misses                    /                #    3.88% of all branches
      
               1.001864539 seconds time elapsed
      
      Committer notes:
      
      As a reminder, to test with BPF counters one has to use BUILD_BPF_SKEL=1
      in the make command line and have clang/llvm installed when building
      perf, otherwise the --bpf-counters option will not be available:
      
        # perf stat -a --bpf-counters --for-each-cgroup /,/ sleep 1
        Error: unknown option `bpf-counters'
      
         Usage: perf stat [<options>] [<command>]
      
            -a, --all-cpus        system-wide collection from all CPUs
        <SNIP>
        #
      
      Fixes: bb1c15b6 ("perf stat: Support regex pattern in --for-each-cgroup")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: bpf@vger.kernel.org
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/r/20230104064402.1551516-5-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c776df09
    • N
      perf stat: Fix handling of unsupported cgroup events when using BPF counters · 36caf028
      Namhyung Kim 提交于
      [ Upstream commit 2d656b0f ]
      
      When --for-each-cgroup option is used, it fails when any of events is
      not supported and exits immediately.  This is not how 'perf stat'
      handles unsupported events.
      
      Let's ignore the failure and proceed with others so that the output is
      similar to when BPF counters are not used:
      
      Before:
      
        $ sudo ./perf stat -a --bpf-counters -e L1-icache-loads,L1-dcache-loads --for-each-cgroup system.slice,user.slice sleep 1
        Failed to open first cgroup events
        $
      
      After it shows output similat to when --bpf-counters isn't specified:
      
        $ sudo ./perf stat -a --bpf-counters -e L1-icache-loads,L1-dcache-loads --for-each-cgroup system.slice,user.slice sleep 1
      
         Performance counter stats for 'system wide':
      
           <not supported>      L1-icache-loads                  system.slice
                29,892,418      L1-dcache-loads                  system.slice
           <not supported>      L1-icache-loads                  user.slice
                52,497,220      L1-dcache-loads                  user.slice
        $
      
      Fixes: 944138f0 ("perf stat: Enable BPF counter with --for-each-cgroup")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/r/20230104064402.1551516-4-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      36caf028
    • T
      perf lock contention: Fix core dump related to not finding the "__sched_text_end" symbol on s/390 · 75b90860
      Thomas Richter 提交于
      [ Upstream commit d8d85ce8 ]
      
      The test case perf lock contention dumps core on s390. Run the following
      commands:
      
        # ./perf lock record -- ./perf bench sched messaging
        # Running 'sched/messaging' benchmark:
        # 20 sender and receiver processes per group
        # 10 groups == 400 processes run
      
            Total time: 2.799 [sec]
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.073 MB perf.data (100 samples) ]
        #
        # ./perf lock contention
        Segmentation fault (core dumped)
        #
      
      The function call stack is lengthy, here are the top 5 functions:
      
        # gdb ./perf core.24048
        GNU gdb (GDB) Fedora Linux 12.1-6.fc37
        Core was generated by `./perf lock contention'.
        Program terminated with signal SIGSEGV, Segmentation fault.
        #0  0x00000000011dd25c in machine__is_lock_function (machine=0x3029e28, addr=1789230) at util/machine.c:3356
               3356 machine->sched.text_end = kmap->unmap_ip(kmap, sym->start);
      
       (gdb) where
        #0  0x00000000011dd25c in machine__is_lock_function (machine=0x3029e28, addr=1789230) at util/machine.c:3356
        #1  0x000000000109f244 in callchain_id (evsel=0x30313e0, sample=0x3ffea4f77d0) at builtin-lock.c:957
        #2  0x000000000109e094 in get_key_by_aggr_mode (key=0x3ffea4f7290, addr=27758136, evsel=0x30313e0, sample=0x3ffea4f77d0) at builtin-lock.c:586
        #3  0x000000000109f4d0 in report_lock_contention_begin_event (evsel=0x30313e0, sample=0x3ffea4f77d0) at builtin-lock.c:1004
        #4  0x00000000010a00ae in evsel__process_contention_begin (evsel=0x30313e0, sample=0x3ffea4f77d0) at builtin-lock.c:1254
        #5  0x00000000010a0e14 in process_sample_event (tool=0x3ffea4f8480, event=0x3ff85601ef8, sample=0x3ffea4f77d0, evsel=0x30313e0, machine=0x3029e28) at builtin-lock.c:1464
        .....
      
      The issue is in function machine__is_lock_function() in file
      ./util/machine.c lines 3355:
      
         /* should not fail from here */
         sym = machine__find_kernel_symbol_by_name(machine, "__sched_text_end", &kmap);
         machine->sched.text_end = kmap->unmap_ip(kmap, sym->start)
      
      On s390 the symbol __sched_text_end is *NOT* in the symbol list and the
      resulting pointer sym is set to NULL. The sym->start is then a NULL pointer
      access and generates the core dump.
      
      The reason why __sched_text_end is not in the symbol list on s390 is
      simple:
      
      When the symbol list is created at perf start up with function calls
      
        dso__load
        +--> dso__load_vmlinux_path
             +--> dso__load_vmlinux
                  +--> dso__load_sym
      	         +--> dso__load_sym_internal (reads kernel symbols)
      		 +--> symbols__fixup_end
      		 +--> symbols__fixup_duplicate
      
      The issue is in function symbols__fixup_duplicate(). It deletes all
      symbols with have the same address. On s390:
      
        # nm -g  ~/linux/vmlinux| fgrep c68390
        0000000000c68390 T __cpuidle_text_start
        0000000000c68390 T __sched_text_end
        #
      
      two symbols have identical addresses and __sched_text_end is considered
      duplicate (in ascending sort order) and removed from the symbol list.
      Therefore it is missing and an invalid pointer reference occurs.  The
      code checks for symbol __sched_text_start and when it exists assumes
      symbol __sched_text_end is also in the symbol table. However this is not
      the case on s390.
      
      Same situation exists for symbol __lock_text_start:
      
      0000000000c68770 T __cpuidle_text_end
      0000000000c68770 T __lock_text_start
      
      This symbol is also removed from the symbol table but used in function
      machine__is_lock_function().
      
      To fix this and keep duplicate symbols in the symbol table, set
      symbol_conf.allow_aliases to true. This prevents the removal of
      duplicate symbols in function symbols__fixup_duplicate().
      
      Output After:
      
       # ./perf lock contention
       contended total wait  max wait  avg wait    type   caller
      
              48   124.39 ms 123.99 ms   2.59 ms rwsem:W unlink_anon_vmas+0x24a
              47    83.68 ms  83.26 ms   1.78 ms rwsem:W free_pgtables+0x132
               5    41.22 us  10.55 us   8.24 us rwsem:W free_pgtables+0x140
               4    40.12 us  20.55 us  10.03 us rwsem:W copy_process+0x1ac8
       #
      
      Fixes: 0d2997f7 ("perf lock: Look up callchain for the contended locks")
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20221230102627.2410847-1-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      75b90860
    • S
      usb: rndis_host: Secure rndis_query check against int overflow · a7136028
      Szymon Heidrich 提交于
      [ Upstream commit c7dd1380 ]
      
      Variables off and len typed as uint32 in rndis_query function
      are controlled by incoming RNDIS response message thus their
      value may be manipulated. Setting off to a unexpectetly large
      value will cause the sum with len and 8 to overflow and pass
      the implemented validation step. Consequently the response
      pointer will be referring to a location past the expected
      buffer boundaries allowing information leakage e.g. via
      RNDIS_OID_802_3_PERMANENT_ADDRESS OID.
      
      Fixes: ddda0862 ("USB: rndis_host, various cleanups")
      Signed-off-by: NSzymon Heidrich <szymon.heidrich@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a7136028
    • G
      octeontx2-pf: Fix lmtst ID used in aura free · 667ce030
      Geetha sowjanya 提交于
      [ Upstream commit 4af1b64f ]
      
      Current code uses per_cpu pointer to get the lmtst_id mapped to
      the core on which aura_free() is executed. Using per_cpu pointer
      without preemption disable causing mismatch between lmtst_id and
      core on which pointer gets freed. This patch fixes the issue by
      disabling preemption around aura_free.
      
      Fixes: ef6c8da7 ("octeontx2-pf: cn10K: Reserve LMTST lines per core")
      Signed-off-by: NSunil Goutham <sgoutham@marvell.com>
      Signed-off-by: NGeetha sowjanya <gakula@marvell.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      667ce030
    • D
      drivers/net/bonding/bond_3ad: return when there's no aggregator · faecbaf1
      Daniil Tatianin 提交于
      [ Upstream commit 9c807965 ]
      
      Otherwise we would dereference a NULL aggregator pointer when calling
      __set_agg_ports_ready on the line below.
      
      Found by Linux Verification Center (linuxtesting.org) with the SVACE
      static analysis tool.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: NDaniil Tatianin <d-tatianin@yandex-team.ru>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      faecbaf1
    • T
      fs/ntfs3: don't hold ni_lock when calling truncate_setsize() · 73fee7e1
      Tetsuo Handa 提交于
      [ Upstream commit 0226635c ]
      
      syzbot is reporting hung task at do_user_addr_fault() [1], for there is
      a silent deadlock between PG_locked bit and ni_lock lock.
      
      Since filemap_update_page() calls filemap_read_folio() after calling
      folio_trylock() which will set PG_locked bit, ntfs_truncate() must not
      call truncate_setsize() which will wait for PG_locked bit to be cleared
      when holding ni_lock lock.
      
      Link: https://lore.kernel.org/all/00000000000060d41f05f139aa44@google.com/
      Link: https://syzkaller.appspot.com/bug?extid=bed15dbf10294aa4f2ae [1]
      Reported-by: Nsyzbot <syzbot+bed15dbf10294aa4f2ae@syzkaller.appspotmail.com>
      Debugged-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Co-developed-by: NHillf Danton <hdanton@sina.com>
      Signed-off-by: NHillf Danton <hdanton@sina.com>
      Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Fixes: 4342306f ("fs/ntfs3: Add file operations and implementation")
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      73fee7e1
    • P
      drm/imx: ipuv3-plane: Fix overlay plane width · 71f9fd5b
      Philipp Zabel 提交于
      [ Upstream commit 92d43bd3 ]
      
      ipu_src_rect_width() was introduced to support odd screen resolutions
      such as 1366x768 by internally rounding up primary plane width to a
      multiple of 8 and compensating with reduced horizontal blanking.
      This also caused overlay plane width to be rounded up, which was not
      intended. Fix overlay plane width by limiting the rounding up to the
      primary plane.
      
      drm_rect_width(&new_state->src) >> 16 is the same value as
      drm_rect_width(dst) because there is no plane scaling support.
      
      Fixes: 94dfec48 ("drm/imx: Add 8 pixel alignment fix")
      Reviewed-by: NLucas Stach <l.stach@pengutronix.de>
      Link: https://lore.kernel.org/r/20221108141420.176696-1-p.zabel@pengutronix.deSigned-off-by: NPhilipp Zabel <p.zabel@pengutronix.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221108141420.176696-1-p.zabel@pengutronix.deTested-by: NIan Ray <ian.ray@ge.com>
      (cherry picked from commit 4333472f)
      Signed-off-by: NPhilipp Zabel <philipp.zabel@gmail.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      71f9fd5b
    • M
      perf tools: Fix resources leak in perf_data__open_dir() · 2bb8016d
      Miaoqian Lin 提交于
      [ Upstream commit 0a6564eb ]
      
      In perf_data__open_dir(), opendir() opens the directory stream.  Add
      missing closedir() to release it after use.
      
      Fixes: eb617670 ("perf data: Add perf_data__open_dir_data function")
      Reviewed-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NMiaoqian Lin <linmq006@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20221229090903.1402395-1-linmq006@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      2bb8016d
    • X
      drm/virtio: Fix memory leak in virtio_gpu_object_create() · 466655dd
      Xiu Jianfeng 提交于
      [ Upstream commit a764da46 ]
      
      The virtio_gpu_object_shmem_init() will alloc memory and save it in
      @ents, so when virtio_gpu_array_alloc() fails, this memory should be
      freed, this patch fixes it.
      
      Fixes: e7fef092 ("drm/virtio: Simplify error handling of virtio_gpu_object_create()")
      Signed-off-by: NXiu Jianfeng <xiujianfeng@huawei.com>
      Reviewed-by: NDmitry Osipenko <dmitry.osipenko@collabora.com>
      Signed-off-by: NDmitry Osipenko <dmitry.osipenko@collabora.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221109091905.55451-1-xiujianfeng@huawei.comSigned-off-by: NSasha Levin <sashal@kernel.org>
      466655dd
    • J
      netfilter: ipset: Rework long task execution when adding/deleting entries · 8964cc36
      Jozsef Kadlecsik 提交于
      [ Upstream commit 5e29dc36 ]
      
      When adding/deleting large number of elements in one step in ipset, it can
      take a reasonable amount of time and can result in soft lockup errors. The
      patch 5f7b51bf ("netfilter: ipset: Limit the maximal range of
      consecutive elements to add/delete") tried to fix it by limiting the max
      elements to process at all. However it was not enough, it is still possible
      that we get hung tasks. Lowering the limit is not reasonable, so the
      approach in this patch is as follows: rely on the method used at resizing
      sets and save the state when we reach a smaller internal batch limit,
      unlock/lock and proceed from the saved state. Thus we can avoid long
      continuous tasks and at the same time removed the limit to add/delete large
      number of elements in one step.
      
      The nfnl mutex is held during the whole operation which prevents one to
      issue other ipset commands in parallel.
      
      Fixes: 5f7b51bf ("netfilter: ipset: Limit the maximal range of consecutive elements to add/delete")
      Reported-by: syzbot+9204e7399656300bf271@syzkaller.appspotmail.com
      Signed-off-by: NJozsef Kadlecsik <kadlec@netfilter.org>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8964cc36
    • J
      netfilter: ipset: fix hash:net,port,net hang with /0 subnet · 080b56c6
      Jozsef Kadlecsik 提交于
      [ Upstream commit a31d47be ]
      
      The hash:net,port,net set type supports /0 subnets. However, the patch
      commit 5f7b51bf titled "netfilter: ipset: Limit the maximal range
      of consecutive elements to add/delete" did not take into account it and
      resulted in an endless loop. The bug is actually older but the patch
      5f7b51bf brings it out earlier.
      
      Handle /0 subnets properly in hash:net,port,net set types.
      
      Fixes: 5f7b51bf ("netfilter: ipset: Limit the maximal range of consecutive elements to add/delete")
      Reported-by: NМарк Коренберг <socketpair@gmail.com>
      Signed-off-by: NJozsef Kadlecsik <kadlec@netfilter.org>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      080b56c6
    • H
      net: sparx5: Fix reading of the MAC address · 2bab138b
      Horatiu Vultur 提交于
      [ Upstream commit 588ab2dc ]
      
      There is an issue with the checking of the return value of
      'of_get_mac_address', which returns 0 on success and negative value on
      failure. The driver interpretated the result the opposite way. Therefore
      if there was a MAC address defined in the DT, then the driver was
      generating a random MAC address otherwise it would use address 0.
      Fix this by checking correctly the return value of 'of_get_mac_address'
      
      Fixes: b74ef9f9 ("net: sparx5: Do not use mac_addr uninitialized in mchp_sparx5_probe()")
      Signed-off-by: NHoratiu Vultur <horatiu.vultur@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      2bab138b
    • I
      vxlan: Fix memory leaks in error path · 5896f558
      Ido Schimmel 提交于
      [ Upstream commit 06bf6294 ]
      
      The memory allocated by vxlan_vnigroup_init() is not freed in the error
      path, leading to memory leaks [1]. Fix by calling
      vxlan_vnigroup_uninit() in the error path.
      
      The leaks can be reproduced by annotating gro_cells_init() with
      ALLOW_ERROR_INJECTION() and then running:
      
       # echo "100" > /sys/kernel/debug/fail_function/probability
       # echo "1" > /sys/kernel/debug/fail_function/times
       # echo "gro_cells_init" > /sys/kernel/debug/fail_function/inject
       # printf %#x -12 > /sys/kernel/debug/fail_function/gro_cells_init/retval
       # ip link add name vxlan0 type vxlan dstport 4789 external vnifilter
       RTNETLINK answers: Cannot allocate memory
      
      [1]
      unreferenced object 0xffff88810db84a00 (size 512):
        comm "ip", pid 330, jiffies 4295010045 (age 66.016s)
        hex dump (first 32 bytes):
          f8 d5 76 0e 81 88 ff ff 01 00 00 00 00 00 00 02  ..v.............
          03 00 04 00 48 00 00 00 00 00 00 01 04 00 01 00  ....H...........
        backtrace:
          [<ffffffff81a3097a>] kmalloc_trace+0x2a/0x60
          [<ffffffff82f049fc>] vxlan_vnigroup_init+0x4c/0x160
          [<ffffffff82ecd69e>] vxlan_init+0x1ae/0x280
          [<ffffffff836858ca>] register_netdevice+0x57a/0x16d0
          [<ffffffff82ef67b7>] __vxlan_dev_create+0x7c7/0xa50
          [<ffffffff82ef6ce6>] vxlan_newlink+0xd6/0x130
          [<ffffffff836d02ab>] __rtnl_newlink+0x112b/0x18a0
          [<ffffffff836d0a8c>] rtnl_newlink+0x6c/0xa0
          [<ffffffff836c0ddf>] rtnetlink_rcv_msg+0x43f/0xd40
          [<ffffffff83908ce0>] netlink_rcv_skb+0x170/0x440
          [<ffffffff839066af>] netlink_unicast+0x53f/0x810
          [<ffffffff839072d8>] netlink_sendmsg+0x958/0xe70
          [<ffffffff835c319f>] ____sys_sendmsg+0x78f/0xa90
          [<ffffffff835cd6da>] ___sys_sendmsg+0x13a/0x1e0
          [<ffffffff835cd94c>] __sys_sendmsg+0x11c/0x1f0
          [<ffffffff8424da78>] do_syscall_64+0x38/0x80
      unreferenced object 0xffff88810e76d5f8 (size 192):
        comm "ip", pid 330, jiffies 4295010045 (age 66.016s)
        hex dump (first 32 bytes):
          04 00 00 00 00 00 00 00 db e1 4f e7 00 00 00 00  ..........O.....
          08 d6 76 0e 81 88 ff ff 08 d6 76 0e 81 88 ff ff  ..v.......v.....
        backtrace:
          [<ffffffff81a3162e>] __kmalloc_node+0x4e/0x90
          [<ffffffff81a0e166>] kvmalloc_node+0xa6/0x1f0
          [<ffffffff8276e1a3>] bucket_table_alloc.isra.0+0x83/0x460
          [<ffffffff8276f18b>] rhashtable_init+0x43b/0x7c0
          [<ffffffff82f04a1c>] vxlan_vnigroup_init+0x6c/0x160
          [<ffffffff82ecd69e>] vxlan_init+0x1ae/0x280
          [<ffffffff836858ca>] register_netdevice+0x57a/0x16d0
          [<ffffffff82ef67b7>] __vxlan_dev_create+0x7c7/0xa50
          [<ffffffff82ef6ce6>] vxlan_newlink+0xd6/0x130
          [<ffffffff836d02ab>] __rtnl_newlink+0x112b/0x18a0
          [<ffffffff836d0a8c>] rtnl_newlink+0x6c/0xa0
          [<ffffffff836c0ddf>] rtnetlink_rcv_msg+0x43f/0xd40
          [<ffffffff83908ce0>] netlink_rcv_skb+0x170/0x440
          [<ffffffff839066af>] netlink_unicast+0x53f/0x810
          [<ffffffff839072d8>] netlink_sendmsg+0x958/0xe70
          [<ffffffff835c319f>] ____sys_sendmsg+0x78f/0xa90
      
      Fixes: f9c4bb0b ("vxlan: vni filtering support on collect metadata device")
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: NNikolay Aleksandrov <razor@blackwall.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      5896f558
    • J
      net: sched: cbq: dont intepret cls results when asked to drop · dc46e39b
      Jamal Hadi Salim 提交于
      [ Upstream commit caa4b35b ]
      
      If asked to drop a packet via TC_ACT_SHOT it is unsafe to assume that
      res.class contains a valid pointer
      
      Sample splat reported by Kyle Zeng
      
      [    5.405624] 0: reclassify loop, rule prio 0, protocol 800
      [    5.406326] ==================================================================
      [    5.407240] BUG: KASAN: slab-out-of-bounds in cbq_enqueue+0x54b/0xea0
      [    5.407987] Read of size 1 at addr ffff88800e3122aa by task poc/299
      [    5.408731]
      [    5.408897] CPU: 0 PID: 299 Comm: poc Not tainted 5.10.155+ #15
      [    5.409516] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
      BIOS 1.15.0-1 04/01/2014
      [    5.410439] Call Trace:
      [    5.410764]  dump_stack+0x87/0xcd
      [    5.411153]  print_address_description+0x7a/0x6b0
      [    5.411687]  ? vprintk_func+0xb9/0xc0
      [    5.411905]  ? printk+0x76/0x96
      [    5.412110]  ? cbq_enqueue+0x54b/0xea0
      [    5.412323]  kasan_report+0x17d/0x220
      [    5.412591]  ? cbq_enqueue+0x54b/0xea0
      [    5.412803]  __asan_report_load1_noabort+0x10/0x20
      [    5.413119]  cbq_enqueue+0x54b/0xea0
      [    5.413400]  ? __kasan_check_write+0x10/0x20
      [    5.413679]  __dev_queue_xmit+0x9c0/0x1db0
      [    5.413922]  dev_queue_xmit+0xc/0x10
      [    5.414136]  ip_finish_output2+0x8bc/0xcd0
      [    5.414436]  __ip_finish_output+0x472/0x7a0
      [    5.414692]  ip_finish_output+0x5c/0x190
      [    5.414940]  ip_output+0x2d8/0x3c0
      [    5.415150]  ? ip_mc_finish_output+0x320/0x320
      [    5.415429]  __ip_queue_xmit+0x753/0x1760
      [    5.415664]  ip_queue_xmit+0x47/0x60
      [    5.415874]  __tcp_transmit_skb+0x1ef9/0x34c0
      [    5.416129]  tcp_connect+0x1f5e/0x4cb0
      [    5.416347]  tcp_v4_connect+0xc8d/0x18c0
      [    5.416577]  __inet_stream_connect+0x1ae/0xb40
      [    5.416836]  ? local_bh_enable+0x11/0x20
      [    5.417066]  ? lock_sock_nested+0x175/0x1d0
      [    5.417309]  inet_stream_connect+0x5d/0x90
      [    5.417548]  ? __inet_stream_connect+0xb40/0xb40
      [    5.417817]  __sys_connect+0x260/0x2b0
      [    5.418037]  __x64_sys_connect+0x76/0x80
      [    5.418267]  do_syscall_64+0x31/0x50
      [    5.418477]  entry_SYSCALL_64_after_hwframe+0x61/0xc6
      [    5.418770] RIP: 0033:0x473bb7
      [    5.418952] Code: 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00
      00 00 90 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2a 00 00
      00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 18 89 54 24 0c 48 89 34
      24 89
      [    5.420046] RSP: 002b:00007fffd20eb0f8 EFLAGS: 00000246 ORIG_RAX:
      000000000000002a
      [    5.420472] RAX: ffffffffffffffda RBX: 00007fffd20eb578 RCX: 0000000000473bb7
      [    5.420872] RDX: 0000000000000010 RSI: 00007fffd20eb110 RDI: 0000000000000007
      [    5.421271] RBP: 00007fffd20eb150 R08: 0000000000000001 R09: 0000000000000004
      [    5.421671] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
      [    5.422071] R13: 00007fffd20eb568 R14: 00000000004fc740 R15: 0000000000000002
      [    5.422471]
      [    5.422562] Allocated by task 299:
      [    5.422782]  __kasan_kmalloc+0x12d/0x160
      [    5.423007]  kasan_kmalloc+0x5/0x10
      [    5.423208]  kmem_cache_alloc_trace+0x201/0x2e0
      [    5.423492]  tcf_proto_create+0x65/0x290
      [    5.423721]  tc_new_tfilter+0x137e/0x1830
      [    5.423957]  rtnetlink_rcv_msg+0x730/0x9f0
      [    5.424197]  netlink_rcv_skb+0x166/0x300
      [    5.424428]  rtnetlink_rcv+0x11/0x20
      [    5.424639]  netlink_unicast+0x673/0x860
      [    5.424870]  netlink_sendmsg+0x6af/0x9f0
      [    5.425100]  __sys_sendto+0x58d/0x5a0
      [    5.425315]  __x64_sys_sendto+0xda/0xf0
      [    5.425539]  do_syscall_64+0x31/0x50
      [    5.425764]  entry_SYSCALL_64_after_hwframe+0x61/0xc6
      [    5.426065]
      [    5.426157] The buggy address belongs to the object at ffff88800e312200
      [    5.426157]  which belongs to the cache kmalloc-128 of size 128
      [    5.426955] The buggy address is located 42 bytes to the right of
      [    5.426955]  128-byte region [ffff88800e312200, ffff88800e312280)
      [    5.427688] The buggy address belongs to the page:
      [    5.427992] page:000000009875fabc refcount:1 mapcount:0
      mapping:0000000000000000 index:0x0 pfn:0xe312
      [    5.428562] flags: 0x100000000000200(slab)
      [    5.428812] raw: 0100000000000200 dead000000000100 dead000000000122
      ffff888007843680
      [    5.429325] raw: 0000000000000000 0000000000100010 00000001ffffffff
      ffff88800e312401
      [    5.429875] page dumped because: kasan: bad access detected
      [    5.430214] page->mem_cgroup:ffff88800e312401
      [    5.430471]
      [    5.430564] Memory state around the buggy address:
      [    5.430846]  ffff88800e312180: fc fc fc fc fc fc fc fc fc fc fc fc
      fc fc fc fc
      [    5.431267]  ffff88800e312200: 00 00 00 00 00 00 00 00 00 00 00 00
      00 00 00 fc
      [    5.431705] >ffff88800e312280: fc fc fc fc fc fc fc fc fc fc fc fc
      fc fc fc fc
      [    5.432123]                                   ^
      [    5.432391]  ffff88800e312300: 00 00 00 00 00 00 00 00 00 00 00 00
      00 00 00 fc
      [    5.432810]  ffff88800e312380: fc fc fc fc fc fc fc fc fc fc fc fc
      fc fc fc fc
      [    5.433229] ==================================================================
      [    5.433648] Disabling lock debugging due to kernel taint
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Reported-by: NKyle Zeng <zengyhkyle@gmail.com>
      Signed-off-by: NJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      dc46e39b
    • J
      net: sched: atm: dont intepret cls results when asked to drop · 85655c63
      Jamal Hadi Salim 提交于
      [ Upstream commit a2965c7b ]
      
      If asked to drop a packet via TC_ACT_SHOT it is unsafe to assume
      res.class contains a valid pointer
      Fixes: b0188d4d ("[NET_SCHED]: sch_atm: Lindent")
      Signed-off-by: NJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      85655c63
    • M
      gpio: sifive: Fix refcount leak in sifive_gpio_probe · 9a402a21
      Miaoqian Lin 提交于
      [ Upstream commit 694175cd ]
      
      of_irq_find_parent() returns a node pointer with refcount incremented,
      We should use of_node_put() on it when not needed anymore.
      Add missing of_node_put() to avoid refcount leak.
      
      Fixes: 96868dce ("gpio/sifive: Add GPIO driver for SiFive SoCs")
      Signed-off-by: NMiaoqian Lin <linmq006@gmail.com>
      Signed-off-by: NBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9a402a21
    • X
      ceph: switch to vfs_inode_has_locks() to fix file lock bug · 58988614
      Xiubo Li 提交于
      [ Upstream commit 461ab10e ]
      
      For the POSIX locks they are using the same owner, which is the
      thread id. And multiple POSIX locks could be merged into single one,
      so when checking whether the 'file' has locks may fail.
      
      For a file where some openers use locking and others don't is a
      really odd usage pattern though. Locks are like stoplights -- they
      only work if everyone pays attention to them.
      
      Just switch ceph_get_caps() to check whether any locks are set on
      the inode. If there are POSIX/OFD/FLOCK locks on the file at the
      time, we should set CHECK_FILELOCK, regardless of what fd was used
      to set the lock.
      
      Fixes: ff5d913d ("ceph: return -EIO if read/write against filp that lost file locks")
      Signed-off-by: NXiubo Li <xiubli@redhat.com>
      Reviewed-by: NJeff Layton <jlayton@kernel.org>
      Reviewed-by: NIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      58988614
    • J
      filelock: new helper: vfs_inode_has_locks · 516fac1e
      Jeff Layton 提交于
      [ Upstream commit ab1ddef9 ]
      
      Ceph has a need to know whether a particular inode has any locks set on
      it. It's currently tracking that by a num_locks field in its
      filp->private_data, but that's problematic as it tries to decrement this
      field when releasing locks and that can race with the file being torn
      down.
      
      Add a new vfs_inode_has_locks helper that just returns whether any locks
      are currently held on the inode.
      Reviewed-by: NXiubo Li <xiubli@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NJeff Layton <jlayton@kernel.org>
      Stable-dep-of: 461ab10e ("ceph: switch to vfs_inode_has_locks() to fix file lock bug")
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      516fac1e