diff options
author | Andrey Ryabinin <a.ryabinin@samsung.com> | 2015-02-13 17:39:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-14 00:21:41 -0500 |
commit | df4c0e36f1b1782b0611a77c52cc240e5c4752dd (patch) | |
tree | 1cdb9be1182864d4604200bf58f044673fa85843 /fs | |
parent | 0316bec22ec95ea2faca6406437b0b5950553b7c (diff) |
fs: dcache: manually unpoison dname after allocation to shut up kasan's reports
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.
Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Konstantin Serebryany <kcc@google.com>
Cc: Dmitry Chernenkov <dmitryc@google.com>
Signed-off-by: Andrey Konovalov <adech.fo@gmail.com>
Cc: Yuri Gribov <tetra2005@gmail.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dcache.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index d04be762b216..7d34f04ec7aa 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -38,6 +38,8 @@ | |||
38 | #include <linux/prefetch.h> | 38 | #include <linux/prefetch.h> |
39 | #include <linux/ratelimit.h> | 39 | #include <linux/ratelimit.h> |
40 | #include <linux/list_lru.h> | 40 | #include <linux/list_lru.h> |
41 | #include <linux/kasan.h> | ||
42 | |||
41 | #include "internal.h" | 43 | #include "internal.h" |
42 | #include "mount.h" | 44 | #include "mount.h" |
43 | 45 | ||
@@ -1429,6 +1431,9 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) | |||
1429 | } | 1431 | } |
1430 | atomic_set(&p->u.count, 1); | 1432 | atomic_set(&p->u.count, 1); |
1431 | dname = p->name; | 1433 | dname = p->name; |
1434 | if (IS_ENABLED(CONFIG_DCACHE_WORD_ACCESS)) | ||
1435 | kasan_unpoison_shadow(dname, | ||
1436 | round_up(name->len + 1, sizeof(unsigned long))); | ||
1432 | } else { | 1437 | } else { |
1433 | dname = dentry->d_iname; | 1438 | dname = dentry->d_iname; |
1434 | } | 1439 | } |