Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

namespace: make timens_on_fork() return nothing

timens_on_fork() always return 0, and maybe not
need to judge the return value in copy_namespaces().

So make timens_on_fork() return nothing and do not
judge its return val in copy_namespaces().

Signed-off-by: Hui Su <sh_def@163.com>
Link: https://lore.kernel.org/r/20201117161750.GA45121@rlk
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

authored by

Hui Su and committed by
Christian Brauner
5c62634f 716e343f

+6 -13
+3 -3
include/linux/time_namespace.h
··· 45 45 struct user_namespace *user_ns, 46 46 struct time_namespace *old_ns); 47 47 void free_time_ns(struct kref *kref); 48 - int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk); 48 + void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk); 49 49 struct vdso_data *arch_get_vdso_data(void *vvar_page); 50 50 51 51 static inline void put_time_ns(struct time_namespace *ns) ··· 136 136 return old_ns; 137 137 } 138 138 139 - static inline int timens_on_fork(struct nsproxy *nsproxy, 139 + static inline void timens_on_fork(struct nsproxy *nsproxy, 140 140 struct task_struct *tsk) 141 141 { 142 - return 0; 142 + return; 143 143 } 144 144 145 145 static inline void timens_add_monotonic(struct timespec64 *ts) { }
+1 -6
kernel/nsproxy.c
··· 153 153 struct nsproxy *old_ns = tsk->nsproxy; 154 154 struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns); 155 155 struct nsproxy *new_ns; 156 - int ret; 157 156 158 157 if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | 159 158 CLONE_NEWPID | CLONE_NEWNET | ··· 179 180 if (IS_ERR(new_ns)) 180 181 return PTR_ERR(new_ns); 181 182 182 - ret = timens_on_fork(new_ns, tsk); 183 - if (ret) { 184 - free_nsproxy(new_ns); 185 - return ret; 186 - } 183 + timens_on_fork(new_ns, tsk); 187 184 188 185 tsk->nsproxy = new_ns; 189 186 return 0;
+2 -4
kernel/time/namespace.c
··· 308 308 return 0; 309 309 } 310 310 311 - int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) 311 + void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) 312 312 { 313 313 struct ns_common *nsc = &nsproxy->time_ns_for_children->ns; 314 314 struct time_namespace *ns = to_time_ns(nsc); 315 315 316 316 /* create_new_namespaces() already incremented the ref counter */ 317 317 if (nsproxy->time_ns == nsproxy->time_ns_for_children) 318 - return 0; 318 + return; 319 319 320 320 get_time_ns(ns); 321 321 put_time_ns(nsproxy->time_ns); 322 322 nsproxy->time_ns = ns; 323 323 324 324 timens_commit(tsk, ns); 325 - 326 - return 0; 327 325 } 328 326 329 327 static struct user_namespace *timens_owner(struct ns_common *ns)