From: Dan Carpenter Date: Wed, 5 Dec 2018 00:13:32 +0000 (+1100) Subject: mm: debug: Fix a width vs precision bug in printk X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=dbbd9a491a874fcff0dabbdcd93470da180cbdcc;p=users%2Fwilly%2Flinux.git mm: debug: Fix a width vs precision bug in printk We had intended to only print dentry->d_name.len characters but there is a width vs precision typo so if the name isn't NUL terminated it will read past the end of the buffer. Link: http://lkml.kernel.org/r/20181123072135.gqvblm2vdujbvfjs@kili.mountain Fixes: 408ddbc22be3 ("mm: print more information about mapping in __dump_page") Signed-off-by: Dan Carpenter Reviewed-by: Anshuman Khandual Acked-by: Michal Hocko Reviewed-by: David Hildenbrand Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell --- diff --git a/mm/debug.c b/mm/debug.c index a33177bfc856..235da079e822 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -80,7 +80,7 @@ void __dump_page(struct page *page, const char *reason) if (mapping->host->i_dentry.first) { struct dentry *dentry; dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias); - pr_emerg("name:\"%*s\" ", dentry->d_name.len, dentry->d_name.name); + pr_emerg("name:\"%.*s\" ", dentry->d_name.len, dentry->d_name.name); } } BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS + 1);