]> www.infradead.org Git - users/willy/linux.git/commitdiff
mm: debug: Fix a width vs precision bug in printk
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 5 Dec 2018 00:13:32 +0000 (11:13 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 5 Dec 2018 00:13:32 +0000 (11:13 +1100)
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 <dan.carpenter@oracle.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
mm/debug.c

index a33177bfc85655afdc021f4631d5679272c40eb3..235da079e822a2fda10b24f8101ce144a34d4f81 100644 (file)
@@ -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);