* man 2 unshare: UNSHARE_EMPTY_MNTNS
@ 2026-11-12 16:42 Niklas Hambüchen
2026-11-19 23:22 ` Alejandro Colomar
0 siblings, 1 reply; 5+ messages in thread
From: Niklas Hambüchen @ 2026-11-12 16:42 UTC (permalink / raw)
To: Alejandro Colomar; +Cc: linux-man
Dear man pages maintainers,
I just want to point out that unshare has a new flag in Linux >= 7.1:
UNSHARE_EMPTY_MNTNS
See e.g.
https://github.com/torvalds/linux/commit/9d4e752a24f740b31ca827bfab07010e4e7f34b0#diff-871f39f0834631ea368e8539ee88840ade11866cd6104e91543f9387dd1b8386R39-R52
"
This is useful for containers and sandboxes that want to
start with a minimal mount table and populate it from scratch rather
than inheriting and then tearing down the full mount tree.
"
Note a little quirk caused by this change:
This is the first `unshare` flag that isn't a `CLONE_*` one, so it breaks the existing invariant that all `unshare` flags are also valid `clone3` flags.
The commit remarks:
"
* unshare flags share the bit space with clone flags but only apply to the
* unshare syscall:
"
I guess that part isn't really relevant for the man page, but I thought to point it out on this list, for searchability of this fact.
Cheers,
Niklas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: man 2 unshare: UNSHARE_EMPTY_MNTNS
2026-11-12 16:42 man 2 unshare: UNSHARE_EMPTY_MNTNS Niklas Hambüchen
@ 2026-11-19 23:22 ` Alejandro Colomar
2026-11-27 12:51 ` Christian Brauner
0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2026-11-19 23:22 UTC (permalink / raw)
To: Niklas Hambüchen; +Cc: linux-man, Christian Brauner
[-- Attachment #1: Type: text/plain, Size: 1464 bytes --]
Hi Niklas, Christian,
> Date: 2026-11-12 17:42:33+0100
> From: Niklas Hambüchen <mail@nh2.me>
>
> Dear man pages maintainers,
>
> I just want to point out that unshare has a new flag in Linux >= 7.1:
> UNSHARE_EMPTY_MNTNS
>
> See e.g.
> https://github.com/torvalds/linux/commit/9d4e752a24f740b31ca827bfab07010e4e7f34b0#diff-871f39f0834631ea368e8539ee88840ade11866cd6104e91543f9387dd1b8386R39-R52
>
> "
> This is useful for containers and sandboxes that want to
> start with a minimal mount table and populate it from scratch rather
> than inheriting and then tearing down the full mount tree.
> "
>
> Note a little quirk caused by this change:
>
> This is the first `unshare` flag that isn't a `CLONE_*` one, so it breaks the existing invariant that all `unshare` flags are also valid `clone3` flags.
> The commit remarks:
That same commit also adds CLONE_EMPTY_MNTNS (according to the commit
message, for clone3(2)). Could you explain why there are two separate
flags? Would you mind writing a patch for the manual pages?
>
> "
> * unshare flags share the bit space with clone flags but only apply to the
> * unshare syscall:
> "
>
> I guess that part isn't really relevant for the man page, but I
> thought to point it out on this list, for searchability of this fact.
It's probably relevant, I'd say.
Have a lovely night!
Alex
>
> Cheers,
> Niklas
>
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: man 2 unshare: UNSHARE_EMPTY_MNTNS
2026-11-19 23:22 ` Alejandro Colomar
@ 2026-11-27 12:51 ` Christian Brauner
2026-11-27 13:07 ` Alejandro Colomar
0 siblings, 1 reply; 5+ messages in thread
From: Christian Brauner @ 2026-11-27 12:51 UTC (permalink / raw)
To: Alejandro Colomar, Niklas Hambüchen; +Cc: linux-man
On Fri, Nov 20, 2026 at 12:22:52AM +0100, Alejandro Colomar wrote:
> That same commit also adds CLONE_EMPTY_MNTNS (according to the commit
> message, for clone3(2)). Could you explain why there are two separate
> flags?
unshare() only takes 32 bits. All of them are taken by legacy CLONE_*
flags. New clone3() flags live above bit 31 so CLONE_EMPTY_MNTNS (1ULL
<< 37) can't be passed to unshare(). UNSHARE_EMPTY_MNTNS reuses the
CLONE_PARENT_SETTID bit which has no meaning for unshare(). Both imply
CLONE_NEWNS.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: man 2 unshare: UNSHARE_EMPTY_MNTNS
2026-11-27 12:51 ` Christian Brauner
@ 2026-11-27 13:07 ` Alejandro Colomar
2026-11-27 13:08 ` Alejandro Colomar
0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2026-11-27 13:07 UTC (permalink / raw)
To: Christian Brauner; +Cc: Niklas Hambüchen, linux-man, linux-api
[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]
[CC += linux-api@]
Hi Christian,
> Date: 2026-11-27 13:51:03+0100
> From: Christian Brauner <brauner@kernel.org>
>
> On Fri, Nov 20, 2026 at 12:22:52AM +0100, Alejandro Colomar wrote:
> > That same commit also adds CLONE_EMPTY_MNTNS (according to the commit
> > message, for clone3(2)). Could you explain why there are two separate
> > flags?
>
> unshare() only takes 32 bits. All of them are taken by legacy CLONE_*
> flags. New clone3() flags live above bit 31 so CLONE_EMPTY_MNTNS (1ULL
> << 37) can't be passed to unshare(). UNSHARE_EMPTY_MNTNS reuses the
> CLONE_PARENT_SETTID bit which has no meaning for unshare(). Both imply
> CLONE_NEWNS.
Hmmm, thanks!
$ git grep -hP -f <(grepc_c -tm CLONE_EMPTY_MNTNS) include/
#define CLONE_EMPTY_MNTNS (1ULL << 37) /* Create an empty mount namespace. */
$ git grep -hP -f <(grepc_c -tm UNSHARE_EMPTY_MNTNS) include/
#define UNSHARE_EMPTY_MNTNS 0x00100000 /* Unshare an empty mount namespace. */
$ git grep -hP -f <(grepc_c -tm CLONE_PARENT_SETTID) include/
#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
Would it make sense to create new UNSHARE_* flags for all the existing
CLONE_* flags that make sense in unshare(2)? That would avoid some
possible confusion.
That is:
$ man 2 unshare | grep -o '^.....CLONE_\w*' | sed s/CLONE/UNSHARE/;
UNSHARE_FILES
UNSHARE_FS
UNSHARE_NEWCGROUP
UNSHARE_NEWIPC
UNSHARE_NEWNET
UNSHARE_NEWNS
UNSHARE_NEWPID
UNSHARE_NEWTIME
UNSHARE_NEWUSER
UNSHARE_NEWUTS
UNSHARE_SYSVSEM
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: man 2 unshare: UNSHARE_EMPTY_MNTNS
2026-11-27 13:07 ` Alejandro Colomar
@ 2026-11-27 13:08 ` Alejandro Colomar
0 siblings, 0 replies; 5+ messages in thread
From: Alejandro Colomar @ 2026-11-27 13:08 UTC (permalink / raw)
To: Christian Brauner
Cc: Niklas Hambüchen, linux-man, linux-api, linux-fsdevel,
Jan Kara, Alexander Viro
[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]
[CC += linux-api@]
Hi Christian,
> Date: 2026-11-27 13:51:03+0100
> From: Christian Brauner <brauner@kernel.org>
>
> On Fri, Nov 20, 2026 at 12:22:52AM +0100, Alejandro Colomar wrote:
> > That same commit also adds CLONE_EMPTY_MNTNS (according to the commit
> > message, for clone3(2)). Could you explain why there are two separate
> > flags?
>
> unshare() only takes 32 bits. All of them are taken by legacy CLONE_*
> flags. New clone3() flags live above bit 31 so CLONE_EMPTY_MNTNS (1ULL
> << 37) can't be passed to unshare(). UNSHARE_EMPTY_MNTNS reuses the
> CLONE_PARENT_SETTID bit which has no meaning for unshare(). Both imply
> CLONE_NEWNS.
Hmmm, thanks!
$ git grep -hP -f <(grepc_c -tm CLONE_EMPTY_MNTNS) include/
#define CLONE_EMPTY_MNTNS (1ULL << 37) /* Create an empty mount namespace. */
$ git grep -hP -f <(grepc_c -tm UNSHARE_EMPTY_MNTNS) include/
#define UNSHARE_EMPTY_MNTNS 0x00100000 /* Unshare an empty mount namespace. */
$ git grep -hP -f <(grepc_c -tm CLONE_PARENT_SETTID) include/
#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
Would it make sense to create new UNSHARE_* flags for all the existing
CLONE_* flags that make sense in unshare(2)? That would avoid some
possible confusion.
That is:
$ man 2 unshare | grep -o '^.....CLONE_\w*' | sed s/CLONE/UNSHARE/;
UNSHARE_FILES
UNSHARE_FS
UNSHARE_NEWCGROUP
UNSHARE_NEWIPC
UNSHARE_NEWNET
UNSHARE_NEWNS
UNSHARE_NEWPID
UNSHARE_NEWTIME
UNSHARE_NEWUSER
UNSHARE_NEWUTS
UNSHARE_SYSVSEM
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-27 13:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 16:42 man 2 unshare: UNSHARE_EMPTY_MNTNS Niklas Hambüchen
2026-11-19 23:22 ` Alejandro Colomar
2026-11-27 12:51 ` Christian Brauner
2026-11-27 13:07 ` Alejandro Colomar
2026-11-27 13:08 ` Alejandro Colomar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox