From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752998Ab0HTOil (ORCPT ); Fri, 20 Aug 2010 10:38:41 -0400 Received: from casper.infradead.org ([85.118.1.10]:47834 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752665Ab0HTOig convert rfc822-to-8bit (ORCPT ); Fri, 20 Aug 2010 10:38:36 -0400 Subject: Re: [RFC][PATCH 0/6] mm, highmem: kmap_atomic rework From: Peter Zijlstra To: Andrew Morton Cc: Linus Torvalds , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Russell King , David Howells , Ralf Baechle , David Miller , Paul Mackerras , Benjamin Herrenschmidt , Hugh Dickins , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org In-Reply-To: <20100819143129.81274c03.akpm@linux-foundation.org> References: <20100819201317.673172547@chello.nl> <20100819143129.81274c03.akpm@linux-foundation.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Date: Fri, 20 Aug 2010 16:38:12 +0200 Message-ID: <1282315092.2605.1134.camel@laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2010-08-19 at 14:31 -0700, Andrew Morton wrote: > On Thu, 19 Aug 2010 22:13:17 +0200 > Peter Zijlstra wrote: > > > > > This patch-set reworks the kmap_atomic API to be a stack based, instead of > > static slot based. Some might remember this from last year, some not ;-) > > > > The advantage is that you no longer need to worry about KM_foo, the > > disadvantage is that kmap_atomic/kunmap_atomic now needs to be strictly > > nested (CONFIG_HIGHMEM_DEBUG should complain in case its not) -- and of > > course its a big massive patch changing a widely used API. > > Nice. That fixes the "use of irq-only slots from interrupts-on > context" bugs which people keep adding. Ah, I should add a: WARN_ON_ONCE(in_irq() && !irqs_disabled()); like check to ensure people don't use kmap_atomic() in nestable IRQ contexts (nestable IRQ context is bad anyway) the old debug code I deleted did something similar. > We don't have any checks in there for the stack overflowing? +#ifdef CONFIG_DEBUG_HIGHMEM + BUG_ON(idx > KM_TYPE_NR); +#endif Seems to be that. > Did you add every runtime check you could possibly think of? > kmap_atomic_idx_push() and pop() don't have much in there. It'd be > good to lard it up with runtime checks for at least a few weeks. Right, so I currently have: - stack size check in push/pop - proper nesting check in pop (verifies that the vaddr you try to unmap is indeed the top most on the stack) Aside from the proposed no irq-nesting thing to avoid unbounded recursion I can't really come up with more creative abuse. > Well, there's that monster conversion patch. How's about you > temporarily do > > #define kmap_atomic(x, arg...) __kmap_atomic(x) > > so for a while, both kmap_atomic(a, KM_foo) and kmap_atomic(a) are > turned into __kmap_atomic(a). Once all the dust has settled, pull that > out again? Ah, that's a nifty trick, let me try that. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [RFC][PATCH 0/6] mm, highmem: kmap_atomic rework Date: Fri, 20 Aug 2010 16:38:12 +0200 Message-ID: <1282315092.2605.1134.camel@laptop> References: <20100819201317.673172547@chello.nl> <20100819143129.81274c03.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20100819143129.81274c03.akpm@linux-foundation.org> Sender: owner-linux-mm@kvack.org To: Andrew Morton Cc: Linus Torvalds , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Russell King , David Howells , Ralf Baechle , David Miller , Paul Mackerras , Benjamin Herrenschmidt , Hugh Dickins , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org List-Id: linux-arch.vger.kernel.org On Thu, 2010-08-19 at 14:31 -0700, Andrew Morton wrote: > On Thu, 19 Aug 2010 22:13:17 +0200 > Peter Zijlstra wrote: >=20 > >=20 > > This patch-set reworks the kmap_atomic API to be a stack based, instead= of > > static slot based. Some might remember this from last year, some not ;-= ) > >=20 > > The advantage is that you no longer need to worry about KM_foo, the > > disadvantage is that kmap_atomic/kunmap_atomic now needs to be strictly > > nested (CONFIG_HIGHMEM_DEBUG should complain in case its not) -- and of > > course its a big massive patch changing a widely used API. >=20 > Nice. That fixes the "use of irq-only slots from interrupts-on > context" bugs which people keep adding. Ah, I should add a: WARN_ON_ONCE(in_irq() && !irqs_disabled()); like check to ensure people don't use kmap_atomic() in nestable IRQ contexts (nestable IRQ context is bad anyway) the old debug code I deleted did something similar. > We don't have any checks in there for the stack overflowing? +#ifdef CONFIG_DEBUG_HIGHMEM + BUG_ON(idx > KM_TYPE_NR); +#endif Seems to be that. > Did you add every runtime check you could possibly think of?=20 > kmap_atomic_idx_push() and pop() don't have much in there. It'd be > good to lard it up with runtime checks for at least a few weeks. Right, so I currently have: - stack size check in push/pop - proper nesting check in pop (verifies that the vaddr you try to unmap is indeed the top most on the stack) Aside from the proposed no irq-nesting thing to avoid unbounded recursion I can't really come up with more creative abuse. > Well, there's that monster conversion patch. How's about you > temporarily do >=20 > #define kmap_atomic(x, arg...) __kmap_atomic(x) >=20 > so for a while, both kmap_atomic(a, KM_foo) and kmap_atomic(a) are > turned into __kmap_atomic(a). Once all the dust has settled, pull that > out again? Ah, that's a nifty trick, let me try that.=20 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org