From: Max Kellermann <max.kellermann@ionos.com>
To: amarkuze@redhat.com, xiubli@redhat.com, idryomov@gmail.com,
ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org, Max Kellermann <max.kellermann@ionos.com>
Subject: [PATCH v2] fs/ceph/file: fix memory leaks in __ceph_sync_read()
Date: Thu, 5 Dec 2024 16:49:51 +0100 [thread overview]
Message-ID: <20241205154951.4163232-1-max.kellermann@ionos.com> (raw)
In-Reply-To: <CAOi1vP8PRbO3853M-MgMZfPOR+9TS1CrW5AGVP0s06u_=Xq3bg@mail.gmail.com>
In two `break` statements, the call to ceph_release_page_vector() was
missing, leaking the allocation from ceph_alloc_page_vector().
Instead of adding the missing ceph_release_page_vector() calls, the
Ceph maintainers preferred to transfer page ownership to the
`ceph_osd_request` by passing `own_pages=true` to
osd_req_op_extent_osd_data_pages(). This requires postponing the
ceph_osdc_put_request() call until after the block that accesses the
`pages`.
Cc: stable@vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/ceph/file.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 4b8d59ebda00..ce342a5d4b8b 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1127,7 +1127,7 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
osd_req_op_extent_osd_data_pages(req, 0, pages, read_len,
offset_in_page(read_off),
- false, false);
+ false, true);
op = &req->r_ops[0];
if (sparse) {
@@ -1186,8 +1186,6 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
ret = min_t(ssize_t, fret, len);
}
- ceph_osdc_put_request(req);
-
/* Short read but not EOF? Zero out the remainder. */
if (ret >= 0 && ret < len && (off + ret < i_size)) {
int zlen = min(len - ret, i_size - off - ret);
@@ -1221,7 +1219,8 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
break;
}
}
- ceph_release_page_vector(pages, num_pages);
+
+ ceph_osdc_put_request(req);
if (ret < 0) {
if (ret == -EBLOCKLISTED)
--
2.45.2
next prev parent reply other threads:[~2024-12-05 15:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 21:20 [PATCH] fs/ceph/file: fix memory leaks in __ceph_sync_read() Max Kellermann
2024-11-28 12:17 ` Alex Markuze
2024-11-28 12:28 ` Max Kellermann
2024-11-28 12:31 ` Max Kellermann
2024-11-28 12:48 ` Alex Markuze
2024-11-28 13:11 ` Max Kellermann
2024-11-29 8:06 ` Max Kellermann
2024-12-05 8:32 ` Max Kellermann
2024-12-05 11:24 ` Ilya Dryomov
2024-12-05 11:31 ` Alex Markuze
2024-12-05 12:02 ` Max Kellermann
2024-12-05 12:17 ` Alex Markuze
2024-12-05 12:32 ` Max Kellermann
2024-12-05 12:22 ` Max Kellermann
2024-12-05 12:57 ` Alex Markuze
2024-12-05 13:08 ` Max Kellermann
2024-12-05 15:12 ` Ilya Dryomov
2024-12-05 15:37 ` Max Kellermann
2024-12-05 15:42 ` Max Kellermann
2024-12-05 15:49 ` Max Kellermann [this message]
2024-12-05 16:30 ` [PATCH v2] " Alex Markuze
2024-12-06 12:50 ` Ilya Dryomov
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=20241205154951.4163232-1-max.kellermann@ionos.com \
--to=max.kellermann@ionos.com \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=xiubli@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox