From: Miklos Szeredi <miklos@szeredi.hu>
To: Chengguang Xu <cgxu519@mykernel.net>
Cc: overlayfs <linux-unionfs@vger.kernel.org>
Subject: Re: [RFC PATCH 2/2] ovl: enhance write permission check for writable open
Date: Wed, 21 Jul 2021 15:14:42 +0200 [thread overview]
Message-ID: <CAJfpegus1AKdqhLNwgLZA1PyRrUF_4VQuNnGbM+aYOYnSBjsmQ@mail.gmail.com> (raw)
In-Reply-To: <20210424140316.485444-2-cgxu519@mykernel.net>
On Sat, 24 Apr 2021 at 16:04, Chengguang Xu <cgxu519@mykernel.net> wrote:
>
> Check upper file's write permission when open on writable mode.
This should already be done in ovl_open() -> ovl_open_realfile() ->
open_with_fake_path() -> do_dentry_open().
Do you have a test case indicating that the writecount test is not working?
Thanks,
Miklos
>
> NOTE: lower files may be shared between differnt overlayfs instances,
> so we skip the check of lower file to avoid introducing interferes.
>
> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
> ---
> fs/overlayfs/file.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> index 6e454a294046..1c3c24d07d01 100644
> --- a/fs/overlayfs/file.c
> +++ b/fs/overlayfs/file.c
> @@ -144,12 +144,18 @@ static int ovl_real_fdget(const struct file *file, struct fd *real)
> static int ovl_open(struct inode *inode, struct file *file)
> {
> struct file *realfile;
> + struct inode *upperinode;
> int err;
>
> err = ovl_maybe_copy_up(file_dentry(file), file->f_flags);
> if (err)
> return err;
>
> + upperinode = ovl_inode_upper(inode);
> + if (((file->f_mode & FMODE_WRITE) || file->f_flags & O_TRUNC) &&
> + (upperinode && atomic_read(&upperinode->i_writecount) < 0))
> + return -ETXTBSY;
> +
> /* No longer need these flags, so don't pass them on to underlying fs */
> file->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
>
> --
> 2.27.0
>
>
next prev parent reply other threads:[~2021-07-21 13:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-24 14:03 [RFC PATCH 1/2] ovl: skip checking lower file's write permisson on truncate Chengguang Xu
2021-04-24 14:03 ` [RFC PATCH 2/2] ovl: enhance write permission check for writable open Chengguang Xu
2021-07-21 13:14 ` Miklos Szeredi [this message]
2021-04-28 12:18 ` 回复:[RFC PATCH 1/2] ovl: skip checking lower file's write permisson on truncate Chengguang Xu
2021-07-20 14:35 ` [RFC " Miklos Szeredi
2021-07-20 15:19 ` Miklos Szeredi
2021-07-20 16:01 ` Chengguang Xu
2021-07-20 16:01 ` Miklos Szeredi
2021-07-20 16:04 ` 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=CAJfpegus1AKdqhLNwgLZA1PyRrUF_4VQuNnGbM+aYOYnSBjsmQ@mail.gmail.com \
--to=miklos@szeredi.hu \
--cc=cgxu519@mykernel.net \
--cc=linux-unionfs@vger.kernel.org \
/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).