linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Roland McGrath <roland@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [BUG] ptraced process waiting on syscall may return kernel internal errnos
Date: Thu, 14 Jun 2007 14:26:44 +0200	[thread overview]
Message-ID: <200706141426.45522.rjw@sisk.pl> (raw)
In-Reply-To: <20070613151530.GA232@tv-sign.ru>

Sorry for being late, I've just realized that you are discussing the freezer
here. ;-)

On Wednesday, 13 June 2007 17:15, Oleg Nesterov wrote:
> Sorry for delay, I was completely offline,
> 
> On 06/06, Roland McGrath wrote:
> > 
> > [PATCH] Restrict clearing TIF_SIGPENDING
> > 
> > This patch should get a few birds.  It prevents sigaction calls from
> > clearing TIF_SIGPENDING in other threads, which could leak -ERESTART*.
> > It fixes ptrace_stop not to clear it, which done at the syscall exit
> > stop could leak -ERESTART*.  It probably removes the harm from
> > signalfd, at least assuming it never calls dequeue_signal on kernel
> > threads that might have used block_all_signals.
> > 
> > Signed-off-by: Roland McGrath <roland@redhat.com>
> > ---
> >  kernel/signal.c |   40 ++++++++++++++++++++++++----------------
> >  1 files changed, 24 insertions(+), 16 deletions(-)
> > 
> > diff --git a/kernel/signal.c b/kernel/signal.c
> > index acdfc05..dc5797c 100644  
> > --- a/kernel/signal.c
> > +++ b/kernel/signal.c
> > @@ -105,7 +105,11 @@ static int recalc_sigpending_tsk(struct 
> >  		set_tsk_thread_flag(t, TIF_SIGPENDING);
> >  		return 1;
> >  	}
> > -	clear_tsk_thread_flag(t, TIF_SIGPENDING);
> > +	/*
> > +	 * We must never clear the flag in another thread, or in current
> > +	 * when it's possible the current syscall is returning -ERESTART*.
> > +	 * So we don't clear it here, and only callers who know they should do.
> > +	 */
> >  	return 0;
> >  }
> 
> This breaks cancel_freezing(). Somehow we should clear TIF_SIGPENDING for
> kernel threads. Otherwise we may have subtle failures if try_to_freeze_tasks()
> fails.

Well, the only code path in which we'd want to call cancel_freezing() for kernel
threads is when the freezing of kernel threads.  However, this only happens if
one of the kernel threads declares itself as freezable and the fails to call
try_to_freeze(), which is a bug.  Thus I don't think that we need to worry
about that case too much.

Moreover, I'm not sure that it's a good idea at all to send signals to kernel
threads from the freezer, since in fact we only need to wake them up to make
them call try_to_freeze() (after we've set TIF_FREEZE for them).

Greetings,
Rafael


-- 
"Premature optimization is the root of all evil." - Donald Knuth

  parent reply	other threads:[~2007-06-14 12:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-06  5:47 [BUG] ptraced process waiting on syscall may return kernel internal errnos Satoru Takeuchi
2007-06-06 10:59 ` Roland McGrath
2007-06-06 15:35   ` Linus Torvalds
2007-06-06 23:07     ` Paul Mackerras
2007-06-07  3:25     ` Benjamin Herrenschmidt
2007-06-07  3:27     ` Benjamin Herrenschmidt
2007-06-07 11:33     ` Satoru Takeuchi
2007-06-07 15:54       ` Linus Torvalds
2007-06-07 22:24         ` Benjamin Herrenschmidt
2007-06-08  3:18           ` Linus Torvalds
2007-06-08  5:30             ` Benjamin Herrenschmidt
2007-06-11 22:16             ` Benjamin Herrenschmidt
2007-06-08  3:07         ` Satoru Takeuchi
2007-06-13 22:06     ` Roland McGrath
2007-06-07  3:20   ` Benjamin Herrenschmidt
2007-06-13 15:15   ` Oleg Nesterov
2007-06-13 22:36     ` Benjamin Herrenschmidt
2007-06-13 23:01       ` Roland McGrath
2007-06-13 23:18         ` Benjamin Herrenschmidt
2007-06-14  0:02           ` Roland McGrath
2007-06-13 22:53     ` Roland McGrath
2007-06-14 12:26     ` Rafael J. Wysocki [this message]
2007-06-14 12:58       ` Oleg Nesterov
2007-06-14 23:35         ` Rafael J. Wysocki
2007-06-15 11:31           ` Oleg Nesterov
2007-06-15 21:48             ` Rafael J. Wysocki
2007-06-15  0:06         ` Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200706141426.45522.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    --cc=roland@redhat.com \
    --cc=takeuchi_satoru@jp.fujitsu.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).