From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by kanga.kvack.org (Postfix) with ESMTP id 2F7376B004D for ; Wed, 10 Sep 2014 10:38:44 -0400 (EDT) Received: by mail-pa0-f53.google.com with SMTP id rd3so7010322pab.26 for ; Wed, 10 Sep 2014 07:38:43 -0700 (PDT) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com. [210.118.77.11]) by mx.google.com with ESMTPS id qw2si28089847pbb.80.2014.09.10.07.38.42 for (version=TLSv1 cipher=RC4-MD5 bits=128/128); Wed, 10 Sep 2014 07:38:43 -0700 (PDT) Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NBO00DCJWT9BY60@mailout1.w1.samsung.com> for linux-mm@kvack.org; Wed, 10 Sep 2014 15:41:33 +0100 (BST) From: Andrey Ryabinin Subject: [RFC/PATCH v2 08/10] fs: dcache: manually unpoison dname after allocation to shut up kasan's reports Date: Wed, 10 Sep 2014 18:31:25 +0400 Message-id: <1410359487-31938-9-git-send-email-a.ryabinin@samsung.com> In-reply-to: <1410359487-31938-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1410359487-31938-1-git-send-email-a.ryabinin@samsung.com> Sender: owner-linux-mm@kvack.org List-ID: To: linux-kernel@vger.kernel.org Cc: Andrey Ryabinin , Dmitry Vyukov , Konstantin Serebryany , Dmitry Chernenkov , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Christoph Lameter , Joonsoo Kim , Andrew Morton , Dave Hansen , Andi Kleen , Vegard Nossum , "H. Peter Anvin" , x86@kernel.org, linux-mm@kvack.org, Alexander Viro We need to manually unpoison rounded up allocation size for dname to avoid kasan's reports in dentry_string_cmp(). When CONFIG_DCACHE_WORD_ACCESS=y dentry_string_cmp may access few bytes beyound requested in kmalloc() size. dentry_string_cmp() relates on that fact that dentry allocated using kmalloc and kmalloc internally round up allocation size. So this is not a bug, but this makes kasan to complain about such accesses. To avoid such reports we mark rounded up allocation size in shadow as accessible. Reported-by: Dmitry Vyukov Signed-off-by: Andrey Ryabinin --- fs/dcache.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index 35e61f6..b83dbc1 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "internal.h" #include "mount.h" @@ -1396,6 +1397,10 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) kmem_cache_free(dentry_cache, dentry); return NULL; } +#ifdef CONFIG_DCACHE_WORD_ACCESS + kasan_unpoison_shadow(dname, + round_up(name->len + 1, sizeof(unsigned long))); +#endif } else { dname = dentry->d_iname; } -- 1.8.5.5 -- 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