[PATCH 5.4 24/92] fuse: verify write return

From: Greg Kroah-Hartman
Date: Wed Dec 11 2019 - 10:08:01 EST


From: Miklos Szeredi <mszeredi@xxxxxxxxxx>

commit 8aab336b14c115c6bf1d4baeb9247e41ed9ce6de upstream.

Make sure filesystem is not returning a bogus number of bytes written.

Fixes: ea9b9907b82a ("fuse: implement perform_write")
Cc: <stable@xxxxxxxxxxxxxxx> # v2.6.26
Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
fs/fuse/file.c | 2 ++
1 file changed, 2 insertions(+)

--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1098,6 +1098,8 @@ static ssize_t fuse_send_write_pages(str
ia->write.in.flags = fuse_write_flags(iocb);

err = fuse_simple_request(fc, &ap->args);
+ if (!err && ia->write.out.size > count)
+ err = -EIO;

offset = ap->descs[0].offset;
count = ia->write.out.size;