Skip to contentSkip to conversation

New: The shell example in time_namespaces doesn't behave as documented

Bug 217547 [email protected] 1 participant 3 messages Jun 13, 2023 – Jun 25, 2023 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=217547

Bug ID: 217547
Summary: The shell example in time_namespaces doesn't behave as
documented
Product: Documentation
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P3
Component: man-pages
Assignee: [email protected]
Reporter: [email protected]
Regression: No

Trying the shell example in the manual page for time_namespaces(7) does not behave for me the way the manual page says it should. From what I can tell, it appears that the new shell ITSELF immediately enters the new namespace, rather than allowing for children to enter. This makes it impossible to write anything to the time_for_children file.

Using the --boottime flag to unshare gives the expected behavior. Does an exec() trigger entering the new time namespace nowadays?

This was tested on a Fedora 38 system running kernel 6.2.14-300.fc38.

Example session:

kalle$$ readlink /proc/$$/ns/time
time:[4026531834]
kalle$$ LANG=en_US.utf8 PS1="ns2# " sudo unshare -T -- bash --norc [sudo] password for göran:
bash-5.2# echo "monotonic $((2*24*60*60)) 0" > /proc/$$/timens_offsets
bash: echo: write error: Permission denied
bash-5.2# readlink /proc/$$/ns/time
time:[4026532249]
bash-5.2# readlink /proc/$$/ns/time_for_children time:[4026532249]

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#1 lore raw

[Bug 217547] The shell example in time_namespaces doesn't behave as documented

https://bugzilla.kernel.org/show_bug.cgi?id=217547

Thomas Weißschuh ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #1 from Thomas Weißschuh ([email protected]) ---
It seems in commit 2b5f9dad32ed ("fs/exec: switch timens when a task gets a new mm")
the time namespace is frozen on exec().

begin_new_exec()
exec_task_namespaces()

    timens_on_fork()
      timens_commit()
        timens_set_vvar_page()
          ns->frozen_offsets = true

As a workaround you could use "unshare -T --monotonic $((2*24*60*60))" to let unshare set the offsets directly.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#2 lore raw

[Bug 217547] The shell example in time_namespaces doesn't behave as documented

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=217547

--- Comment #2 from Göran Uddeborg ([email protected]) ---
That command works as expected, but unfortunately it doesn't illustrate the behaviour as nicely. For example, the direct writes will not be visible, and "time" and "time_for_children" will no longer differ.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.