All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] scsi: target: tcmu: Fix memory leak
@ 2021-02-18 17:50 Bodo Stroesser
  2021-02-18 17:50 ` [PATCH 1/2] scsi: target: tcmu: Move some functions without code change Bodo Stroesser
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Bodo Stroesser @ 2021-02-18 17:50 UTC (permalink / raw)
  To: linux-scsi, target-devel, Martin K. Petersen
  Cc: Bodo Stroesser, Mike Christie

This small series applies to Martin's for-next.

This is the third attempt to fix a severe memory leak in tcmu.
Previous patches:
  https://lore.kernel.org/linux-scsi/20201218141534.9918-1-bostroesser@gmail.com/
  and
  https://lore.kernel.org/linux-scsi/20210210194031.7422-1-bostroesser@gmail.com/

Tcmu's refcounting relies on tcmu_open and tcmu_release being
called symmetrically by uio. But that is not true if userspace
daemon holds the uio device open or mmap'ed while tcmu calls
uio_unregister device. So refcount can stay above 0 for ever,
which means that tcmu does not free resources of a tcmu device.
In extreme cases the amount of memory leaked can be > 1 GB for
a single destroyed tcmu device.

This new patch series fixes the problem by moving refcounting from
tcmu_open/tcmu_release to new vm_operations_struct::open/*::close
handlers, which are called under all conditions.

Bodo Stroesser (2):
  scsi: target: tcmu: Move some functions without code change
  scsi: target: tcmu: Fix memory leak caused by wrong uio usage

 drivers/target/target_core_user.c | 189 +++++++++++++++++++++-----------------
 1 file changed, 106 insertions(+), 83 deletions(-)

-- 
2.12.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-26  2:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-18 17:50 [PATCH 0/2] scsi: target: tcmu: Fix memory leak Bodo Stroesser
2021-02-18 17:50 ` [PATCH 1/2] scsi: target: tcmu: Move some functions without code change Bodo Stroesser
2021-02-18 17:50 ` [PATCH 2/2] scsi: target: tcmu: Fix memory leak caused by wrong uio usage Bodo Stroesser
2021-02-19 19:01 ` [PATCH 0/2] scsi: target: tcmu: Fix memory leak michael.christie
2021-02-23  3:35 ` Martin K. Petersen
2021-02-26  2:22 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.