linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ovl: check VM_DENYWRITE mappings in copy-up
@ 2021-04-08 11:20 Chengguang Xu
  2021-04-08 11:28 ` 回复:[PATCH] " Chengguang Xu
  0 siblings, 1 reply; 8+ messages in thread
From: Chengguang Xu @ 2021-04-08 11:20 UTC (permalink / raw)
  To: miklos; +Cc: linux-unionfs, Chengguang Xu

In overlayfs copy-up, if open flag has O_TRUNC then upper
file will truncate to zero size, in this case we should check
VM_DENYWRITE mappings to keep compatibility with other filesystems.

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
 fs/overlayfs/copy_up.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 0fed532efa68..c56c81494b0c 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -901,8 +901,11 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
 	}
 
 	/* maybe truncate regular file. this has no effect on dirs */
-	if (flags & O_TRUNC)
+	if (flags & O_TRUNC) {
+		if (atomic_read(&d_inode(ovl_dentry_real(dentry))->i_writecount) < 0)
+			return -ETXTBSY;
 		ctx.stat.size = 0;
+	}
 
 	if (S_ISLNK(ctx.stat.mode)) {
 		ctx.link = vfs_get_link(ctx.lowerpath.dentry, &done);
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-04-20 11:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 11:20 [PATCH] ovl: check VM_DENYWRITE mappings in copy-up Chengguang Xu
2021-04-08 11:28 ` 回复:[PATCH] " Chengguang Xu
2021-04-08 11:29   ` [PATCH] " Miklos Szeredi
2021-04-08 11:40     ` Chengguang Xu
2021-04-08 15:03       ` Miklos Szeredi
2021-04-13  3:26         ` Chengguang Xu
2021-04-13  8:47           ` Miklos Szeredi
2021-04-20 11:14             ` Chengguang Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).