From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932278AbaGIOsq (ORCPT ); Wed, 9 Jul 2014 10:48:46 -0400 Received: from qmta13.emeryville.ca.mail.comcast.net ([76.96.27.243]:60043 "EHLO qmta13.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751268AbaGIOso (ORCPT ); Wed, 9 Jul 2014 10:48:44 -0400 Date: Wed, 9 Jul 2014 09:48:41 -0500 (CDT) From: Christoph Lameter To: Andrey Ryabinin cc: linux-kernel@vger.kernel.org, Dmitry Vyukov , Konstantin Serebryany , Alexey Preobrazhensky , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Michal Marek , Russell King , Thomas Gleixner , Ingo Molnar , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-kbuild@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org Subject: Re: [RFC/PATCH RESEND -next 15/21] mm: slub: add kernel address sanitizer hooks to slub allocator In-Reply-To: <1404905415-9046-16-git-send-email-a.ryabinin@samsung.com> Message-ID: References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1404905415-9046-16-git-send-email-a.ryabinin@samsung.com> Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Jul 2014, Andrey Ryabinin wrote: > With this patch kasan will be able to catch bugs in memory allocated > by slub. > Allocated slab page, this whole page marked as unaccessible > in corresponding shadow memory. > On allocation of slub object requested allocation size marked as > accessible, and the rest of the object (including slub's metadata) > marked as redzone (unaccessible). > > We also mark object as accessible if ksize was called for this object. > There is some places in kernel where ksize function is called to inquire > size of really allocated area. Such callers could validly access whole > allocated memory, so it should be marked as accessible by kasan_krealloc call. Do you really need to go through all of this? Add the hooks to kmem_cache_alloc_trace() instead and use the existing instrumentation that is there for other purposes? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qg0-f42.google.com (mail-qg0-f42.google.com [209.85.192.42]) by kanga.kvack.org (Postfix) with ESMTP id 707E26B0031 for ; Wed, 9 Jul 2014 10:48:46 -0400 (EDT) Received: by mail-qg0-f42.google.com with SMTP id e89so6567874qgf.15 for ; Wed, 09 Jul 2014 07:48:46 -0700 (PDT) Received: from qmta04.emeryville.ca.mail.comcast.net (qmta04.emeryville.ca.mail.comcast.net. [2001:558:fe2d:43:76:96:30:40]) by mx.google.com with ESMTP id t9si26913697qai.120.2014.07.09.07.48.44 for ; Wed, 09 Jul 2014 07:48:45 -0700 (PDT) Date: Wed, 9 Jul 2014 09:48:41 -0500 (CDT) From: Christoph Lameter Subject: Re: [RFC/PATCH RESEND -next 15/21] mm: slub: add kernel address sanitizer hooks to slub allocator In-Reply-To: <1404905415-9046-16-git-send-email-a.ryabinin@samsung.com> Message-ID: References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1404905415-9046-16-git-send-email-a.ryabinin@samsung.com> Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Andrey Ryabinin Cc: linux-kernel@vger.kernel.org, Dmitry Vyukov , Konstantin Serebryany , Alexey Preobrazhensky , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Michal Marek , Russell King , Thomas Gleixner , Ingo Molnar , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-kbuild@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org On Wed, 9 Jul 2014, Andrey Ryabinin wrote: > With this patch kasan will be able to catch bugs in memory allocated > by slub. > Allocated slab page, this whole page marked as unaccessible > in corresponding shadow memory. > On allocation of slub object requested allocation size marked as > accessible, and the rest of the object (including slub's metadata) > marked as redzone (unaccessible). > > We also mark object as accessible if ksize was called for this object. > There is some places in kernel where ksize function is called to inquire > size of really allocated area. Such callers could validly access whole > allocated memory, so it should be marked as accessible by kasan_krealloc call. Do you really need to go through all of this? Add the hooks to kmem_cache_alloc_trace() instead and use the existing instrumentation that is there for other purposes? -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: cl@gentwo.org (Christoph Lameter) Date: Wed, 9 Jul 2014 09:48:41 -0500 (CDT) Subject: [RFC/PATCH RESEND -next 15/21] mm: slub: add kernel address sanitizer hooks to slub allocator In-Reply-To: <1404905415-9046-16-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1404905415-9046-16-git-send-email-a.ryabinin@samsung.com> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wed, 9 Jul 2014, Andrey Ryabinin wrote: > With this patch kasan will be able to catch bugs in memory allocated > by slub. > Allocated slab page, this whole page marked as unaccessible > in corresponding shadow memory. > On allocation of slub object requested allocation size marked as > accessible, and the rest of the object (including slub's metadata) > marked as redzone (unaccessible). > > We also mark object as accessible if ksize was called for this object. > There is some places in kernel where ksize function is called to inquire > size of really allocated area. Such callers could validly access whole > allocated memory, so it should be marked as accessible by kasan_krealloc call. Do you really need to go through all of this? Add the hooks to kmem_cache_alloc_trace() instead and use the existing instrumentation that is there for other purposes?