Skip to content

Commit b799388

Browse files
cding-ddngregkh
authored andcommitted
fuse: missing copy_finish in fuse-over-io-uring argument copies
commit 6e0d7f7 upstream. Fix a possible reference count leak of payload pages during fuse argument copies. [Joanne: simplified error cleanup] Fixes: c090c8a ("fuse: Add io-uring sqe commit and fetch support") Cc: stable@vger.kernel.org # v6.14 Signed-off-by: Cheng Ding <cding@ddn.com> Signed-off-by: Bernd Schubert <bschubert@ddn.com> Reviewed-by: Joanne Koong <joannelkoong@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e0d6de8 commit b799388

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

fs/fuse/dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ void fuse_copy_init(struct fuse_copy_state *cs, bool write,
846846
}
847847

848848
/* Unmap and put previous page of userspace buffer */
849-
static void fuse_copy_finish(struct fuse_copy_state *cs)
849+
void fuse_copy_finish(struct fuse_copy_state *cs)
850850
{
851851
if (cs->currbuf) {
852852
struct pipe_buffer *buf = cs->currbuf;

fs/fuse/dev_uring.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,9 @@ static int fuse_uring_copy_from_ring(struct fuse_ring *ring,
599599
cs.is_uring = true;
600600
cs.req = req;
601601

602-
return fuse_copy_out_args(&cs, args, ring_in_out.payload_sz);
602+
err = fuse_copy_out_args(&cs, args, ring_in_out.payload_sz);
603+
fuse_copy_finish(&cs);
604+
return err;
603605
}
604606

605607
/*
@@ -650,6 +652,7 @@ static int fuse_uring_args_to_ring(struct fuse_ring *ring, struct fuse_req *req,
650652
/* copy the payload */
651653
err = fuse_copy_args(&cs, num_args, args->in_pages,
652654
(struct fuse_arg *)in_args, 0);
655+
fuse_copy_finish(&cs);
653656
if (err) {
654657
pr_info_ratelimited("%s fuse_copy_args failed\n", __func__);
655658
return err;

fs/fuse/fuse_dev_i.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void fuse_dev_end_requests(struct list_head *head);
6262

6363
void fuse_copy_init(struct fuse_copy_state *cs, bool write,
6464
struct iov_iter *iter);
65+
void fuse_copy_finish(struct fuse_copy_state *cs);
6566
int fuse_copy_args(struct fuse_copy_state *cs, unsigned int numargs,
6667
unsigned int argpages, struct fuse_arg *args,
6768
int zeroing);

0 commit comments

Comments
 (0)