]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
watchdog: diag288_wdt: do not use stack buffers for hardware data
authorAlexander Egorenkov <egorenar@linux.ibm.com>
Fri, 27 Jan 2023 13:52:41 +0000 (14:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Feb 2023 11:47:14 +0000 (12:47 +0100)
commit fe8973a3ad0905cb9ba2d42db42ed51de14737df upstream.

With CONFIG_VMAP_STACK=y the stack is allocated from the vmalloc space.
Data passed to a hardware or a hypervisor interface that
requires V=R can no longer be allocated on the stack.

Use kmalloc() to get memory for a diag288 command.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/watchdog/diag288_wdt.c

index 806a04a676b7ee6c369da99d6d09f0ecd50d1fd1..eda505a6a1438f42aaf9bf777bd21fedcca89eee 100644 (file)
@@ -274,12 +274,21 @@ static int __init diag288_init(void)
        char ebc_begin[] = {
                194, 197, 199, 201, 213
        };
+       char *ebc_cmd;
 
        watchdog_set_nowayout(&wdt_dev, nowayout_info);
 
        if (MACHINE_IS_VM) {
-               if (__diag288_vm(WDT_FUNC_INIT, 15,
-                                ebc_begin, sizeof(ebc_begin)) != 0) {
+               ebc_cmd = kmalloc(sizeof(ebc_begin), GFP_KERNEL);
+               if (!ebc_cmd) {
+                       pr_err("The watchdog cannot be initialized\n");
+                       return -ENOMEM;
+               }
+               memcpy(ebc_cmd, ebc_begin, sizeof(ebc_begin));
+               ret = __diag288_vm(WDT_FUNC_INIT, 15,
+                                  ebc_cmd, sizeof(ebc_begin));
+               kfree(ebc_cmd);
+               if (ret != 0) {
                        pr_err("The watchdog cannot be initialized\n");
                        return -EINVAL;
                }