From: Greg Kroah-Hartman Date: Thu, 13 Oct 2022 09:15:11 +0000 (+0200) Subject: 4.9-stable patches X-Git-Tag: v5.4.218~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f8d1424e9fd0f89548591fdfb8cedb5dbf330447;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: ceph-don-t-truncate-file-in-atomic_open.patch --- diff --git a/queue-4.9/ceph-don-t-truncate-file-in-atomic_open.patch b/queue-4.9/ceph-don-t-truncate-file-in-atomic_open.patch new file mode 100644 index 00000000000..833afed8910 --- /dev/null +++ b/queue-4.9/ceph-don-t-truncate-file-in-atomic_open.patch @@ -0,0 +1,51 @@ +From 7cb9994754f8a36ae9e5ec4597c5c4c2d6c03832 Mon Sep 17 00:00:00 2001 +From: Hu Weiwen +Date: Fri, 1 Jul 2022 10:52:27 +0800 +Subject: ceph: don't truncate file in atomic_open + +From: Hu Weiwen + +commit 7cb9994754f8a36ae9e5ec4597c5c4c2d6c03832 upstream. + +Clear O_TRUNC from the flags sent in the MDS create request. + +`atomic_open' is called before permission check. We should not do any +modification to the file here. The caller will do the truncation +afterward. + +Fixes: 124e68e74099 ("ceph: file operations") +Signed-off-by: Hu Weiwen +Reviewed-by: Xiubo Li +Signed-off-by: Ilya Dryomov +[Xiubo: fixed a trivial conflict for 4.9 backport] +Signed-off-by: Xiubo Li +Signed-off-by: Greg Kroah-Hartman +--- + fs/ceph/file.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +--- a/fs/ceph/file.c ++++ b/fs/ceph/file.c +@@ -354,6 +354,11 @@ int ceph_atomic_open(struct inode *dir, + err = ceph_init_dentry(dentry); + if (err < 0) + return err; ++ /* ++ * Do not truncate the file, since atomic_open is called before the ++ * permission check. The caller will do the truncation afterward. ++ */ ++ flags &= ~O_TRUNC; + + if (flags & O_CREAT) { + err = ceph_pre_init_acls(dir, &mode, &acls); +@@ -384,9 +389,7 @@ int ceph_atomic_open(struct inode *dir, + req->r_args.open.mask = cpu_to_le32(mask); + + req->r_locked_dir = dir; /* caller holds dir->i_mutex */ +- err = ceph_mdsc_do_request(mdsc, +- (flags & (O_CREAT|O_TRUNC)) ? dir : NULL, +- req); ++ err = ceph_mdsc_do_request(mdsc, (flags & O_CREAT) ? dir : NULL, req); + err = ceph_handle_snapdir(req, dentry, err); + if (err) + goto out_req; diff --git a/queue-4.9/series b/queue-4.9/series index 7226696e7da..e7793d5a857 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -27,3 +27,4 @@ usb-serial-ftdi_sio-fix-300-bps-rate-for-sio.patch nilfs2-fix-null-pointer-dereference-at-nilfs_bmap_lookup_at_level.patch nilfs2-fix-leak-of-nilfs_root-in-case-of-writer-thread-creation-failure.patch nilfs2-replace-warn_ons-by-nilfs_error-for-checkpoint-acquisition-failure.patch +ceph-don-t-truncate-file-in-atomic_open.patch