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: <CA+55aFxSyCmxv=fZTMgnq3OSTQjj5R4izKFotBExpAu1M5BsQg@mail.gmail.com>
Date:	Sat, 14 Apr 2012 01:00:46 -0700
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Oleg Nesterov <oleg@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	David Howells <dhowells@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Alexander Gordeev <agordeev@...hat.com>,
	Chris Zankel <chris@...kel.net>,
	David Smith <dsmith@...hat.com>,
	"Frank Ch. Eigler" <fche@...hat.com>,
	Geert Uytterhoeven <geert@...ux-m68k.org>,
	Larry Woodman <lwoodman@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Tejun Heo <tj@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 1/3] task_work_add: generic process-context callbacks

On Fri, Apr 13, 2012 at 8:39 PM, Oleg Nesterov <oleg@...hat.com> wrote:
>>
>> Alternatively, you must make the rule be that the data can only be
>> freed by the caller *if* it was returned from "task_work_cancel()".
>
> Exactly.
>
> Once the caller does task_work_add(twork), it no longer "owns" this
> twork.
>
> But, if task_work_cancel() succeeds - you own it again.

*IF* it succeeds.

My argument was that it might race, and not successfully remove the
work entry at all - but because it was allocated on the stack, it gets
freed *regardless* of whether the cancel got it or not.

>> But then you can't allocate it on the stack any more, and have to
>> allocate it separately.
>
> Yes, unless you do task_work_add/cancel(current).

Ok, your argument seems to be that "current" is special, and can not
race, because the work execution is always synchronous with the task
it got scheduled on.

I can buy that. But if so, it needs some big honking comment. Maybe
the whole "add yourself onto your *own* task work" should be an
explicit separate interface.

And that whole "run_task_work()" function should *not* take a "task"
pointer, because it would be horribly horribly wrong to ever run it in
any context than "current".

                 Linus
--
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