lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070319225305.GA258@tv-sign.ru>
Date:	Tue, 20 Mar 2007 01:53:05 +0300
From:	Oleg Nesterov <oleg@...sign.ru>
To:	Davide Libenzi <davidel@...ilserver.org>
Cc:	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [patch 2/13] signal/timer/event fds v6 - signalfd core ...

On 03/19, Davide Libenzi wrote:
>
> On Mon, 19 Mar 2007, Oleg Nesterov wrote:
> 
> > On 03/19, Davide Libenzi wrote:
> > >
> > > On Mon, 19 Mar 2007, Eric W. Biederman wrote:
> > > 
> > > > > +struct signalfd_ctx {
> > > > > +	struct list_head lnk;
> > > > > +	wait_queue_head_t wqh;
> > > > > +	sigset_t sigmask;
> > > > > +	struct task_struct *tsk;
> > > > > +};
> > > > 
> > > > I think you want to use a struct pid *pid instead of a pointer to the
> > > > task struct here.  It is slightly less efficient (one more
> > > > dereference) but it means that we won't pin the task struct in memory
> > > > indefinitely.  Pinning the task_struct like this makes for a very
> > > > interesting way to get around the limits on the number of processes a
> > > > user can have.
> > > 
> > > Hmm, when the task is detached from the sighand, we get a notify, so I 
> > > could do a put from there. This would avoid the extra de-reference. I need 
> > > to verify locking though ...
> > 
> > In that case (if I understand you correctly) we don't need {get,put}_task_struct()
> > at all.
> > 
> > signalfd_deliver(-1) sets ctx->tsk = NULL, signalfd_get_sighand() reads ->tsk
> > under rcu_read_lock(). The code becomes even simpler, we don't need to check
> > list_empty(&ctx->lnk).
> 
> 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 ...

No.

First, you don't need to use unlock_task_sighand(), you can just use
spin_unlock_irqrestore(sighand) directly. But this is, I agree, not good.

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.

Oleg.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ