Merge tag 'hardening-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
[platform/kernel/linux-starfive.git] / fs / coredump.c
index a4c30bb..de78bde 100644 (file)
@@ -68,7 +68,10 @@ struct core_name {
 
 static int expand_corename(struct core_name *cn, int size)
 {
-       char *corename = krealloc(cn->corename, size, GFP_KERNEL);
+       char *corename;
+
+       size = kmalloc_size_roundup(size);
+       corename = krealloc(cn->corename, size, GFP_KERNEL);
 
        if (!corename)
                return -ENOMEM;
@@ -76,7 +79,7 @@ static int expand_corename(struct core_name *cn, int size)
        if (size > core_name_size) /* racy but harmless */
                core_name_size = size;
 
-       cn->size = ksize(corename);
+       cn->size = size;
        cn->corename = corename;
        return 0;
 }