From: "KONDO KAZUMA(近藤 和真)" <kazuma-kondo@nec.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: "brauner@kernel.org" <brauner@kernel.org>,
"jack@suse.cz" <jack@suse.cz>,
"mike@mbaynton.com" <mike@mbaynton.com>,
"miklos@szeredi.hu" <miklos@szeredi.hu>,
"amir73il@gmail.com" <amir73il@gmail.com>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-unionfs@vger.kernel.org" <linux-unionfs@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"KONDO KAZUMA(近藤 和真)" <kazuma-kondo@nec.com>
Subject: Re: [PATCH] fs: allow clone_private_mount() for a path on real rootfs
Date: Wed, 14 May 2025 08:37:54 +0000 [thread overview]
Message-ID: <9138a96b-3df0-455a-9059-287a98356c4c@nec.com> (raw)
In-Reply-To: <20250514024342.GL2023217@ZenIV>
On 2025/05/14 11:43, Al Viro wrote:
> On Wed, May 14, 2025 at 12:25:58AM +0000, KONDO KAZUMA(近藤 和真) wrote:
>
>> @@ -2482,17 +2482,13 @@ struct vfsmount *clone_private_mount(const struct path *path)
>> if (IS_MNT_UNBINDABLE(old_mnt))
>> return ERR_PTR(-EINVAL);
>>
>> - if (mnt_has_parent(old_mnt)) {
>> + if (!is_mounted(&old_mnt->mnt))
>> + return ERR_PTR(-EINVAL);
>> +
>> + if (mnt_has_parent(old_mnt) || !is_anon_ns(old_mnt->mnt_ns)) {
>> if (!check_mnt(old_mnt))
>> return ERR_PTR(-EINVAL);
>> } else {
>> - if (!is_mounted(&old_mnt->mnt))
>> - return ERR_PTR(-EINVAL);
>> -
>> - /* Make sure this isn't something purely kernel internal. */
>> - if (!is_anon_ns(old_mnt->mnt_ns))
>> - return ERR_PTR(-EINVAL);
>> -
>> /* Make sure we don't create mount namespace loops. */
>> if (!check_for_nsfs_mounts(old_mnt))
>> return ERR_PTR(-EINVAL);
>
> Not the right way to do that. What we want is
>
> /* ours are always fine */
> if (!check_mnt(old_mnt)) {
> /* they'd better be mounted _somewhere */
> if (!is_mounted(old_mnt))
> return -EINVAL;
> /* no other real namespaces; only anon */
> if (!is_anon_ns(old_mnt->mnt_ns))
> return -EINVAL;
> /* ... and root of that anon */
> if (mnt_has_parent(old_mnt))
> return -EINVAL;
> /* Make sure we don't create mount namespace loops. */
> if (!check_for_nsfs_mounts(old_mnt))
> return ERR_PTR(-EINVAL);
> }
Hello Al Viro,
Thank you for your comment.
That code can solve my problem, and it seems to be better!
So, I will revise my patch and resend it.
Thanks,
Kazuma Kondo
next prev parent reply other threads:[~2025-05-14 8:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 0:25 KONDO KAZUMA(近藤 和真)
2025-05-14 2:43 ` Al Viro
2025-05-14 8:37 ` KONDO KAZUMA(近藤 和真) [this message]
2025-05-14 19:02 ` Al Viro
2025-05-15 12:12 ` KONDO KAZUMA(近藤 和真)
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=9138a96b-3df0-455a-9059-287a98356c4c@nec.com \
--to=kazuma-kondo@nec.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=mike@mbaynton.com \
--cc=miklos@szeredi.hu \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®