linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kmod: avoid propagating PF_NO_SETAFFINITY into userspace child
@ 2013-11-14  1:51 zhang.yi20
  2013-11-14  5:23 ` Tejun Heo
  0 siblings, 1 reply; 69+ messages in thread
From: zhang.yi20 @ 2013-11-14  1:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tejun Heo, Tetsuo Handa, Oleg Nesterov


The kernel worker thread has the PF_NO_SETAFFINITY flag, and it is propagated
into the userspace child. Clearing this flag in usersapce child to enable its
migrating capability.


Signed-off-by: Zhang Yi <zhang.yi20@zte.com.cn>

--- linux3-12/kernel/kmod.c	2013-11-14 09:06:58.991781656 +0000
+++ linux3-12/kernel/kmod.c	2013-11-14 09:08:47.511781621 +0000
@@ -217,6 +217,7 @@ static int ____call_usermodehelper(void
 	 * Avoid propagating that into the userspace child.
 	 */
 	set_user_nice(current, 0);
+	current->flags &= ~PF_NO_SETAFFINITY;

 	retval = -ENOMEM;
 	new = prepare_kernel_cred(current);


^ permalink raw reply	[flat|nested] 69+ messages in thread
* [PATCH]: exec: avoid propagating PF_NO_SETAFFINITY into userspace child
@ 2013-11-29  9:19 zhang.yi20
  0 siblings, 0 replies; 69+ messages in thread
From: zhang.yi20 @ 2013-11-29  9:19 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Tejun Heo, lkml, Ingo Molnar, Oleg Nesterov, Tetsuo Handa, pang.xunlei


Khelper is a workqueue thread which has PF_NO_SETAFFINITY set.
When a usermode process is spawned by khelper through __call_usermodehelper()
which will invoke kernel_thread() (not kthread_create()) to fork the new
process, we will clearly see that it will inherit the PF_NO_SETAFFINITY flag.

Consequently, this usermod process will lose some capabilities like
sched_setaffinity(), moving between cgroups, etc.

Clearing this flag in flush_old_exec() to solve this problem.


Signed-off-by: Zhang Yi <zhang.yi20@zte.com.cn>
Signed-off-by: Pang Xunlei <pang.xunlei@zte.com.cn>

--- linux-3.12.old/fs/exec.c	2013-11-26 08:53:12.175811856 +0000
+++ linux-3.12/fs/exec.c	2013-11-27 09:36:56.231972168 +0000
@@ -1090,8 +1090,8 @@ int flush_old_exec(struct linux_binprm *
 	bprm->mm = NULL;		/* We're using it now */

 	set_fs(USER_DS);
-	current->flags &=
-		~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | PF_NOFREEZE);
+	current->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
+					PF_NOFREEZE | PF_NO_SETAFFINITY);
 	flush_thread();
 	current->personality &= ~bprm->per_clear;



^ permalink raw reply	[flat|nested] 69+ messages in thread

end of thread, other threads:[~2013-12-06 15:55 UTC | newest]

Thread overview: 69+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-14  1:51 kmod: avoid propagating PF_NO_SETAFFINITY into userspace child zhang.yi20
2013-11-14  5:23 ` Tejun Heo
2013-11-14 11:40   ` Oleg Nesterov
2013-11-14 11:55     ` [PATCH 0/1]: (Was: kmod: avoid propagating PF_NO_SETAFFINITY into userspace child) Oleg Nesterov
2013-11-14 11:56       ` [PATCH 1/1] workqueue: swap set_cpus_allowed_ptr() and PF_NO_SETAFFINITY Oleg Nesterov
2013-11-22 23:13         ` Tejun Heo
     [not found]           ` <OF36E72FA9.51146BE3-ON48257C2E.0008BC6D-48257C2E.0008FF9C@zte.com.cn>
2013-11-25 12:14             ` 答复: " Oleg Nesterov
2013-11-26  2:10               ` [PATCH]: exec: avoid propagating PF_NO_SETAFFINITY into userspace child zhang.yi20
2013-11-26 18:04                 ` Oleg Nesterov
2013-11-27  2:07                   ` zhang.yi20
2013-11-27 13:20                     ` Oleg Nesterov
2013-11-27 18:31                     ` Tejun Heo
2013-11-28  9:13                       ` Peter Zijlstra
2013-11-28 11:45                         ` Oleg Nesterov
2013-11-28 12:17                           ` Peter Zijlstra
2013-11-28 13:31                             ` Oleg Nesterov
2013-11-28 13:39                               ` Peter Zijlstra
2013-11-28 14:13                                 ` Tejun Heo
2013-11-28 14:31                                   ` Peter Zijlstra
2013-11-28 14:38                                     ` Tejun Heo
2013-11-28 14:47                                       ` Peter Zijlstra
2013-11-28 14:51                                         ` Tejun Heo
2013-11-28 14:55                                       ` Peter Zijlstra
2013-11-28 14:57                                         ` Tejun Heo
2013-11-28 14:59                                           ` Peter Zijlstra
2013-11-28 15:07                                             ` Tejun Heo
2013-11-28 15:17                                               ` Peter Zijlstra
2013-11-28 15:39                                                 ` Tejun Heo
2013-11-28 16:33                                                   ` Peter Zijlstra
2013-11-29 14:33                                                     ` Tejun Heo
2013-11-28 15:47                                                 ` Oleg Nesterov
2013-11-28 16:07                                                   ` Oleg Nesterov
2013-11-28 14:43                                     ` Peter Zijlstra
2013-11-28 14:53                                       ` Tejun Heo
2013-11-28 14:57                                         ` Peter Zijlstra
2013-11-28 15:02                                           ` Tejun Heo
2013-11-28 15:07                                             ` Peter Zijlstra
2013-11-28 15:10                                               ` Tejun Heo
2013-11-28 15:18                                                 ` Peter Zijlstra
2013-11-28 14:38                                   ` Peter Zijlstra
2013-11-28 14:45                                     ` Tejun Heo
2013-11-28 14:53                                       ` Peter Zijlstra
2013-11-28 15:34                                     ` Oleg Nesterov
2013-11-28 15:40                                       ` Peter Zijlstra
2013-11-28 16:20                                         ` Oleg Nesterov
2013-11-28 16:38                                           ` Peter Zijlstra
2013-11-28 18:13                                             ` Oleg Nesterov
2013-11-28 14:23                                 ` Oleg Nesterov
2013-11-28 14:31                                   ` Tejun Heo
2013-11-28 15:00                                     ` Oleg Nesterov
2013-11-28 15:02                                       ` Peter Zijlstra
2013-11-28 19:33                                         ` [PATCH 0/1] usermodehelper: kill ____call_usermodehelper()->set_cpus_allowed_ptr() Oleg Nesterov
2013-11-28 19:33                                           ` [PATCH 1/1] " Oleg Nesterov
2013-11-29 13:44                                             ` Tejun Heo
2013-11-29 16:49                                               ` Oleg Nesterov
2013-12-05 14:21                                             ` Frederic Weisbecker
2013-12-05 14:37                                               ` Oleg Nesterov
2013-12-05 14:39                                                 ` Tejun Heo
2013-12-05 15:30                                                   ` Oleg Nesterov
2013-12-05 19:13                                                     ` Christoph Lameter
2013-12-06 14:53                                                       ` Oleg Nesterov
2013-12-06 15:37                                                         ` Christoph Lameter
2013-12-06 15:56                                                           ` Oleg Nesterov
2013-12-05 16:26                                                   ` Frederic Weisbecker
2013-12-05 14:42                                                 ` Frederic Weisbecker
2013-11-28 13:41                               ` [PATCH]: exec: avoid propagating PF_NO_SETAFFINITY into userspace child Peter Zijlstra
2013-11-28 14:05                                 ` Tejun Heo
2013-11-28 14:34                                 ` Oleg Nesterov
2013-11-29  9:19 zhang.yi20

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).