Commit df4c0e36 authored by Andrey Ryabinin's avatar Andrey Ryabinin Committed by Linus Torvalds
Browse files

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()

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: default avatarAndrey Ryabinin <>
Reported-by: default avatarDmitry Vyukov <>
Cc: Konstantin Serebryany <>
Cc: Dmitry Chernenkov <>
Signed-off-by: default avatarAndrey Konovalov <>
Cc: Yuri Gribov <>
Cc: Konstantin Khlebnikov <>
Cc: Sasha Levin <>
Cc: Christoph Lameter <>
Cc: Joonsoo Kim <>
Cc: Dave Hansen <>
Cc: Andi Kleen <>
Cc: Ingo Molnar <>
Cc: Thomas Gleixner <>
Cc: "H. Peter Anvin" <>
Cc: Christoph Lameter <>
Cc: Pekka Enberg <>
Cc: David Rientjes <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 0316bec2
......@@ -38,6 +38,8 @@
#include <linux/prefetch.h>
#include <linux/ratelimit.h>
#include <linux/list_lru.h>
#include <linux/kasan.h>
#include "internal.h"
#include "mount.h"
......@@ -1429,6 +1431,9 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
atomic_set(&p->u.count, 1);
dname = p->name;
round_up(name->len + 1, sizeof(unsigned long)));
} else {
dname = dentry->d_iname;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment