From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbcFWTql (ORCPT ); Thu, 23 Jun 2016 15:46:41 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:60994 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbcFWTqh (ORCPT ); Thu, 23 Jun 2016 15:46:37 -0400 Date: Thu, 23 Jun 2016 21:46:17 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Oleg Nesterov , Andy Lutomirski , Andy Lutomirski , the arch/x86 maintainers , Linux Kernel Mailing List , "linux-arch@vger.kernel.org" , Borislav Petkov , Nadav Amit , Kees Cook , Brian Gerst , "kernel-hardening@lists.openwall.com" , Josh Poimboeuf , Jann Horn , Heiko Carstens Subject: Re: [PATCH v3 00/13] Virtually mapped stacks with guard pages (x86, core) Message-ID: <20160623194617.GS30154@twins.programming.kicks-ass.net> References: <20160623143126.GA16664@redhat.com> <20160623191123.GE30935@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 23, 2016 at 12:34:24PM -0700, Linus Torvalds wrote: > On Thu, Jun 23, 2016 at 12:11 PM, Peter Zijlstra wrote: > > > > Didn't we talk about using SLAB_DESTROY_BY_RCU for task_struct before? > > If that is possible, a reuse in per-cpu cache is equally possible. > > > > All we really want to guarantee is that the memory remains a > > task_struct, it need not remain the same task, right? > > No, we can't do SLAB_DESTROY_BY_RCU for the task_struct itself, > because the RCU list traversal does expect that the thread and task > lists are stable even if it walks into a "stale" struct task_struct. Indeed. OK, so the situation we talked about before is different, we wanted to do SLAB_DESTROY_BY_RCU on top of the existing delayed_put_task_struct() to get a double grace period. The problem was for things like rq->curr, which isn't RCU managed as such, we could still do: rcu_read_lock(); task = rq->curr; and rely on task being _a_ task_struct, even though it might not be the self-same task we thought we had. So yes, not an option and I was stitching together two half remembered situations to create utter nonsense. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH v3 00/13] Virtually mapped stacks with guard pages (x86, core) Date: Thu, 23 Jun 2016 21:46:17 +0200 Message-ID: <20160623194617.GS30154@twins.programming.kicks-ass.net> References: <20160623143126.GA16664@redhat.com> <20160623191123.GE30935@twins.programming.kicks-ass.net> Reply-To: kernel-hardening@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Content-Disposition: inline In-Reply-To: To: Linus Torvalds Cc: Oleg Nesterov , Andy Lutomirski , Andy Lutomirski , the arch/x86 maintainers , Linux Kernel Mailing List , "linux-arch@vger.kernel.org" , Borislav Petkov , Nadav Amit , Kees Cook , Brian Gerst , "kernel-hardening@lists.openwall.com" , Josh Poimboeuf , Jann Horn , Heiko Carstens List-Id: linux-arch.vger.kernel.org On Thu, Jun 23, 2016 at 12:34:24PM -0700, Linus Torvalds wrote: > On Thu, Jun 23, 2016 at 12:11 PM, Peter Zijlstra wrote: > > > > Didn't we talk about using SLAB_DESTROY_BY_RCU for task_struct before? > > If that is possible, a reuse in per-cpu cache is equally possible. > > > > All we really want to guarantee is that the memory remains a > > task_struct, it need not remain the same task, right? > > No, we can't do SLAB_DESTROY_BY_RCU for the task_struct itself, > because the RCU list traversal does expect that the thread and task > lists are stable even if it walks into a "stale" struct task_struct. Indeed. OK, so the situation we talked about before is different, we wanted to do SLAB_DESTROY_BY_RCU on top of the existing delayed_put_task_struct() to get a double grace period. The problem was for things like rq->curr, which isn't RCU managed as such, we could still do: rcu_read_lock(); task = rq->curr; and rely on task being _a_ task_struct, even though it might not be the self-same task we thought we had. So yes, not an option and I was stitching together two half remembered situations to create utter nonsense. From mboxrd@z Thu Jan 1 00:00:00 1970 Reply-To: kernel-hardening@lists.openwall.com Date: Thu, 23 Jun 2016 21:46:17 +0200 From: Peter Zijlstra Message-ID: <20160623194617.GS30154@twins.programming.kicks-ass.net> References: <20160623143126.GA16664@redhat.com> <20160623191123.GE30935@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [kernel-hardening] Re: [PATCH v3 00/13] Virtually mapped stacks with guard pages (x86, core) To: Linus Torvalds Cc: Oleg Nesterov , Andy Lutomirski , Andy Lutomirski , the arch/x86 maintainers , Linux Kernel Mailing List , "linux-arch@vger.kernel.org" , Borislav Petkov , Nadav Amit , Kees Cook , Brian Gerst , "kernel-hardening@lists.openwall.com" , Josh Poimboeuf , Jann Horn , Heiko Carstens List-ID: On Thu, Jun 23, 2016 at 12:34:24PM -0700, Linus Torvalds wrote: > On Thu, Jun 23, 2016 at 12:11 PM, Peter Zijlstra wrote: > > > > Didn't we talk about using SLAB_DESTROY_BY_RCU for task_struct before? > > If that is possible, a reuse in per-cpu cache is equally possible. > > > > All we really want to guarantee is that the memory remains a > > task_struct, it need not remain the same task, right? > > No, we can't do SLAB_DESTROY_BY_RCU for the task_struct itself, > because the RCU list traversal does expect that the thread and task > lists are stable even if it walks into a "stale" struct task_struct. Indeed. OK, so the situation we talked about before is different, we wanted to do SLAB_DESTROY_BY_RCU on top of the existing delayed_put_task_struct() to get a double grace period. The problem was for things like rq->curr, which isn't RCU managed as such, we could still do: rcu_read_lock(); task = rq->curr; and rely on task being _a_ task_struct, even though it might not be the self-same task we thought we had. So yes, not an option and I was stitching together two half remembered situations to create utter nonsense.