Skip to content
  1. Jan 01, 2024
    • David Lechner's avatar
      iio: triggered-buffer: prevent possible freeing of wrong buffer · 01bc94b5
      David Lechner authored
      commit bce61476 upstream.
      
      Commit ee708e6b ("iio: buffer: introduce support for attaching more
      IIO buffers") introduced support for multiple buffers per indio_dev but
      left indio_dev->buffer for a few legacy use cases.
      
      In the case of the triggered buffer, iio_triggered_buffer_cleanup()
      still assumes that indio_dev->buffer points to the buffer allocated by
      iio_triggered_buffer_setup_ext(). However, since
      iio_triggered_buffer_setup_ext() now calls iio_device_attach_buffer()
      to attach the buffer, indio_dev->buffer will only point to the buffer
      allocated by iio_device_attach_buffer() if it the first buffer attached.
      
      This adds a check to make sure that no other buffer has been attached
      yet to ensure that indio_dev->buffer will be assigned when
      iio_device_attach_buffer() is called.
      
      As per discussion in the review thread, we may want to deal with multiple
      triggers per device, but this is a fix for the issue in the meantime and
      any such support would be unlikely to be suitable for a backport.
      
      Fixes: ee708e6b
      
       ("iio: buffer: introduce support for attaching more IIO buffers")
      Signed-off-by: default avatarDavid Lechner <dlechner@baylibre.com>
      Acked-by: default avatarNuno Sa <nuno.sa@analog.com>
      Link: https://lore.kernel.org/r/20231031210521.1661552-1-dlechner@baylibre.com
      
      
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      01bc94b5
    • Wadim Egorov's avatar
      iio: adc: ti_am335x_adc: Fix return value check of tiadc_request_dma() · c508a99f
      Wadim Egorov authored
      commit 60576e84 upstream.
      
      Fix wrong handling of a DMA request where the probing only failed
      if -EPROPE_DEFER was returned. Instead, let us fail if a non -ENODEV
      value is returned. This makes DMAs explicitly optional. Even if the
      DMA request is unsuccessfully, the ADC can still work properly.
      We do also handle the defer probe case by making use of dev_err_probe().
      
      Fixes: f438b9da
      
       ("drivers: iio: ti_am335x_adc: add dma support")
      Signed-off-by: default avatarWadim Egorov <w.egorov@phytec.de>
      Reviewed-by: default avatarBhavya Kapoor <b-kapoor@ti.com>
      Link: https://lore.kernel.org/r/20230925134427.214556-1-w.egorov@phytec.de
      
      
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c508a99f
    • Javier Carrasco's avatar
      iio: common: ms_sensors: ms_sensors_i2c: fix humidity conversion time table · 1b670b0e
      Javier Carrasco authored
      commit 54cf39ec upstream.
      
      The HTU21 offers 4 sampling frequencies: 20, 40, 70 and 120, which are
      associated to an index that is used to select the right measurement
      resolution and its corresponding measurement time. The current
      implementation selects the measurement resolution and the temperature
      measurement time properly, but it does not select the right humidity
      measurement time in all cases.
      
      In summary, the 40 and 70 humidity measurement times are swapped.
      
      The reason for that is probably the unusual coding for the measurement
      resolution. According to the datasheet, the bits [7,0] of the "user
      register" are used as follows to select the bit resolution:
      
      --------------------------------------------------
      | Bit 7 | Bit 0 | RH | Temp | Trh (us) | Tt (us) |
      --------------------------------------------------
      |   0   |   0   | 12 |  14  |  16000   |  50000  |
      --------------------------------------------------
      |   0   |   1   | 8  |  12  |  3000    |  13000  |
      --------------------------------------------------
      |   1   |   0   | 10 |  13  |  5000    |  25000  |
      --------------------------------------------------
      |   1   |   1   | 11 |  11  |  8000    |  7000   |
      --------------------------------------------------
      *This table is available in the official datasheet, page 13/21. I have
      just appended the times provided in the humidity/temperature tables,
      pages 3/21, 5/21. Note that always a pair of resolutions is selected.
      
      The sampling frequencies [20, 40, 70, 120] are assigned to a linear
      index [0..3] which is then coded as follows [1]:
      
      Index    [7,0]
      --------------
      idx 0     0,0
      idx 1     1,0
      idx 2     0,1
      idx 3     1,1
      
      That is done that way because the temperature measurements are being
      used as the reference for the sampling frequency (the frequencies and
      the temperature measurement times are correlated), so increasing the
      index always reduces the temperature measurement time and its
      resolution. Therefore, the temperature measurement time array is as
      simple as [50000, 25000, 13000, 7000]
      
      On the other hand, the humidity resolution cannot follow the same
      pattern because of the way it is coded in the "user register", where
      both resolutions are selected at the same time. The humidity measurement
      time array is the following: [16000, 3000, 5000, 8000], which defines
      the following assignments:
      
      Index    [7,0]    Trh
      -----------------------
      idx 0     0,0     16000  -> right, [0,0] selects 12 bits (Trh = 16000)
      idx 1     1,0     3000   -> wrong! [1,0] selects 10 bits (Trh = 5000)
      idx 2     0,1     5000   -> wrong! [0,1] selects 8 bits (Trh = 3000)
      idx 3     1,1     8000   -> right, [1,1] selects 11 bits (Trh = 8000)
      
      The times have been ordered as if idx = 1 -> [0,1] and idx = 2 -> [1,0],
      which is not the case for the reason explained above.
      
      So a simple modification is required to obtain the right humidity
      measurement time array, swapping the values in the positions 1 and 2.
      
      The right table should be the following: [16000, 5000, 3000, 8000]
      
      Fix the humidity measurement time array with the right idex/value
      coding.
      
      [1] The actual code that makes this coding and assigns it to the current
      value of the "user register" is the following:
      config_reg &= 0x7E;
      config_reg |= ((i & 1) << 7) + ((i & 2) >> 1);
      
      Fixes: d574a87c
      
       ("Add meas-spec sensors common part")
      Signed-off-by: default avatarJavier Carrasco <javier.carrasco.cruz@gmail.com>
      Link: https://lore.kernel.org/r/20231026-topic-htu21_conversion_time-v1-1-bd257dc44209@gmail.com
      
      
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1b670b0e
    • Wei Yongjun's avatar
      scsi: bnx2fc: Fix skb double free in bnx2fc_rcv() · 1fe4c93f
      Wei Yongjun authored
      [ Upstream commit 08c94d80 ]
      
      skb_share_check() already drops the reference to the skb when returning
      NULL. Using kfree_skb() in the error handling path leads to an skb double
      free.
      
      Fix this by removing the variable tmp_skb, and return directly when
      skb_share_check() returns NULL.
      
      Fixes: 01a4cc4d
      
       ("bnx2fc: do not add shared skbs to the fcoe_rx_list")
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Link: https://lore.kernel.org/r/20221114110626.526643-1-weiyongjun@huaweicloud.com
      
      
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1fe4c93f
    • Haoran Liu's avatar
      Input: ipaq-micro-keys - add error handling for devm_kmemdup · 66ccf5f7
      Haoran Liu authored
      [ Upstream commit 59b6a747
      
       ]
      
      Check the return value of i2c_add_adapter. Static analysis revealed that
      the function did not properly handle potential failures of
      i2c_add_adapter, which could lead to partial initialization of the I2C
      adapter and unstable operation.
      
      Signed-off-by: default avatarHaoran Liu <liuhaoran14@163.com>
      Link: https://lore.kernel.org/r/20231203164653.38983-1-liuhaoran14@163.com
      Fixes: d7535ffa
      
       ("Input: driver for microcontroller keys on the iPaq h3xxx")
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      66ccf5f7
    • Konrad Dybcio's avatar
      interconnect: qcom: sm8250: Enable sync_state · 3637f6bd
      Konrad Dybcio authored
      [ Upstream commit bfc7db1c ]
      
      Add the generic icc sync_state callback to ensure interconnect votes
      are taken into account, instead of being pegged at maximum values.
      
      Fixes: b95b668e
      
       ("interconnect: qcom: icc-rpmh: Add BCMs to commit list in pre_aggregate")
      Signed-off-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Link: https://lore.kernel.org/r/20231130-topic-8250icc_syncstate-v1-1-7ce78ba6e04c@linaro.org
      
      
      Signed-off-by: default avatarGeorgi Djakov <djakov@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3637f6bd
    • Su Hui's avatar
      iio: imu: inv_mpu6050: fix an error code problem in inv_mpu6050_read_raw · 90aa6272
      Su Hui authored
      [ Upstream commit c3df0e29 ]
      
      inv_mpu6050_sensor_show() can return -EINVAL or IIO_VAL_INT. Return the
      true value rather than only return IIO_VAL_INT.
      
      Fixes: d5098447
      
       ("iio: imu: mpu6050: add calibration offset support")
      Signed-off-by: default avatarSu Hui <suhui@nfschina.com>
      Link: https://lore.kernel.org/r/20231030020218.65728-1-suhui@nfschina.com
      
      
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      90aa6272
    • Mike Tipton's avatar
      interconnect: Treat xlate() returning NULL node as an error · 50d60bfc
      Mike Tipton authored
      [ Upstream commit ad2ab129 ]
      
      Currently, if provider->xlate() or provider->xlate_extended()
      "successfully" return a NULL node, then of_icc_get_from_provider() won't
      consider that an error and will successfully return the NULL node. This
      bypasses error handling in of_icc_get_by_index() and leads to NULL
      dereferences in path_find().
      
      This could be avoided by ensuring provider callbacks always return an
      error for NULL nodes, but it's better to explicitly protect against this
      in the common framework.
      
      Fixes: 87e3031b
      
       ("interconnect: Allow endpoints translation via DT")
      Signed-off-by: default avatarMike Tipton <quic_mdtipton@quicinc.com>
      Link: https://lore.kernel.org/r/20231025145829.11603-1-quic_mdtipton@quicinc.com
      
      
      Signed-off-by: default avatarGeorgi Djakov <djakov@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      50d60bfc
    • Ville Syrjälä's avatar
      drm/i915: Fix ADL+ tiled plane stride when the POT stride is smaller than the original · 900c1b3c
      Ville Syrjälä authored
      [ Upstream commit 324b70e9
      
       ]
      
      plane_view_scanout_stride() currently assumes that we had to pad the
      mapping stride with dummy pages in order to align it. But that is not
      the case if the original fb stride exceeds the aligned stride used
      to populate the remapped view, which is calculated from the user
      specified framebuffer width rather than the user specified framebuffer
      stride.
      
      Ignore the original fb stride in this case and just stick to the POT
      aligned stride. Getting this wrong will cause the plane to fetch the
      wrong data, and can lead to fault errors if the page tables at the
      bogus location aren't even populated.
      
      TODO: figure out if this is OK for CCS, or if we should instead increase
      the width of the view to cover the entire user specified fb stride
      instead...
      
      Cc: Imre Deak <imre.deak@intel.com>
      Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20231204202443.31247-1-ville.syrjala@linux.intel.com
      
      
      Reviewed-by: default avatarImre Deak <imre.deak@intel.com>
      Reviewed-by: default avatarJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
      (cherry picked from commit 01a39f1c
      
      )
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      900c1b3c
    • Clint Taylor's avatar
      drm/i915/mtl: Add MTL for remapping CCS FBs · de4349bd
      Clint Taylor authored
      [ Upstream commit 0da6bfe8
      
       ]
      
      Add support for remapping CCS FBs on MTL to remove the restriction
      of the power-of-two sized stride and the 2MB surface offset alignment
      for these FBs.
      
      Signed-off-by: default avatarClint Taylor <clinton.a.taylor@intel.com>
      Signed-off-by: default avatarJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
      Reviewed-by: default avatarRadhakrishna Sripada <radhakrishna.sripada@intel.com>
      Signed-off-by: default avatarNirmoy Das <nirmoy.das@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230505144005.23480-2-nirmoy.das@intel.com
      Stable-dep-of: 324b70e9
      
       ("drm/i915: Fix ADL+ tiled plane stride when the POT stride is smaller than the original")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      de4349bd
    • Ville Syrjälä's avatar
      drm/i915/dpt: Only do the POT stride remap when using DPT · 52c1a67d
      Ville Syrjälä authored
      [ Upstream commit ef5cb493
      
       ]
      
      If we want to test with DPT disabled on ADL the POT stride remap
      stuff needs to be disabled. Make it depend on actual DPT usage
      instead of just assuming it based on the modifier.
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230320090522.9909-3-ville.syrjala@linux.intel.com
      
      
      Reviewed-by: default avatarJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
      Stable-dep-of: 324b70e9
      
       ("drm/i915: Fix ADL+ tiled plane stride when the POT stride is smaller than the original")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      52c1a67d
    • Ville Syrjälä's avatar
      drm/i915: Fix intel_atomic_setup_scalers() plane_state handling · 7afe8109
      Ville Syrjälä authored
      [ Upstream commit c3070f08
      
       ]
      
      Since the plane_state variable is declared outside the scaler_users
      loop in intel_atomic_setup_scalers(), and it's never reset back to
      NULL inside the loop we may end up calling intel_atomic_setup_scaler()
      with a non-NULL plane state for the pipe scaling case. That is bad
      because intel_atomic_setup_scaler() determines whether we are doing
      plane scaling or pipe scaling based on plane_state!=NULL. The end
      result is that we may miscalculate the scaler mode for pipe scaling.
      
      The hardware becomes somewhat upset if we end up in this situation
      when scanning out a planar format on a SDR plane. We end up
      programming the pipe scaler into planar mode as well, and the
      result is a screenfull of garbage.
      
      Fix the situation by making sure we pass the correct plane_state==NULL
      when calculating the scaler mode for pipe scaling.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20231207193441.20206-2-ville.syrjala@linux.intel.com
      
      
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      (cherry picked from commit e8114410
      
      )
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7afe8109
    • Ville Syrjälä's avatar
      drm/i915: Relocate intel_atomic_setup_scalers() · b097184f
      Ville Syrjälä authored
      [ Upstream commit 8976b182
      
       ]
      
      Move intel_atomic_setup_scalers() next to the other scaler
      code in skl_scaler.c.
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230418175528.13117-4-ville.syrjala@linux.intel.com
      
      
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      Stable-dep-of: c3070f08
      
       ("drm/i915: Fix intel_atomic_setup_scalers() plane_state handling")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b097184f
    • Luca Coelho's avatar
      drm/i915/mtl: limit second scaler vertical scaling in ver >= 14 · 99767368
      Luca Coelho authored
      [ Upstream commit 8d4312e2
      
       ]
      
      In newer hardware versions (i.e. display version >= 14), the second
      scaler doesn't support vertical scaling.
      
      The current implementation of the scaling limits is simplified and
      only occurs when the planes are created, so we don't know which scaler
      is being used.
      
      In order to handle separate scaling limits for horizontal and vertical
      scaling, and different limits per scaler, split the checks in two
      phases.  We first do a simple check during plane creation and use the
      best-case scenario (because we don't know the scaler that may be used
      at a later point) and then do a more specific check when the scalers
      are actually being set up.
      
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Reviewed-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
      Signed-off-by: default avatarRadhakrishna Sripada <radhakrishna.sripada@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221223130509.43245-2-luciano.coelho@intel.com
      Stable-dep-of: c3070f08
      
       ("drm/i915: Fix intel_atomic_setup_scalers() plane_state handling")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      99767368
    • Maurizio Lombardi's avatar
      nvme-pci: fix sleeping function called from interrupt context · 387e8077
      Maurizio Lombardi authored
      [ Upstream commit f6fe0b2d ]
      
      the nvme_handle_cqe() interrupt handler calls nvme_complete_async_event()
      but the latter may call nvme_auth_stop() which is a blocking function.
      Sleeping functions can't be called in interrupt context
      
       BUG: sleeping function called from invalid context
       in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/15
        Call Trace:
           <IRQ>
            __cancel_work_timer+0x31e/0x460
            ? nvme_change_ctrl_state+0xcf/0x3c0 [nvme_core]
            ? nvme_change_ctrl_state+0xcf/0x3c0 [nvme_core]
            nvme_complete_async_event+0x365/0x480 [nvme_core]
            nvme_poll_cq+0x262/0xe50 [nvme]
      
      Fix the bug by moving nvme_auth_stop() to fw_act_work
      (executed by the nvme_wq workqueue)
      
      Fixes: f50fff73
      
       ("nvme: implement In-Band authentication")
      Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Reviewed-by: default avatarJens Axboe <axboe@kernel.dk>
      Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
      Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      387e8077
    • Kent Gibson's avatar
      gpiolib: cdev: add gpio_device locking wrapper around gpio_ioctl() · b506833e
      Kent Gibson authored
      [ Upstream commit 1d656bd2 ]
      
      While the GPIO cdev gpio_ioctl() call is in progress, the kernel can
      call gpiochip_remove() which will set gdev->chip to NULL, after which
      any subsequent access will cause a crash.
      
      gpio_ioctl() was overlooked by the previous fix to protect syscalls
      (bdbbae24), so add protection for that.
      
      Fixes: bdbbae24 ("gpiolib: protect the GPIO device against being dropped while in use by user-space")
      Fixes: d7c51b47 ("gpio: userspace ABI for reading/writing GPIO lines")
      Fixes: 3c0d9c63 ("gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL")
      Fixes: aad95584
      
       ("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and GPIO_V2_GET_LINEINFO_WATCH_IOCTL")
      Signed-off-by: default avatarKent Gibson <warthog618@gmail.com>
      Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b506833e
    • Alexis Lothoré's avatar
      pinctrl: at91-pio4: use dedicated lock class for IRQ · 6eb51df9
      Alexis Lothoré authored
      [ Upstream commit 14694179 ]
      
      Trying to suspend to RAM on SAMA5D27 EVK leads to the following lockdep
      warning:
      
       ============================================
       WARNING: possible recursive locking detected
       6.7.0-rc5-wt+ #532 Not tainted
       --------------------------------------------
       sh/92 is trying to acquire lock:
       c3cf306c (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0xe8/0x100
      
       but task is already holding lock:
       c3d7c46c (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0xe8/0x100
      
       other info that might help us debug this:
        Possible unsafe locking scenario:
      
              CPU0
              ----
         lock(&irq_desc_lock_class);
         lock(&irq_desc_lock_class);
      
        *** DEADLOCK ***
      
        May be due to missing lock nesting notation
      
       6 locks held by sh/92:
        #0: c3aa0258 (sb_writers#6){.+.+}-{0:0}, at: ksys_write+0xd8/0x178
        #1: c4c2df44 (&of->mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0x138/0x284
        #2: c32684a0 (kn->active){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x148/0x284
        #3: c232b6d4 (system_transition_mutex){+.+.}-{3:3}, at: pm_suspend+0x13c/0x4e8
        #4: c387b088 (&dev->mutex){....}-{3:3}, at: __device_suspend+0x1e8/0x91c
        #5: c3d7c46c (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0xe8/0x100
      
       stack backtrace:
       CPU: 0 PID: 92 Comm: sh Not tainted 6.7.0-rc5-wt+ #532
       Hardware name: Atmel SAMA5
        unwind_backtrace from show_stack+0x18/0x1c
        show_stack from dump_stack_lvl+0x34/0x48
        dump_stack_lvl from __lock_acquire+0x19ec/0x3a0c
        __lock_acquire from lock_acquire.part.0+0x124/0x2d0
        lock_acquire.part.0 from _raw_spin_lock_irqsave+0x5c/0x78
        _raw_spin_lock_irqsave from __irq_get_desc_lock+0xe8/0x100
        __irq_get_desc_lock from irq_set_irq_wake+0xa8/0x204
        irq_set_irq_wake from atmel_gpio_irq_set_wake+0x58/0xb4
        atmel_gpio_irq_set_wake from irq_set_irq_wake+0x100/0x204
        irq_set_irq_wake from gpio_keys_suspend+0xec/0x2b8
        gpio_keys_suspend from dpm_run_callback+0xe4/0x248
        dpm_run_callback from __device_suspend+0x234/0x91c
        __device_suspend from dpm_suspend+0x224/0x43c
        dpm_suspend from dpm_suspend_start+0x9c/0xa8
        dpm_suspend_start from suspend_devices_and_enter+0x1e0/0xa84
        suspend_devices_and_enter from pm_suspend+0x460/0x4e8
        pm_suspend from state_store+0x78/0xe4
        state_store from kernfs_fop_write_iter+0x1a0/0x284
        kernfs_fop_write_iter from vfs_write+0x38c/0x6f4
        vfs_write from ksys_write+0xd8/0x178
        ksys_write from ret_fast_syscall+0x0/0x1c
       Exception stack(0xc52b3fa8 to 0xc52b3ff0)
       3fa0:                   00000004 005a0ae8 00000001 005a0ae8 00000004 00000001
       3fc0: 00000004 005a0ae8 00000001 00000004 00000004 b6c616c0 00000020 0059d190
       3fe0: 00000004 b6c61678 aec5a041 aebf1a26
      
      This warning is raised because pinctrl-at91-pio4 uses chained IRQ. Whenever
      a wake up source configures an IRQ through irq_set_irq_wake, it will
      lock the corresponding IRQ desc, and then call irq_set_irq_wake on "parent"
      IRQ which will do the same on its own IRQ desc, but since those two locks
      share the same class, lockdep reports this as an issue.
      
      Fix lockdep false positive by setting a different class for parent and
      children IRQ
      
      Fixes: 77618084
      
       ("pinctrl: introduce driver for Atmel PIO4 controller")
      Signed-off-by: default avatarAlexis Lothoré <alexis.lothore@bootlin.com>
      Link: https://lore.kernel.org/r/20231215-lockdep_warning-v1-1-8137b2510ed5@bootlin.com
      
      
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6eb51df9
    • Arnd Bergmann's avatar
      x86/xen: add CPU dependencies for 32-bit build · 903bb0c7
      Arnd Bergmann authored
      [ Upstream commit 93cd0597 ]
      
      Xen only supports modern CPUs even when running a 32-bit kernel, and it now
      requires a kernel built for a 64 byte (or larger) cache line:
      
      In file included from <command-line>:
      In function 'xen_vcpu_setup',
          inlined from 'xen_vcpu_setup_restore' at arch/x86/xen/enlighten.c:111:3,
          inlined from 'xen_vcpu_restore' at arch/x86/xen/enlighten.c:141:3:
      include/linux/compiler_types.h:435:45: error: call to '__compiletime_assert_287' declared with attribute error: BUILD_BUG_ON failed: sizeof(*vcpup) > SMP_CACHE_BYTES
      arch/x86/xen/enlighten.c:166:9: note: in expansion of macro 'BUILD_BUG_ON'
        166 |         BUILD_BUG_ON(sizeof(*vcpup) > SMP_CACHE_BYTES);
            |         ^~~~~~~~~~~~
      
      Enforce the dependency with a whitelist of CPU configurations. In normal
      distro kernels, CONFIG_X86_GENERIC is enabled, and this works fine. When this
      is not set, still allow Xen to be built on kernels that target a 64-bit
      capable CPU.
      
      Fixes: db283230
      
       ("x86/xen: fix percpu vcpu_info allocation")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Tested-by: default avatarAlyssa Ross <hi@alyssa.is>
      Link: https://lore.kernel.org/r/20231204084722.3789473-1-arnd@kernel.org
      
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      903bb0c7
    • Quan Nguyen's avatar
      i2c: aspeed: Handle the coalesced stop conditions with the start conditions. · 2550d96a
      Quan Nguyen authored
      [ Upstream commit b4cc1cbb ]
      
      Some masters may drive the transfers with low enough latency between
      the nak/stop phase of the current command and the start/address phase
      of the following command that the interrupts are coalesced by the
      time we process them.
      Handle the stop conditions before processing SLAVE_MATCH to fix the
      complaints that sometimes occur below.
      
      "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected
      0x00000086, but was 0x00000084"
      
      Fixes: f9eb9135
      
       ("i2c: aspeed: added slave support for Aspeed I2C driver")
      Signed-off-by: default avatarQuan Nguyen <quan@os.amperecomputing.com>
      Reviewed-by: default avatarAndrew Jeffery <andrew@codeconstruct.com.au>
      Reviewed-by: default avatarAndi Shyti <andi.shyti@kernel.org>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2550d96a
    • Shengjiu Wang's avatar
      ASoC: fsl_sai: Fix channel swap issue on i.MX8MP · 5c11f637
      Shengjiu Wang authored
      [ Upstream commit 8f0f0164 ]
      
      When flag mclk_with_tere and mclk_direction_output enabled,
      The SAI transmitter or receiver will be enabled in very early
      stage, that if FSL_SAI_xMR is set by previous case,
      for example previous case is one channel, current case is
      two channels, then current case started with wrong xMR in
      the beginning, then channel swap happen.
      
      The patch is to clear xMR in hw_free() to avoid such
      channel swap issue.
      
      Fixes: 3e4a8261
      
       ("ASoC: fsl_sai: MCLK bind with TX/RX enable bit")
      Signed-off-by: default avatarShengjiu Wang <shengjiu.wang@nxp.com>
      Reviewed-by: default avatarDaniel Baluta <daniel.baluta@nxp.com>
      Link: https://msgid.link/r/1702953057-4499-1-git-send-email-shengjiu.wang@nxp.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5c11f637
    • Jerome Brunet's avatar
      ASoC: hdmi-codec: fix missing report for jack initial status · 264d8c9b
      Jerome Brunet authored
      [ Upstream commit 025222a9 ]
      
      This fixes a problem introduced while fixing ELD reporting with no jack
      set.
      
      Most driver using the hdmi-codec will call the 'plugged_cb' callback
      directly when registered to report the initial state of the HDMI connector.
      
      With the commit mentionned, this occurs before jack is ready and the
      initial report is lost for platforms actually providing a jack for HDMI.
      
      Fix this by storing the hdmi connector status regardless of jack being set
      or not and report the last status when jack gets set.
      
      With this, the initial state is reported correctly even if it is
      disconnected. This was not done initially and is also a fix.
      
      Fixes: 15be353d
      
       ("ASoC: hdmi-codec: register hpd callback on component probe")
      Reported-by: default avatarZhengqiao Xia <xiazhengqiao@huaqin.corp-partner.google.com>
      Closes: https://lore.kernel.org/alsa-devel/CADYyEwTNyY+fR9SgfDa-g6iiDwkU3MUdPVCYexs2_3wbcM8_vg@mail.gmail.com/
      
      
      Cc: Hsin-Yi Wang <hsinyi@google.com>
      Tested-by: default avatarZhengqiao Xia <xiazhengqiao@huaqin.corp-partner.google.com>
      Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
      Link: https://msgid.link/r/20231218145655.134929-1-jbrunet@baylibre.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      264d8c9b
    • David Howells's avatar
      afs: Fix use-after-free due to get/remove race in volume tree · 9b4c95a6
      David Howells authored
      [ Upstream commit 9a6b294a ]
      
      When an afs_volume struct is put, its refcount is reduced to 0 before
      the cell->volume_lock is taken and the volume removed from the
      cell->volumes tree.
      
      Unfortunately, this means that the lookup code can race and see a volume
      with a zero ref in the tree, resulting in a use-after-free:
      
          refcount_t: addition on 0; use-after-free.
          WARNING: CPU: 3 PID: 130782 at lib/refcount.c:25 refcount_warn_saturate+0x7a/0xda
          ...
          RIP: 0010:refcount_warn_saturate+0x7a/0xda
          ...
          Call Trace:
           afs_get_volume+0x3d/0x55
           afs_create_volume+0x126/0x1de
           afs_validate_fc+0xfe/0x130
           afs_get_tree+0x20/0x2e5
           vfs_get_tree+0x1d/0xc9
           do_new_mount+0x13b/0x22e
           do_mount+0x5d/0x8a
           __do_sys_mount+0x100/0x12a
           do_syscall_64+0x3a/0x94
           entry_SYSCALL_64_after_hwframe+0x62/0x6a
      
      Fix this by:
      
       (1) When putting, use a flag to indicate if the volume has been removed
           from the tree and skip the rb_erase if it has.
      
       (2) When looking up, use a conditional ref increment and if it fails
           because the refcount is 0, replace the node in the tree and set the
           removal flag.
      
      Fixes: 20325960
      
       ("afs: Reorganise volume and server trees to be rooted on the cell")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarJeffrey Altman <jaltman@auristor.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9b4c95a6
    • David Howells's avatar
      afs: Fix overwriting of result of DNS query · 17605162
      David Howells authored
      [ Upstream commit a9e01ac8 ]
      
      In afs_update_cell(), ret is the result of the DNS lookup and the errors
      are to be handled by a switch - however, the value gets clobbered in
      between by setting it to -ENOMEM in case afs_alloc_vlserver_list()
      fails.
      
      Fix this by moving the setting of -ENOMEM into the error handling for
      OOM failure.  Further, only do it if we don't have an alternative error
      to return.
      
      Found by Linux Verification Center (linuxtesting.org) with SVACE.  Based
      on a patch from Anastasia Belova [1].
      
      Fixes: d5c32c89
      
       ("afs: Fix cell DNS lookup")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarJeffrey Altman <jaltman@auristor.com>
      cc: Anastasia Belova <abelova@astralinux.ru>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      cc: lvc-project@linuxtesting.org
      Link: https://lore.kernel.org/r/20231221085849.1463-1-abelova@astralinux.ru/ [1]
      Link: https://lore.kernel.org/r/1700862.1703168632@warthog.procyon.org.uk/
      
       # v1
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      17605162
    • David Howells's avatar
      keys, dns: Allow key types (eg. DNS) to be reclaimed immediately on expiry · 791d5409
      David Howells authored
      [ Upstream commit 39299bdd ]
      
      If a key has an expiration time, then when that time passes, the key is
      left around for a certain amount of time before being collected (5 mins by
      default) so that EKEYEXPIRED can be returned instead of ENOKEY.  This is a
      problem for DNS keys because we want to redo the DNS lookup immediately at
      that point.
      
      Fix this by allowing key types to be marked such that keys of that type
      don't have this extra period, but are reclaimed as soon as they expire and
      turn this on for dns_resolver-type keys.  To make this easier to handle,
      key->expiry is changed to be permanent if TIME64_MAX rather than 0.
      
      Furthermore, give such new-style negative DNS results a 1s default expiry
      if no other expiry time is set rather than allowing it to stick around
      indefinitely.  This shouldn't be zero as ls will follow a failing stat call
      immediately with a second with AT_SYMLINK_NOFOLLOW added.
      
      Fixes: 1a4240f4
      
       ("DNS: Separate out CIFS DNS Resolver code")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Tested-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
      cc: Wang Lei <wang840925@gmail.com>
      cc: Jeff Layton <jlayton@redhat.com>
      cc: Steve French <smfrench@gmail.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: Jarkko Sakkinen <jarkko@kernel.org>
      cc: "David S. Miller" <davem@davemloft.net>
      cc: Eric Dumazet <edumazet@google.com>
      cc: Jakub Kicinski <kuba@kernel.org>
      cc: Paolo Abeni <pabeni@redhat.com>
      cc: linux-afs@lists.infradead.org
      cc: linux-cifs@vger.kernel.org
      cc: linux-nfs@vger.kernel.org
      cc: ceph-devel@vger.kernel.org
      cc: keyrings@vger.kernel.org
      cc: netdev@vger.kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      791d5409
    • Eric Dumazet's avatar
      net: check dev->gso_max_size in gso_features_check() · 3e617c7e
      Eric Dumazet authored
      [ Upstream commit 24ab059d ]
      
      Some drivers might misbehave if TSO packets get too big.
      
      GVE for instance uses a 16bit field in its TX descriptor,
      and will do bad things if a packet is bigger than 2^16 bytes.
      
      Linux TCP stack honors dev->gso_max_size, but there are
      other ways for too big packets to reach an ndo_start_xmit()
      handler : virtio_net, af_packet, GRO...
      
      Add a generic check in gso_features_check() and fallback
      to GSO when needed.
      
      gso_max_size was added in the blamed commit.
      
      Fixes: 82cc1a7a
      
       ("[NET]: Add per-connection option to set max TSO frame size")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/20231219125331.4127498-1-edumazet@google.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3e617c7e
    • David Howells's avatar
      afs: Fix dynamic root lookup DNS check · 087b96ad
      David Howells authored
      [ Upstream commit 74cef687 ]
      
      In the afs dynamic root directory, the ->lookup() function does a DNS check
      on the cell being asked for and if the DNS upcall reports an error it will
      report an error back to userspace (typically ENOENT).
      
      However, if a failed DNS upcall returns a new-style result, it will return
      a valid result, with the status field set appropriately to indicate the
      type of failure - and in that case, dns_query() doesn't return an error and
      we let stat() complete with no error - which can cause confusion in
      userspace as subsequent calls that trigger d_automount then fail with
      ENOENT.
      
      Fix this by checking the status result from a valid dns_query() and
      returning an error if it indicates a failure.
      
      Fixes: bbb4c432
      
       ("dns: Allow the dns resolver to retrieve a server set")
      Reported-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
      Closes: https://bugzilla.kernel.org/show_bug.cgi?id=216637
      
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Tested-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      087b96ad
    • David Howells's avatar
      afs: Fix the dynamic root's d_delete to always delete unused dentries · 9c6ea7ab
      David Howells authored
      [ Upstream commit 71f8b55b ]
      
      Fix the afs dynamic root's d_delete function to always delete unused
      dentries rather than only deleting them if they're positive.  With things
      as they stand upstream, negative dentries stemming from failed DNS lookups
      stick around preventing retries.
      
      Fixes: 66c7e1d3
      
       ("afs: Split the dynroot stuff out and give it its own ops tables")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Tested-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9c6ea7ab
    • Liu Jian's avatar
      net: check vlan filter feature in vlan_vids_add_by_dev() and vlan_vids_del_by_dev() · a70c2dd7
      Liu Jian authored
      [ Upstream commit 01a564ba ]
      
      I got the below warning trace:
      
      WARNING: CPU: 4 PID: 4056 at net/core/dev.c:11066 unregister_netdevice_many_notify
      CPU: 4 PID: 4056 Comm: ip Not tainted 6.7.0-rc4+ #15
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014
      RIP: 0010:unregister_netdevice_many_notify+0x9a4/0x9b0
      Call Trace:
       rtnl_dellink
       rtnetlink_rcv_msg
       netlink_rcv_skb
       netlink_unicast
       netlink_sendmsg
       __sock_sendmsg
       ____sys_sendmsg
       ___sys_sendmsg
       __sys_sendmsg
       do_syscall_64
       entry_SYSCALL_64_after_hwframe
      
      It can be repoduced via:
      
          ip netns add ns1
          ip netns exec ns1 ip link add bond0 type bond mode 0
          ip netns exec ns1 ip link add bond_slave_1 type veth peer veth2
          ip netns exec ns1 ip link set bond_slave_1 master bond0
      [1] ip netns exec ns1 ethtool -K bond0 rx-vlan-filter off
      [2] ip netns exec ns1 ip link add link bond_slave_1 name bond_slave_1.0 type vlan id 0
      [3] ip netns exec ns1 ip link add link bond0 name bond0.0 type vlan id 0
      [4] ip netns exec ns1 ip link set bond_slave_1 nomaster
      [5] ip netns exec ns1 ip link del veth2
          ip netns del ns1
      
      This is all caused by command [1] turning off the rx-vlan-filter function
      of bond0. The reason is the same as commit 01f4fd27 ("bonding: Fix
      incorrect deletion of ETH_P_8021AD protocol vid from slaves"). Commands
      [2] [3] add the same vid to slave and master respectively, causing
      command [4] to empty slave->vlan_info. The following command [5] triggers
      this problem.
      
      To fix this problem, we should add VLAN_FILTER feature checks in
      vlan_vids_add_by_dev() and vlan_vids_del_by_dev() to prevent incorrect
      addition or deletion of vlan_vid information.
      
      Fixes: 348a1443
      
       ("vlan: introduce functions to do mass addition/deletion of vids by another device")
      Signed-off-by: default avatarLiu Jian <liujian56@huawei.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a70c2dd7
    • Yury Norov's avatar
      net: mana: select PAGE_POOL · ea03196e
      Yury Norov authored
      [ Upstream commit 340943fb
      
       ]
      
      Mana uses PAGE_POOL API. x86_64 defconfig doesn't select it:
      
      ld: vmlinux.o: in function `mana_create_page_pool.isra.0':
      mana_en.c:(.text+0x9ae36f): undefined reference to `page_pool_create'
      ld: vmlinux.o: in function `mana_get_rxfrag':
      mana_en.c:(.text+0x9afed1): undefined reference to `page_pool_alloc_pages'
      make[3]: *** [/home/yury/work/linux/scripts/Makefile.vmlinux:37: vmlinux] Error 1
      make[2]: *** [/home/yury/work/linux/Makefile:1154: vmlinux] Error 2
      make[1]: *** [/home/yury/work/linux/Makefile:234: __sub-make] Error 2
      make[1]: Leaving directory '/home/yury/work/build-linux-x86_64'
      make: *** [Makefile:234: __sub-make] Error 2
      
      So we need to select it explicitly.
      
      Signed-off-by: default avatarYury Norov <yury.norov@gmail.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Tested-by: Simon Horman <horms@kernel.org> # build-tested
      Fixes: ca9c54d2 ("net: mana: Add a driver for Microsoft Azure Network Adapter")
      Link: https://lore.kernel.org/r/20231215203353.635379-1-yury.norov@gmail.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ea03196e
    • Arnd Bergmann's avatar
      Bluetooth: hci_event: shut up a false-positive warning · a1986c42
      Arnd Bergmann authored
      [ Upstream commit a5812c68 ]
      
      Turning on -Wstringop-overflow globally exposed a misleading compiler
      warning in bluetooth:
      
      net/bluetooth/hci_event.c: In function 'hci_cc_read_class_of_dev':
      net/bluetooth/hci_event.c:524:9: error: 'memcpy' writing 3 bytes into a
      region of size 0 overflows the destination [-Werror=stringop-overflow=]
        524 |         memcpy(hdev->dev_class, rp->dev_class, 3);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      The problem here is the check for hdev being NULL in bt_dev_dbg() that
      leads the compiler to conclude that hdev->dev_class might be an invalid
      pointer access.
      
      Add another explicit check for the same condition to make sure gcc sees
      this cannot happen.
      
      Fixes: a9de9248
      
       ("[Bluetooth] Switch from OGF+OCF to using only opcodes")
      Fixes: 1b56c90018f0 ("Makefile: Enable -Wstringop-overflow globally")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a1986c42
    • Ying Hsu's avatar
      Bluetooth: Fix deadlock in vhci_send_frame · fc647151
      Ying Hsu authored
      [ Upstream commit 769bf60e ]
      
      syzbot found a potential circular dependency leading to a deadlock:
          -> #3 (&hdev->req_lock){+.+.}-{3:3}:
          __mutex_lock_common+0x1b6/0x1bc2 kernel/locking/mutex.c:599
          __mutex_lock kernel/locking/mutex.c:732 [inline]
          mutex_lock_nested+0x17/0x1c kernel/locking/mutex.c:784
          hci_dev_do_close+0x3f/0x9f net/bluetooth/hci_core.c:551
          hci_rfkill_set_block+0x130/0x1ac net/bluetooth/hci_core.c:935
          rfkill_set_block+0x1e6/0x3b8 net/rfkill/core.c:345
          rfkill_fop_write+0x2d8/0x672 net/rfkill/core.c:1274
          vfs_write+0x277/0xcf5 fs/read_write.c:594
          ksys_write+0x19b/0x2bd fs/read_write.c:650
          do_syscall_x64 arch/x86/entry/common.c:55 [inline]
          do_syscall_64+0x51/0xba arch/x86/entry/common.c:93
          entry_SYSCALL_64_after_hwframe+0x61/0xcb
      
          -> #2 (rfkill_global_mutex){+.+.}-{3:3}:
          __mutex_lock_common+0x1b6/0x1bc2 kernel/locking/mutex.c:599
          __mutex_lock kernel/locking/mutex.c:732 [inline]
          mutex_lock_nested+0x17/0x1c kernel/locking/mutex.c:784
          rfkill_register+0x30/0x7e3 net/rfkill/core.c:1045
          hci_register_dev+0x48f/0x96d net/bluetooth/hci_core.c:2622
          __vhci_create_device drivers/bluetooth/hci_vhci.c:341 [inline]
          vhci_create_device+0x3ad/0x68f drivers/bluetooth/hci_vhci.c:374
          vhci_get_user drivers/bluetooth/hci_vhci.c:431 [inline]
          vhci_write+0x37b/0x429 drivers/bluetooth/hci_vhci.c:511
          call_write_iter include/linux/fs.h:2109 [inline]
          new_sync_write fs/read_write.c:509 [inline]
          vfs_write+0xaa8/0xcf5 fs/read_write.c:596
          ksys_write+0x19b/0x2bd fs/read_write.c:650
          do_syscall_x64 arch/x86/entry/common.c:55 [inline]
          do_syscall_64+0x51/0xba arch/x86/entry/common.c:93
          entry_SYSCALL_64_after_hwframe+0x61/0xcb
      
          -> #1 (&data->open_mutex){+.+.}-{3:3}:
          __mutex_lock_common+0x1b6/0x1bc2 kernel/locking/mutex.c:599
          __mutex_lock kernel/locking/mutex.c:732 [inline]
          mutex_lock_nested+0x17/0x1c kernel/locking/mutex.c:784
          vhci_send_frame+0x68/0x9c drivers/bluetooth/hci_vhci.c:75
          hci_send_frame+0x1cc/0x2ff net/bluetooth/hci_core.c:2989
          hci_sched_acl_pkt net/bluetooth/hci_core.c:3498 [inline]
          hci_sched_acl net/bluetooth/hci_core.c:3583 [inline]
          hci_tx_work+0xb94/0x1a60 net/bluetooth/hci_core.c:3654
          process_one_work+0x901/0xfb8 kernel/workqueue.c:2310
          worker_thread+0xa67/0x1003 kernel/workqueue.c:2457
          kthread+0x36a/0x430 kernel/kthread.c:319
          ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
      
          -> #0 ((work_completion)(&hdev->tx_work)){+.+.}-{0:0}:
          check_prev_add kernel/locking/lockdep.c:3053 [inline]
          check_prevs_add kernel/locking/lockdep.c:3172 [inline]
          validate_chain kernel/locking/lockdep.c:3787 [inline]
          __lock_acquire+0x2d32/0x77fa kernel/locking/lockdep.c:5011
          lock_acquire+0x273/0x4d5 kernel/locking/lockdep.c:5622
          __flush_work+0xee/0x19f kernel/workqueue.c:3090
          hci_dev_close_sync+0x32f/0x1113 net/bluetooth/hci_sync.c:4352
          hci_dev_do_close+0x47/0x9f net/bluetooth/hci_core.c:553
          hci_rfkill_set_block+0x130/0x1ac net/bluetooth/hci_core.c:935
          rfkill_set_block+0x1e6/0x3b8 net/rfkill/core.c:345
          rfkill_fop_write+0x2d8/0x672 net/rfkill/core.c:1274
          vfs_write+0x277/0xcf5 fs/read_write.c:594
          ksys_write+0x19b/0x2bd fs/read_write.c:650
          do_syscall_x64 arch/x86/entry/common.c:55 [inline]
          do_syscall_64+0x51/0xba arch/x86/entry/common.c:93
          entry_SYSCALL_64_after_hwframe+0x61/0xcb
      
      This change removes the need for acquiring the open_mutex in
      vhci_send_frame, thus eliminating the potential deadlock while
      maintaining the required packet ordering.
      
      Fixes: 92d4abd6
      
       ("Bluetooth: vhci: Fix race when opening vhci device")
      Signed-off-by: default avatarYing Hsu <yinghsu@chromium.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fc647151
    • Eric Dumazet's avatar
      net/rose: fix races in rose_kill_by_device() · 3e0d1585
      Eric Dumazet authored
      [ Upstream commit 64b8bc7d ]
      
      syzbot found an interesting netdev refcounting issue in
      net/rose/af_rose.c, thanks to CONFIG_NET_DEV_REFCNT_TRACKER=y [1]
      
      Problem is that rose_kill_by_device() can change rose->device
      while other threads do not expect the pointer to be changed.
      
      We have to first collect sockets in a temporary array,
      then perform the changes while holding the socket
      lock and rose_list_lock spinlock (in this order)
      
      Change rose_release() to also acquire rose_list_lock
      before releasing the netdev refcount.
      
      [1]
      
      [ 1185.055088][ T7889] ref_tracker: reference already released.
      [ 1185.061476][ T7889] ref_tracker: allocated in:
      [ 1185.066081][ T7889]  rose_bind+0x4ab/0xd10
      [ 1185.070446][ T7889]  __sys_bind+0x1ec/0x220
      [ 1185.074818][ T7889]  __x64_sys_bind+0x72/0xb0
      [ 1185.079356][ T7889]  do_syscall_64+0x40/0x110
      [ 1185.083897][ T7889]  entry_SYSCALL_64_after_hwframe+0x63/0x6b
      [ 1185.089835][ T7889] ref_tracker: freed in:
      [ 1185.094088][ T7889]  rose_release+0x2f5/0x570
      [ 1185.098629][ T7889]  __sock_release+0xae/0x260
      [ 1185.103262][ T7889]  sock_close+0x1c/0x20
      [ 1185.107453][ T7889]  __fput+0x270/0xbb0
      [ 1185.111467][ T7889]  task_work_run+0x14d/0x240
      [ 1185.116085][ T7889]  get_signal+0x106f/0x2790
      [ 1185.120622][ T7889]  arch_do_signal_or_restart+0x90/0x7f0
      [ 1185.126205][ T7889]  exit_to_user_mode_prepare+0x121/0x240
      [ 1185.131846][ T7889]  syscall_exit_to_user_mode+0x1e/0x60
      [ 1185.137293][ T7889]  do_syscall_64+0x4d/0x110
      [ 1185.141783][ T7889]  entry_SYSCALL_64_after_hwframe+0x63/0x6b
      [ 1185.148085][ T7889] ------------[ cut here ]------------
      
      WARNING: CPU: 1 PID: 7889 at lib/ref_tracker.c:255 ref_tracker_free+0x61a/0x810 lib/ref_tracker.c:255
      Modules linked in:
      CPU: 1 PID: 7889 Comm: syz-executor.2 Not tainted 6.7.0-rc4-syzkaller-00162-g65c95f78917e #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
      RIP: 0010:ref_tracker_free+0x61a/0x810 lib/ref_tracker.c:255
      Code: 00 44 8b 6b 18 31 ff 44 89 ee e8 21 62 f5 fc 45 85 ed 0f 85 a6 00 00 00 e8 a3 66 f5 fc 48 8b 34 24 48 89 ef e8 27 5f f1 05 90 <0f> 0b 90 bb ea ff ff ff e9 52 fd ff ff e8 84 66 f5 fc 4c 8d 6d 44
      RSP: 0018:ffffc90004917850 EFLAGS: 00010202
      RAX: 0000000000000201 RBX: ffff88802618f4c0 RCX: 0000000000000000
      RDX: 0000000000000202 RSI: ffffffff8accb920 RDI: 0000000000000001
      RBP: ffff8880269ea5b8 R08: 0000000000000001 R09: fffffbfff23e35f6
      R10: ffffffff91f1afb7 R11: 0000000000000001 R12: 1ffff92000922f0c
      R13: 0000000005a2039b R14: ffff88802618f4d8 R15: 00000000ffffffff
      FS: 00007f0a720ef6c0(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
      CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f43a819d988 CR3: 0000000076c64000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
      <TASK>
      netdev_tracker_free include/linux/netdevice.h:4127 [inline]
      netdev_put include/linux/netdevice.h:4144 [inline]
      netdev_put include/linux/netdevice.h:4140 [inline]
      rose_kill_by_device net/rose/af_rose.c:195 [inline]
      rose_device_event+0x25d/0x330 net/rose/af_rose.c:218
      notifier_call_chain+0xb6/0x3b0 kernel/notifier.c:93
      call_netdevice_notifiers_info+0xbe/0x130 net/core/dev.c:1967
      call_netdevice_notifiers_extack net/core/dev.c:2005 [inline]
      call_netdevice_notifiers net/core/dev.c:2019 [inline]
      __dev_notify_flags+0x1f5/0x2e0 net/core/dev.c:8646
      dev_change_flags+0x122/0x170 net/core/dev.c:8682
      dev_ifsioc+0x9ad/0x1090 net/core/dev_ioctl.c:529
      dev_ioctl+0x224/0x1090 net/core/dev_ioctl.c:786
      sock_do_ioctl+0x198/0x270 net/socket.c:1234
      sock_ioctl+0x22e/0x6b0 net/socket.c:1339
      vfs_ioctl fs/ioctl.c:51 [inline]
      __do_sys_ioctl fs/ioctl.c:871 [inline]
      __se_sys_ioctl fs/ioctl.c:857 [inline]
      __x64_sys_ioctl+0x18f/0x210 fs/ioctl.c:857
      do_syscall_x64 arch/x86/entry/common.c:52 [inline]
      do_syscall_64+0x40/0x110 arch/x86/entry/common.c:83
      entry_SYSCALL_64_after_hwframe+0x63/0x6b
      RIP: 0033:0x7f0a7147cba9
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007f0a720ef0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 00007f0a7159bf80 RCX: 00007f0a7147cba9
      RDX: 0000000020000040 RSI: 0000000000008914 RDI: 0000000000000004
      RBP: 00007f0a714c847a R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 000000000000000b R14: 00007f0a7159bf80 R15: 00007ffc8bb3a5f8
      </TASK>
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Bernard Pidoux <f6bvp@free.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3e0d1585
    • Zhipeng Lu's avatar
      ethernet: atheros: fix a memleak in atl1e_setup_ring_resources · 51e28c37
      Zhipeng Lu authored
      [ Upstream commit 309fdb1c ]
      
      In the error handling of 'offset > adapter->ring_size', the
      tx_ring->tx_buffer allocated by kzalloc should be freed,
      instead of 'goto failed' instantly.
      
      Fixes: a6a53252
      
       ("atl1e: Atheros L1E Gigabit Ethernet driver")
      Signed-off-by: default avatarZhipeng Lu <alexious@zju.edu.cn>
      Reviewed-by: default avatarSuman Ghosh <sumang@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      51e28c37
    • Eric Dumazet's avatar
      net: sched: ife: fix potential use-after-free · 6707baab
      Eric Dumazet authored
      [ Upstream commit 19391a2c ]
      
      ife_decode() calls pskb_may_pull() two times, we need to reload
      ifehdr after the second one, or risk use-after-free as reported
      by syzbot:
      
      BUG: KASAN: slab-use-after-free in __ife_tlv_meta_valid net/ife/ife.c:108 [inline]
      BUG: KASAN: slab-use-after-free in ife_tlv_meta_decode+0x1d1/0x210 net/ife/ife.c:131
      Read of size 2 at addr ffff88802d7300a4 by task syz-executor.5/22323
      
      CPU: 0 PID: 22323 Comm: syz-executor.5 Not tainted 6.7.0-rc3-syzkaller-00804-g074ac38d5b95 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
      Call Trace:
      <TASK>
      __dump_stack lib/dump_stack.c:88 [inline]
      dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
      print_address_description mm/kasan/report.c:364 [inline]
      print_report+0xc4/0x620 mm/kasan/report.c:475
      kasan_report+0xda/0x110 mm/kasan/report.c:588
      __ife_tlv_meta_valid net/ife/ife.c:108 [inline]
      ife_tlv_meta_decode+0x1d1/0x210 net/ife/ife.c:131
      tcf_ife_decode net/sched/act_ife.c:739 [inline]
      tcf_ife_act+0x4e3/0x1cd0 net/sched/act_ife.c:879
      tc_act include/net/tc_wrapper.h:221 [inline]
      tcf_action_exec+0x1ac/0x620 net/sched/act_api.c:1079
      tcf_exts_exec include/net/pkt_cls.h:344 [inline]
      mall_classify+0x201/0x310 net/sched/cls_matchall.c:42
      tc_classify include/net/tc_wrapper.h:227 [inline]
      __tcf_classify net/sched/cls_api.c:1703 [inline]
      tcf_classify+0x82f/0x1260 net/sched/cls_api.c:1800
      hfsc_classify net/sched/sch_hfsc.c:1147 [inline]
      hfsc_enqueue+0x315/0x1060 net/sched/sch_hfsc.c:1546
      dev_qdisc_enqueue+0x3f/0x230 net/core/dev.c:3739
      __dev_xmit_skb net/core/dev.c:3828 [inline]
      __dev_queue_xmit+0x1de1/0x3d30 net/core/dev.c:4311
      dev_queue_xmit include/linux/netdevice.h:3165 [inline]
      packet_xmit+0x237/0x350 net/packet/af_packet.c:276
      packet_snd net/packet/af_packet.c:3081 [inline]
      packet_sendmsg+0x24aa/0x5200 net/packet/af_packet.c:3113
      sock_sendmsg_nosec net/socket.c:730 [inline]
      __sock_sendmsg+0xd5/0x180 net/socket.c:745
      __sys_sendto+0x255/0x340 net/socket.c:2190
      __do_sys_sendto net/socket.c:2202 [inline]
      __se_sys_sendto net/socket.c:2198 [inline]
      __x64_sys_sendto+0xe0/0x1b0 net/socket.c:2198
      do_syscall_x64 arch/x86/entry/common.c:51 [inline]
      do_syscall_64+0x40/0x110 arch/x86/entry/common.c:82
      entry_SYSCALL_64_after_hwframe+0x63/0x6b
      RIP: 0033:0x7fe9acc7cae9
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007fe9ada450c8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
      RAX: ffffffffffffffda RBX: 00007fe9acd9bf80 RCX: 00007fe9acc7cae9
      RDX: 000000000000fce0 RSI: 00000000200002c0 RDI: 0000000000000003
      RBP: 00007fe9accc847a R08: 0000000020000140 R09: 0000000000000014
      R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000
      R13: 000000000000000b R14: 00007fe9acd9bf80 R15: 00007ffd5427ae78
      </TASK>
      
      Allocated by task 22323:
      kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
      kasan_set_track+0x25/0x30 mm/kasan/common.c:52
      ____kasan_kmalloc mm/kasan/common.c:374 [inline]
      __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383
      kasan_kmalloc include/linux/kasan.h:198 [inline]
      __do_kmalloc_node mm/slab_common.c:1007 [inline]
      __kmalloc_node_track_caller+0x5a/0x90 mm/slab_common.c:1027
      kmalloc_reserve+0xef/0x260 net/core/skbuff.c:582
      __alloc_skb+0x12b/0x330 net/core/skbuff.c:651
      alloc_skb include/linux/skbuff.h:1298 [inline]
      alloc_skb_with_frags+0xe4/0x710 net/core/skbuff.c:6331
      sock_alloc_send_pskb+0x7e4/0x970 net/core/sock.c:2780
      packet_alloc_skb net/packet/af_packet.c:2930 [inline]
      packet_snd net/packet/af_packet.c:3024 [inline]
      packet_sendmsg+0x1e2a/0x5200 net/packet/af_packet.c:3113
      sock_sendmsg_nosec net/socket.c:730 [inline]
      __sock_sendmsg+0xd5/0x180 net/socket.c:745
      __sys_sendto+0x255/0x340 net/socket.c:2190
      __do_sys_sendto net/socket.c:2202 [inline]
      __se_sys_sendto net/socket.c:2198 [inline]
      __x64_sys_sendto+0xe0/0x1b0 net/socket.c:2198
      do_syscall_x64 arch/x86/entry/common.c:51 [inline]
      do_syscall_64+0x40/0x110 arch/x86/entry/common.c:82
      entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Freed by task 22323:
      kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
      kasan_set_track+0x25/0x30 mm/kasan/common.c:52
      kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522
      ____kasan_slab_free mm/kasan/common.c:236 [inline]
      ____kasan_slab_free+0x15b/0x1b0 mm/kasan/common.c:200
      kasan_slab_free include/linux/kasan.h:164 [inline]
      slab_free_hook mm/slub.c:1800 [inline]
      slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826
      slab_free mm/slub.c:3809 [inline]
      __kmem_cache_free+0xc0/0x180 mm/slub.c:3822
      skb_kfree_head net/core/skbuff.c:950 [inline]
      skb_free_head+0x110/0x1b0 net/core/skbuff.c:962
      pskb_expand_head+0x3c5/0x1170 net/core/skbuff.c:2130
      __pskb_pull_tail+0xe1/0x1830 net/core/skbuff.c:2655
      pskb_may_pull_reason include/linux/skbuff.h:2685 [inline]
      pskb_may_pull include/linux/skbuff.h:2693 [inline]
      ife_decode+0x394/0x4f0 net/ife/ife.c:82
      tcf_ife_decode net/sched/act_ife.c:727 [inline]
      tcf_ife_act+0x43b/0x1cd0 net/sched/act_ife.c:879
      tc_act include/net/tc_wrapper.h:221 [inline]
      tcf_action_exec+0x1ac/0x620 net/sched/act_api.c:1079
      tcf_exts_exec include/net/pkt_cls.h:344 [inline]
      mall_classify+0x201/0x310 net/sched/cls_matchall.c:42
      tc_classify include/net/tc_wrapper.h:227 [inline]
      __tcf_classify net/sched/cls_api.c:1703 [inline]
      tcf_classify+0x82f/0x1260 net/sched/cls_api.c:1800
      hfsc_classify net/sched/sch_hfsc.c:1147 [inline]
      hfsc_enqueue+0x315/0x1060 net/sched/sch_hfsc.c:1546
      dev_qdisc_enqueue+0x3f/0x230 net/core/dev.c:3739
      __dev_xmit_skb net/core/dev.c:3828 [inline]
      __dev_queue_xmit+0x1de1/0x3d30 net/core/dev.c:4311
      dev_queue_xmit include/linux/netdevice.h:3165 [inline]
      packet_xmit+0x237/0x350 net/packet/af_packet.c:276
      packet_snd net/packet/af_packet.c:3081 [inline]
      packet_sendmsg+0x24aa/0x5200 net/packet/af_packet.c:3113
      sock_sendmsg_nosec net/socket.c:730 [inline]
      __sock_sendmsg+0xd5/0x180 net/socket.c:745
      __sys_sendto+0x255/0x340 net/socket.c:2190
      __do_sys_sendto net/socket.c:2202 [inline]
      __se_sys_sendto net/socket.c:2198 [inline]
      __x64_sys_sendto+0xe0/0x1b0 net/socket.c:2198
      do_syscall_x64 arch/x86/entry/common.c:51 [inline]
      do_syscall_64+0x40/0x110 arch/x86/entry/common.c:82
      entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      The buggy address belongs to the object at ffff88802d730000
      which belongs to the cache kmalloc-8k of size 8192
      The buggy address is located 164 bytes inside of
      freed 8192-byte region [ffff88802d730000, ffff88802d732000)
      
      The buggy address belongs to the physical page:
      page:ffffea0000b5cc00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2d730
      head:ffffea0000b5cc00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
      flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
      page_type: 0xffffffff()
      raw: 00fff00000000840 ffff888013042280 dead000000000122 0000000000000000
      raw: 0000000000000000 0000000080020002 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      page_owner tracks the page as allocated
      page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 22323, tgid 22320 (syz-executor.5), ts 950317230369, free_ts 950233467461
      set_page_owner include/linux/page_owner.h:31 [inline]
      post_alloc_hook+0x2d0/0x350 mm/page_alloc.c:1544
      prep_new_page mm/page_alloc.c:1551 [inline]
      get_page_from_freelist+0xa28/0x3730 mm/page_alloc.c:3319
      __alloc_pages+0x22e/0x2420 mm/page_alloc.c:4575
      alloc_pages_mpol+0x258/0x5f0 mm/mempolicy.c:2133
      alloc_slab_page mm/slub.c:1870 [inline]
      allocate_slab mm/slub.c:2017 [inline]
      new_slab+0x283/0x3c0 mm/slub.c:2070
      ___slab_alloc+0x979/0x1500 mm/slub.c:3223
      __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322
      __slab_alloc_node mm/slub.c:3375 [inline]
      slab_alloc_node mm/slub.c:3468 [inline]
      __kmem_cache_alloc_node+0x131/0x310 mm/slub.c:3517
      __do_kmalloc_node mm/slab_common.c:1006 [inline]
      __kmalloc_node_track_caller+0x4a/0x90 mm/slab_common.c:1027
      kmalloc_reserve+0xef/0x260 net/core/skbuff.c:582
      __alloc_skb+0x12b/0x330 net/core/skbuff.c:651
      alloc_skb include/linux/skbuff.h:1298 [inline]
      alloc_skb_with_frags+0xe4/0x710 net/core/skbuff.c:6331
      sock_alloc_send_pskb+0x7e4/0x970 net/core/sock.c:2780
      packet_alloc_skb net/packet/af_packet.c:2930 [inline]
      packet_snd net/packet/af_packet.c:3024 [inline]
      packet_sendmsg+0x1e2a/0x5200 net/packet/af_packet.c:3113
      sock_sendmsg_nosec net/socket.c:730 [inline]
      __sock_sendmsg+0xd5/0x180 net/socket.c:745
      __sys_sendto+0x255/0x340 net/socket.c:2190
      page last free stack trace:
      reset_page_owner include/linux/page_owner.h:24 [inline]
      free_pages_prepare mm/page_alloc.c:1144 [inline]
      free_unref_page_prepare+0x53c/0xb80 mm/page_alloc.c:2354
      free_unref_page+0x33/0x3b0 mm/page_alloc.c:2494
      __unfreeze_partials+0x226/0x240 mm/slub.c:2655
      qlink_free mm/kasan/quarantine.c:168 [inline]
      qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187
      kasan_quarantine_reduce+0x18e/0x1d0 mm/kasan/quarantine.c:294
      __kasan_slab_alloc+0x65/0x90 mm/kasan/common.c:305
      kasan_slab_alloc include/linux/kasan.h:188 [inline]
      slab_post_alloc_hook mm/slab.h:763 [inline]
      slab_alloc_node mm/slub.c:3478 [inline]
      slab_alloc mm/slub.c:3486 [inline]
      __kmem_cache_alloc_lru mm/slub.c:3493 [inline]
      kmem_cache_alloc_lru+0x219/0x6f0 mm/slub.c:3509
      alloc_inode_sb include/linux/fs.h:2937 [inline]
      ext4_alloc_inode+0x28/0x650 fs/ext4/super.c:1408
      alloc_inode+0x5d/0x220 fs/inode.c:261
      new_inode_pseudo fs/inode.c:1006 [inline]
      new_inode+0x22/0x260 fs/inode.c:1032
      __ext4_new_inode+0x333/0x5200 fs/ext4/ialloc.c:958
      ext4_symlink+0x5d7/0xa20 fs/ext4/namei.c:3398
      vfs_symlink fs/namei.c:4464 [inline]
      vfs_symlink+0x3e5/0x620 fs/namei.c:4448
      do_symlinkat+0x25f/0x310 fs/namei.c:4490
      __do_sys_symlinkat fs/namei.c:4506 [inline]
      __se_sys_symlinkat fs/namei.c:4503 [inline]
      __x64_sys_symlinkat+0x97/0xc0 fs/namei.c:4503
      do_syscall_x64 arch/x86/entry/common.c:51 [inline]
      do_syscall_64+0x40/0x110 arch/x86/entry/common.c:82
      
      Fixes: d57493d6
      
       ("net: sched: ife: check on metadata length")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Alexander Aring <aahringo@redhat.com>
      Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6707baab
    • Shigeru Yoshida's avatar
      net: Return error from sk_stream_wait_connect() if sk_wait_event() fails · 31edab12
      Shigeru Yoshida authored
      [ Upstream commit cac23b7d ]
      
      The following NULL pointer dereference issue occurred:
      
      BUG: kernel NULL pointer dereference, address: 0000000000000000
      <...>
      RIP: 0010:ccid_hc_tx_send_packet net/dccp/ccid.h:166 [inline]
      RIP: 0010:dccp_write_xmit+0x49/0x140 net/dccp/output.c:356
      <...>
      Call Trace:
       <TASK>
       dccp_sendmsg+0x642/0x7e0 net/dccp/proto.c:801
       inet_sendmsg+0x63/0x90 net/ipv4/af_inet.c:846
       sock_sendmsg_nosec net/socket.c:730 [inline]
       __sock_sendmsg+0x83/0xe0 net/socket.c:745
       ____sys_sendmsg+0x443/0x510 net/socket.c:2558
       ___sys_sendmsg+0xe5/0x150 net/socket.c:2612
       __sys_sendmsg+0xa6/0x120 net/socket.c:2641
       __do_sys_sendmsg net/socket.c:2650 [inline]
       __se_sys_sendmsg net/socket.c:2648 [inline]
       __x64_sys_sendmsg+0x45/0x50 net/socket.c:2648
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x43/0x110 arch/x86/entry/common.c:82
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      sk_wait_event() returns an error (-EPIPE) if disconnect() is called on the
      socket waiting for the event. However, sk_stream_wait_connect() returns
      success, i.e. zero, even if sk_wait_event() returns -EPIPE, so a function
      that waits for a connection with sk_stream_wait_connect() may misbehave.
      
      In the case of the above DCCP issue, dccp_sendmsg() is waiting for the
      connection. If disconnect() is called in concurrently, the above issue
      occurs.
      
      This patch fixes the issue by returning error from sk_stream_wait_connect()
      if sk_wait_event() fails.
      
      Fixes: 419ce133
      
       ("tcp: allow again tcp_disconnect() when threads are waiting")
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reported-by: default avatar <syzbot+c71bc336c5061153b502@syzkaller.appspotmail.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Reported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      31edab12
    • Suman Ghosh's avatar
      octeontx2-pf: Fix graceful exit during PFC configuration failure · 9d00421e
      Suman Ghosh authored
      [ Upstream commit 8c97ab54 ]
      
      During PFC configuration failure the code was not handling a graceful
      exit. This patch fixes the same and add proper code for a graceful exit.
      
      Fixes: 99c969a8
      
       ("octeontx2-pf: Add egress PFC support")
      Signed-off-by: default avatarSuman Ghosh <sumang@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9d00421e
    • Vladimir Oltean's avatar
      net: mscc: ocelot: fix eMAC TX RMON stats for bucket 256-511 and above · b0cee294
      Vladimir Oltean authored
      [ Upstream commit 52eda464 ]
      
      There is a typo in the driver due to which we report incorrect TX RMON
      counters for the 256-511 octet bucket and all the other buckets larger
      than that.
      
      Bug found with the selftest at
      https://patchwork.kernel.org/project/netdevbpf/patch/20231211223346.2497157-9-tobias@waldekranz.com/
      
      Fixes: e32036e1
      
       ("net: mscc: ocelot: add support for all sorts of standardized counters present in DSA")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
      Link: https://lore.kernel.org/r/20231214000902.545625-1-vladimir.oltean@nxp.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b0cee294
    • Rahul Rameshbabu's avatar
      net/mlx5e: Correct snprintf truncation handling for fw_version buffer used by representors · 72b8de75
      Rahul Rameshbabu authored
      [ Upstream commit b13559b7 ]
      
      snprintf returns the length of the formatted string, excluding the trailing
      null, without accounting for truncation. This means that is the return
      value is greater than or equal to the size parameter, the fw_version string
      was truncated.
      
      Link: https://docs.kernel.org/core-api/kernel-api.html#c.snprintf
      Fixes: 1b2bd0c0
      
       ("net/mlx5e: Check return value of snprintf writing to fw_version buffer for representors")
      Signed-off-by: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      72b8de75
    • Rahul Rameshbabu's avatar
      net/mlx5e: Correct snprintf truncation handling for fw_version buffer · 18b4a5e0
      Rahul Rameshbabu authored
      [ Upstream commit ad436b9c
      
       ]
      
      snprintf returns the length of the formatted string, excluding the trailing
      null, without accounting for truncation. This means that is the return
      value is greater than or equal to the size parameter, the fw_version string
      was truncated.
      
      Reported-by: default avatarDavid Laight <David.Laight@ACULAB.COM>
      Closes: https://lore.kernel.org/netdev/81cae734ee1b4cde9b380a9a31006c1a@AcuMS.aculab.com/
      Link: https://docs.kernel.org/core-api/kernel-api.html#c.snprintf
      Fixes: 41e63c2b
      
       ("net/mlx5e: Check return value of snprintf writing to fw_version buffer")
      Signed-off-by: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18b4a5e0
    • Moshe Shemesh's avatar
      net/mlx5: Fix fw tracer first block check · 94c8485b
      Moshe Shemesh authored
      [ Upstream commit 4261edf1 ]
      
      While handling new traces, to verify it is not the first block being
      written, last_timestamp is checked. But instead of checking it is non
      zero it is verified to be zero. Fix to verify last_timestamp is not
      zero.
      
      Fixes: c71ad41c
      
       ("net/mlx5: FW tracer, events handling")
      Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Reviewed-by: default avatarFeras Daoud <ferasda@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      94c8485b