From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752713AbbDCWHX (ORCPT ); Fri, 3 Apr 2015 18:07:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49177 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751005AbbDCWHV (ORCPT ); Fri, 3 Apr 2015 18:07:21 -0400 Date: Fri, 3 Apr 2015 15:07:19 -0700 From: Andrew Morton To: Andrey Ryabinin Cc: David Rientjes , Dave Kleikamp , Christoph Hellwig , Sebastian Ott , Mikulas Patocka , Catalin Marinas , LKML , linux-mm@kvack.org, jfs-discussion@lists.sourceforge.net, Dmitry Chernenkov , Dmitry Vyukov , Alexander Potapenko Subject: Re: [PATCH] mm, mempool: kasan: poison mempool elements Message-Id: <20150403150719.b2197f71260fee25434e49fc@linux-foundation.org> In-Reply-To: <1428072467-21668-1-git-send-email-a.ryabinin@samsung.com> References: <1428072467-21668-1-git-send-email-a.ryabinin@samsung.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 03 Apr 2015 17:47:47 +0300 Andrey Ryabinin wrote: > Mempools keep allocated objects in reserved for situations > when ordinary allocation may not be possible to satisfy. > These objects shouldn't be accessed before they leave > the pool. > This patch poison elements when get into the pool > and unpoison when they leave it. This will let KASan > to detect use-after-free of mempool's elements. > > ... > > +static void kasan_poison_element(mempool_t *pool, void *element) > +{ > + if (pool->alloc == mempool_alloc_slab) > + kasan_slab_free(pool->pool_data, element); > + if (pool->alloc == mempool_kmalloc) > + kasan_kfree(element); > + if (pool->alloc == mempool_alloc_pages) > + kasan_free_pages(element, (unsigned long)pool->pool_data); > +} We recently discovered that mempool pages (from alloc_pages, not slab) can be in highmem. But kasan apepars to handle highmem pages (by baling out) so we should be OK with that. Can kasan be taught to use kmap_atomic() or is it more complicated than that? It probably isn't worthwhile - highmem pages don'[t get used by the kernel much and most bugs will be found using 64-bit testing anyway.