From: Davide Libenzi <davidel@xmailserver.org>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [patch 2/13] signal/timer/event fds v6 - signalfd core ...
Date: Mon, 19 Mar 2007 16:34:18 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0703191633030.3733@alien.or.mcafeemobile.com> (raw)
In-Reply-To: <20070319232842.GB258@tv-sign.ru>
On Tue, 20 Mar 2007, Oleg Nesterov wrote:
> On 03/20, Oleg Nesterov wrote:
> >
> > On 03/19, Davide Libenzi wrote:
> > >
> > > I'd need a get_task_struct in any case in order to safely call
> > > unlock_task_sighand(). At that point I'd prefer to just pass through the
> > > struct pid*. I'll be posting the new version for review as soon as I
> > > complete a few tests ...
> >
> > If signalfd_get_sighand()->lock_task_sighand() succeeds, it is safe to
> > dereference ctx->tsk. The task can't be freed and ctx->tsk can't be cleared
> > while we are holding siglock.
> >
> > However, I was wrong, we still need a re-check after lock_task_sighand().
> > We should check ctx->tsk != NULL.
>
> IOW, we can (afaics) do
>
> static struct sighand_struct *signalfd_get_sighand(struct signalfd_ctx *ctx,
> unsigned long *flags)
> {
> struct sighand_struct *sighand = NULL;
> struct tsak_struct *tsk;
>
> rcu_read_lock();
> tsk = rcu_dereference(ctx->tsk); // not needed, just a documentation
> if (tsk != NULL)
> sighand = lock_task_sighand(tsk, flags);
> rcu_read_unlock();
>
> if (sighand && !ctx->tsk)) {
> unlock_task_sighand(tsk, flags);
> sighand = NULL;
> }
>
> return sighand;
> }
>
> If signalfd_get_sighand() succeeds, ctx->tsk is pinned.
I did a similar thing, but I renamed the locking functions and its
parameters. After looking at what the pid thing was doing, I realized that
it was not really needed.
- Davide
prev parent reply other threads:[~2007-03-19 23:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-16 0:22 Davide Libenzi
2007-03-17 21:35 ` Arnd Bergmann
2007-03-17 21:50 ` Arnd Bergmann
2007-03-18 4:56 ` Stephen Rothwell
2007-03-18 20:31 ` Davide Libenzi
2007-03-18 23:45 ` Arnd Bergmann
2007-03-19 0:22 ` Davide Libenzi
2007-03-19 17:20 ` Eric W. Biederman
2007-03-19 18:53 ` Davide Libenzi
2007-03-19 19:08 ` Eric W. Biederman
2007-03-19 19:11 ` Davide Libenzi
2007-03-19 20:36 ` Oleg Nesterov
2007-03-19 22:33 ` Davide Libenzi
2007-03-19 22:53 ` Oleg Nesterov
2007-03-19 23:28 ` Oleg Nesterov
2007-03-19 23:34 ` Davide Libenzi [this message]
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=Pine.LNX.4.64.0703191633030.3733@alien.or.mcafeemobile.com \
--to=davidel@xmailserver.org \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--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
all inboxes | Powered by JetHome®