1. 25 Jan, 2020 2 commits
    • Tyrel Datwyler's avatar
      powerpc/pseries/vio: Fix iommu_table use-after-free refcount warning · aff8c824
      Tyrel Datwyler authored
      Commit e5afdf9d ("powerpc/vfio_spapr_tce: Add reference counting to
      iommu_table") missed an iommu_table allocation in the pseries vio code.
      The iommu_table is allocated with kzalloc and as a result the associated
      kref gets a value of zero. This has the side effect that during a DLPAR
      remove of the associated virtual IOA the iommu_tce_table_put() triggers
      a use-after-free underflow warning.
      
      Call Trace:
      [c0000002879e39f0] [c00000000071ecb4] refcount_warn_saturate+0x184/0x190
      (unreliable)
      [c0000002879e3a50] [c0000000000500ac] iommu_tce_table_put+0x9c/0xb0
      [c0000002879e3a70] [c0000000000f54e4] vio_dev_release+0x34/0x70
      [c0000002879e3aa0] [c00000000087cfa4] device_release+0x54/0xf0
      [c0000002879e3b10] [c000000000d64c84] kobject_cleanup+0xa4/0x240
      [c0000002879e3b90] [c00000000087d358] put_device+0x28/0x40
      [c0000002879e3bb0] [c0000000007a328c] dlpar_remove_slot+0x15c/0x250
      [c0000002879e3c50] [c0000000007a348c] remove_slot_store+0xac/0xf0
      [c0000002879e3cd0] [c000000000d64220] kobj_attr_store+0x30/0x60
      [c0000002879e3cf0] [c0000000004ff13c] sysfs_kf_write+0x6c/0xa0
      [c0000002879e3d10] [c0000000004fde4c] kernfs_fop_write+0x18c/0x260
      [c0000002879e3d60] [c000000000410f3c] __vfs_write+0x3c/0x70
      [c0000002879e3d80] [c000000000415408] vfs_write+0xc8/0x250
      [c0000002879e3dd0] [c0000000004157dc] ksys_write+0x7c/0x120
      [c0000002879e3e20] [c00000000000b278] system_call+0x5c/0x68
      
      Further, since the refcount was always zero the iommu_tce_table_put()
      fails to call the iommu_table release function resulting in a leak.
      
      Fix this issue be initilizing the iommu_table kref immediately after
      allocation.
      
      Fixes: e5afdf9d ("powerpc/vfio_spapr_tce: Add reference counting to iommu_table")
      Signed-off-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
      Reviewed-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1579558202-26052-1-git-send-email-tyreld@linux.ibm.com
      aff8c824
    • Aneesh Kumar K.V's avatar
      powerpc/papr_scm: Don't enable direct map for a region by default · 7e6f8cbc
      Aneesh Kumar K.V authored
      Setting ND_REGION_PAGEMAP flag implies namespace mode defaults to fsdax mode.
      This also means kernel ends up creating struct page backing for these namspace
      ranges. With large namespaces that is not the right thing to do. We
      should let the user select the mode he/she wants the namespace to be created
      with.
      
      Hence disable ND_REGION_PAGEMAP for papr_scm regions. We still keep the flag for
      of_pmem because it supports only small persistent memory regions.
      
      This is similar to what is done for x86 with commit
      commit: 004f1afb ("libnvdimm, pmem: direct map legacy pmem by default")
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200108064647.169637-1-aneesh.kumar@linux.ibm.com
      7e6f8cbc
  2. 23 Jan, 2020 38 commits