From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Howells Subject: Re: [PATCH v6 4/6] keys: change keyctl_session_to_parent() to use task_work_add() Date: Fri, 20 Apr 2012 09:45:16 +0100 Message-ID: <10220.1334911516@redhat.com> References: <20120419231543.GD15828@redhat.com> <20120419231431.GA15820@redhat.com> Return-path: In-Reply-To: <20120419231543.GD15828@redhat.com> Sender: linux-kernel-owner@vger.kernel.org To: Oleg Nesterov Cc: dhowells@redhat.com, Andrew Morton , Linus Torvalds , Thomas Gleixner , Alexander Gordeev , Chris Zankel , David Smith , "Frank Ch. Eigler" , Geert Uytterhoeven , Larry Woodman , Peter Zijlstra , Richard Kuo , Tejun Heo , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: linux-arch.vger.kernel.org Oleg Nesterov wrote: > Change keyctl_session_to_parent() to use task_work_add() and > move key_replace_session_keyring() logic into task_work->func(). > > Note that we do task_work_cancel() before task_work_add() to > ensure that only one work can be pending at any time. This is > important, we must not allow user-space to abuse the parent's > ->task_works list. > > The callback, replace_session_keyring(), checks PF_EXITING. > I guess this is not really needed but looks better. > > As a side effect, this fixes the (unlikely) race. The callers > of key_replace_session_keyring() and keyctl_session_to_parent() > lack the necessary barriers, the parent can miss the request. > > Now we can remove task_struct->replacement_session_keyring and > related code. > > Signed-off-by: Oleg Nesterov Acked-by: David Howells From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:21338 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751392Ab2DTIpp (ORCPT ); Fri, 20 Apr 2012 04:45:45 -0400 From: David Howells In-Reply-To: <20120419231543.GD15828@redhat.com> References: <20120419231543.GD15828@redhat.com> <20120419231431.GA15820@redhat.com> Subject: Re: [PATCH v6 4/6] keys: change keyctl_session_to_parent() to use task_work_add() Date: Fri, 20 Apr 2012 09:45:16 +0100 Message-ID: <10220.1334911516@redhat.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Oleg Nesterov Cc: dhowells@redhat.com, Andrew Morton , Linus Torvalds , Thomas Gleixner , Alexander Gordeev , Chris Zankel , David Smith , "Frank Ch. Eigler" , Geert Uytterhoeven , Larry Woodman , Peter Zijlstra , Richard Kuo , Tejun Heo , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <20120420084516.GZz4mGZDEmEK11g-NvaG9XBdTR3FbUZILgeobdoRNA0@z> Oleg Nesterov wrote: > Change keyctl_session_to_parent() to use task_work_add() and > move key_replace_session_keyring() logic into task_work->func(). > > Note that we do task_work_cancel() before task_work_add() to > ensure that only one work can be pending at any time. This is > important, we must not allow user-space to abuse the parent's > ->task_works list. > > The callback, replace_session_keyring(), checks PF_EXITING. > I guess this is not really needed but looks better. > > As a side effect, this fixes the (unlikely) race. The callers > of key_replace_session_keyring() and keyctl_session_to_parent() > lack the necessary barriers, the parent can miss the request. > > Now we can remove task_struct->replacement_session_keyring and > related code. > > Signed-off-by: Oleg Nesterov Acked-by: David Howells