archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <>
To: Chengguang Xu <>
Cc: overlayfs <>
Subject: Re: [RFC PATCH 1/2] ovl: skip checking lower file's write permisson on truncate
Date: Tue, 20 Jul 2021 17:19:16 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, 20 Jul 2021 at 16:35, Miklos Szeredi <> wrote:
> On Sat, 24 Apr 2021 at 16:04, Chengguang Xu <> wrote:
> >
> > Lower files may be shared in overlayfs so strictly checking write
> > perssmion on lower file will cause interferes between different
> > overlayfs instances.
> How so?
> i_writecount on lower inode is not modified by overlayfs (at least not
> in this codepath).  Which means that there should be no interference
> between overlayfs instances sharing a lower directory tree.

I'm beginning to see what you are worrying about.

So on one instance a file on lower gets executed and on another
instance sharing the lower layer the file is truncated.  The truncate
is currently denied due to the negative i_writecount on the lower
file.  Also behavior is inconsistent between open(path, O_TRUNC) and
truncate(path) even though the two should be equivalent.

Applied with the following description:

It is possible that a directory tree is shared between multiple overlay
instances as a lower layer.  In this case when one instance executes a file
residing on the lower layer, the other instance denies a truncate(2) call
on this file.

This only happens for truncate(2) and not for open(2) with the O_TRUNC

Fix this interference and inconsistency by removing the preliminary
i_writecount check before copy-up.

This means that unlike on normal filesystems truncate(argv[0]) will now
succeed.  If this ever causes a regression in a real world use case this
needs to be revisited.

One way to fix this properly would be to keep a correct i_writecount in the
overlay inode, but that is difficult due to memory mapping code only
dealing with the real file/inode.


  reply	other threads:[~2021-07-20 15:46 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
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 [this message]
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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \ \

* 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).