Skip to content
Snippets Groups Projects
  1. Jun 08, 2023
  2. Mar 24, 2023
    • Eli Cohen's avatar
      lib: cpu_rmap: Add irq_cpu_rmap_remove to complement irq_cpu_rmap_add · 71f0a247
      Eli Cohen authored
      
      Add a function to complement irq_cpu_rmap_add(). It removes the irq from
      the reverse mapping by setting the notifier to NULL. The function calls
      irq_set_affinity_notifier() with NULL at the notify argument which then
      cancel any pending notifier work and decrement reference on the
      notifier. When ref count reaches zero, the glue pointer is kfree and the
      rmap entry is set to NULL serving both to avoid second attempt to
      release it and also making the rmap entry available for subsequent
      mapping.
      
      It should be noted the drivers usually creates the reverse mapping at
      initialization time and remove it at unload time so we do not expect
      failures in allocating rmap due to kref holding the glue entry.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      71f0a247
    • Eli Cohen's avatar
      lib: cpu_rmap: Use allocator for rmap entries · 9821d8d4
      Eli Cohen authored
      
      Use a proper allocator for rmap entries using a naive for loop. The
      allocator relies on whether an entry is NULL to be considered free.
      Remove the used field of rmap which is not needed.
      
      Also, avoid crashing the kernel if an entry is not available.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      9821d8d4
    • Eli Cohen's avatar
      lib: cpu_rmap: Avoid use after free on rmap->obj array entries · 4e0473f1
      Eli Cohen authored
      
      When calling irq_set_affinity_notifier() with NULL at the notify
      argument, it will cause freeing of the glue pointer in the
      corresponding array entry but will leave the pointer in the array. A
      subsequent call to free_irq_cpu_rmap() will try to free this entry again
      leading to possible use after free.
      
      Fix that by setting NULL to the array entry and checking that we have
      non-zero at the array entry when iterating over the array in
      free_irq_cpu_rmap().
      
      The current code does not suffer from this since there are no cases
      where irq_set_affinity_notifier(irq, NULL) (note the NULL passed for the
      notify arg) is called, followed by a call to free_irq_cpu_rmap() so we
      don't hit and issue. Subsequent patches in this series excersize this
      flow, hence the required fix.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      4e0473f1
  3. Oct 18, 2019
  4. Jun 19, 2019
  5. May 27, 2015
  6. Sep 13, 2013
  7. Jan 11, 2013
  8. Mar 07, 2012
  9. Jan 24, 2011
Loading