From: Bodo Stroesser <bostroesser@gmail.com>
To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Bodo Stroesser <bostroesser@gmail.com>,
Mike Christie <michael.christie@oracle.com>
Subject: [PATCH 0/2] scsi: target: tcmu: Fix memory leak
Date: Thu, 18 Feb 2021 18:50:37 +0100 [thread overview]
Message-ID: <20210218175039.7829-1-bostroesser@gmail.com> (raw)
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
next reply other threads:[~2021-02-18 19:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-18 17:50 Bodo Stroesser [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210218175039.7829-1-bostroesser@gmail.com \
--to=bostroesser@gmail.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.com \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.