linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yun Levi <ppbuk5246@gmail.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [Question] Unlinking original file of bind mounted file.
Date: Sat, 31 Dec 2022 07:58:09 +0900	[thread overview]
Message-ID: <CAM7-yPSdnPg56fQ=j11neee5UN3jLE6e3D5tmtMxHufR_nVD+g@mail.gmail.com> (raw)
In-Reply-To: <Y69dRHaTLqgY+vLG@sol.localdomain>

> No, it doesn't change the refcount of the dentry.  The unlink does temporarily
> increment, and then decrement, the refcount.  However, there is still another
> reference that's held by the bind mount.  For that reason, the dentry's inode is
> not released yet; instead, the dentry is just made unavailable to lookups.
>

>You can't actually do that, because the unlink fails with EBUSY.  And even if
> you could, it would be a different dentry (b instead of a).

Thanks for the correction!. I've said wrong sorry!


> If you have a reproducer for an actual crash, please provide it.  (And if you do
> indeed have an actual crash, please consider that its root cause may be
> completely unrelated to the theory that you've described...)

What I describe doesn't cause any panic. but I've traced with crash in
live below situation.:

======================================================
/**
 * NOT directory bind, file bind.
 */
1. mount --bind {original file} {bind file}

  // original's inode->i_count = 1, inode->i_nlink =0, and ext4_inode
becomes orphaned,
  // inode->i_no which managed by ext4 is freed and become reusable.
2. rm -f {original file}
=======================================================

It's not issued remove of bind itself. after step (2)
In the view of VFS, inode seems live, but in the view of EXT4, it
becomes "orphaned" and
its inode->i_no which managed by ext4. was removed and reuse by other
created file.

In that situation, if inode->i_no is reused, via bind fil,
It seems "arbitrary access" the data of new created one with same i_no.
(write, and read...)

What I wonder is that it's intended action or not.
IMHO, should it prohibit to unlink of original to prevent above
arbitrary access?

Thanks.

--
Sincerely,
Levi

  reply	other threads:[~2022-12-30 22:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-30  8:08 [Question] Unlinking original file of bind mounted file Yun Levi
2022-12-30 10:58 ` Matthew Wilcox
     [not found]   ` <CAM7-yPROANYjeGn3ECfqmn0sLzEQPUpzCyU5zSN3-mJv3UA4CA@mail.gmail.com>
2022-12-30 11:16     ` Fwd: " Yun Levi
2022-12-30 21:51       ` Eric Biggers
2022-12-30 22:58         ` Yun Levi [this message]
2022-12-30 23:05           ` Eric Biggers
2022-12-31  4:35             ` Yun Levi

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='CAM7-yPSdnPg56fQ=j11neee5UN3jLE6e3D5tmtMxHufR_nVD+g@mail.gmail.com' \
    --to=ppbuk5246@gmail.com \
    --cc=ebiggers@kernel.org \
    --cc=linux-fsdevel@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).