All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] exec: don't turn PF_KTHREAD off when command not found
@ 2010-09-09  9:03 KOSAKI Motohiro
  2010-09-09 20:39 ` Oleg Nesterov
  2010-09-10  6:12 ` Roland McGrath
  0 siblings, 2 replies; 3+ messages in thread
From: KOSAKI Motohiro @ 2010-09-09  9:03 UTC (permalink / raw)
  To: Roland McGrath, Oleg Nesterov, LKML; +Cc: kosaki.motohiro

Now, do_execve() turn PF_KTHREAD off before search_binary_handler().
It has theorical risk of PF_KTHREAD lost. When ENOEXEC case, we don't
have to turn PF_KTHREAD off.

This patch move this flag modification after founding execution file.

I guess this is only theorical issue because now any kthread don't
call do_execve() directly. but anyway fixing would be better.

Cc: Roland McGrath <roland@redhat.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 fs/exec.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index ef8b9dc..81d0d06 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1011,7 +1011,7 @@ int flush_old_exec(struct linux_binprm * bprm)
 	bprm->mm = NULL;		/* We're using it now */
 	set_exec_mm(NULL);
 
-	current->flags &= ~PF_RANDOMIZE;
+	current->flags &= ~(PF_RANDOMIZE | PF_KTHREAD);
 	flush_thread();
 	current->personality &= ~bprm->per_clear;
 
@@ -1421,7 +1421,6 @@ int do_execve(const char * filename,
 	if (retval < 0)
 		goto out;
 
-	current->flags &= ~PF_KTHREAD;
 	retval = search_binary_handler(bprm,regs);
 	if (retval < 0)
 		goto out;
-- 
1.6.5.2




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

* Re: [PATCH] exec: don't turn PF_KTHREAD off when command not found
  2010-09-09  9:03 [PATCH] exec: don't turn PF_KTHREAD off when command not found KOSAKI Motohiro
@ 2010-09-09 20:39 ` Oleg Nesterov
  2010-09-10  6:12 ` Roland McGrath
  1 sibling, 0 replies; 3+ messages in thread
From: Oleg Nesterov @ 2010-09-09 20:39 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: Roland McGrath, LKML

On 09/09, KOSAKI Motohiro wrote:
>
> I guess this is only theorical issue because now any kthread don't
> call do_execve() directly.

Yes, I think that kthread should always exit if exec fails.
Otherwise we can "trust" the thread, just suppose that exec fails
after exec_mmap() succeeds.

But,

> but anyway fixing would be better.

Agreed. It looks better if we clear PF_KTHREAD after the point-of-no-return,
and the patch saves one ->flags modification.

Oleg.


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

* Re: [PATCH] exec: don't turn PF_KTHREAD off when command not found
  2010-09-09  9:03 [PATCH] exec: don't turn PF_KTHREAD off when command not found KOSAKI Motohiro
  2010-09-09 20:39 ` Oleg Nesterov
@ 2010-09-10  6:12 ` Roland McGrath
  1 sibling, 0 replies; 3+ messages in thread
From: Roland McGrath @ 2010-09-10  6:12 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: Oleg Nesterov, LKML

That looks reasonable to me too.


Thanks,
Roland

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

end of thread, other threads:[~2010-09-10  6:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-09  9:03 [PATCH] exec: don't turn PF_KTHREAD off when command not found KOSAKI Motohiro
2010-09-09 20:39 ` Oleg Nesterov
2010-09-10  6:12 ` Roland McGrath

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.