From: Chengguang Xu <cgxu519@mykernel.net>
To: "Chengguang Xu" <cgxu519@mykernel.net>
Cc: "miklos" <miklos@szeredi.hu>,
"linux-unionfs" <linux-unionfs@vger.kernel.org>
Subject: 回复:[PATCH] ovl: check VM_DENYWRITE mappings in copy-up
Date: Thu, 08 Apr 2021 19:28:37 +0800 [thread overview]
Message-ID: <178b13dbf0a.c5d5924718458.7870418673694557579@mykernel.net> (raw)
In-Reply-To: <20210408112042.2586996-1-cgxu519@mykernel.net>
---- 在 星期四, 2021-04-08 19:20:42 Chengguang Xu <cgxu519@mykernel.net> 撰写 ----
> 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;
> + }
Maybe we should check this for open(with writable flag) not only for truncate case, right?
Thanks,
Chengguang
>
> if (S_ISLNK(ctx.stat.mode)) {
> ctx.link = vfs_get_link(ctx.lowerpath.dentry, &done);
> --
> 2.27.0
>
>
>
next prev parent reply other threads:[~2021-04-08 11:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 11:20 [PATCH] ovl: check VM_DENYWRITE mappings in copy-up Chengguang Xu
2021-04-08 11:28 ` Chengguang Xu [this message]
2021-04-08 11:29 ` 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
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=178b13dbf0a.c5d5924718458.7870418673694557579@mykernel.net \
--to=cgxu519@mykernel.net \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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;
as well as URLs for NNTP newsgroup(s).