History

Merge tag 'time-namespace-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux

Pull time namespace updates from Christian Brauner: "When time namespaces were introduced we missed to virtualize the 'btime' field in /proc/stat. This confuses tasks which are in another time namespace with a virtualized boottime which is common in some container workloads. This contains Michael's series to fix 'btime' which Thomas asked me to take through my tree. To fix 'btime' virtualization we simply subtract the offset of the time namespace's boottime from btime before printing the stats. Note that since start_boottime of processes are seconds since boottime and the boottime stamp is now shifted according to the time namespace's offset, the offset of the time namespace also needs to be applied before the process stats are given to userspace. This avoids that processes shown by tools such as 'ps' appear as time travelers in the corresponding time namespace. Selftests are included to verify that btime virtualization in /proc/stat works as expected" * tag 'time-namespace-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux: namespace: make timens_on_fork() return nothing selftests/timens: added selftest for /proc/stat btime fs/proc: apply the time namespace offset to /proc/stat btime timens: additional helper functions for boottime offset handling

Linus Torvalds committed 5 years ago

Commit 6d93a192 parents 0ca2ce8 5c626346 files · +92 −16Browse files

Showing the changes to kernel (2 of 6 files). Show all

Unified · Split

2 files
  1. kernel/nsproxy.c +1 −6
  2. kernel/time/namespace.c +2 −4
kernel/nsproxy.c+1−6
@@ -153,7 +153,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) · 152 unmodified lines
153 struct nsproxy *old_ns = tsk->nsproxy;153 struct nsproxy *old_ns = tsk->nsproxy;
154 struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);154 struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
155 struct nsproxy *new_ns;155 struct nsproxy *new_ns;
156 int ret;
157 156
158 if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |157 if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
159 CLONE_NEWPID | CLONE_NEWNET |158 CLONE_NEWPID | CLONE_NEWNET |
@@ -180,11 +179,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) · 20 unmodified lines
180 if (IS_ERR(new_ns))179 if (IS_ERR(new_ns))
181 return PTR_ERR(new_ns);180 return PTR_ERR(new_ns);
182 181
183 ret = timens_on_fork(new_ns, tsk);182 timens_on_fork(new_ns, tsk);
184 if (ret) {
185 free_nsproxy(new_ns);
186 return ret;
187 }
188 183
189 tsk->nsproxy = new_ns;184 tsk->nsproxy = new_ns;
190 return 0;185 return 0;
kernel/time/namespace.c+2−4
@@ -308,22 +308,20 @@ static int timens_install(struct nsset *nsset, struct ns_common *new) · 307 unmodified lines
308 return 0;308 return 0;
309}309}
310 310
311int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)311void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
312{312{
313 struct ns_common *nsc = &nsproxy->time_ns_for_children->ns;313 struct ns_common *nsc = &nsproxy->time_ns_for_children->ns;
314 struct time_namespace *ns = to_time_ns(nsc);314 struct time_namespace *ns = to_time_ns(nsc);
315 315
316 /* create_new_namespaces() already incremented the ref counter */316 /* create_new_namespaces() already incremented the ref counter */
317 if (nsproxy->time_ns == nsproxy->time_ns_for_children)317 if (nsproxy->time_ns == nsproxy->time_ns_for_children)
318 return 0;318 return;
319 319
320 get_time_ns(ns);320 get_time_ns(ns);
321 put_time_ns(nsproxy->time_ns);321 put_time_ns(nsproxy->time_ns);
322 nsproxy->time_ns = ns;322 nsproxy->time_ns = ns;
323 323
324 timens_commit(tsk, ns);324 timens_commit(tsk, ns);
325
326 return 0;
327}325}
328 326
329static struct user_namespace *timens_owner(struct ns_common *ns)327static struct user_namespace *timens_owner(struct ns_common *ns)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t