]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
powerpc/rtas: Fix array overrun in ppc_rtas() syscall
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Fri, 18 Mar 2016 06:36:33 +0000 (17:36 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 5 Jul 2016 13:49:52 +0000 (23:49 +1000)
If ppc_rtas() is called with args.nargs == 16 and args.nret == 0,
args.rets is set to point to &args.args[16], which is beyond the end of
the args.args array. This results in a minor read overrun of the array
when we check the first return code (which, per PAPR, is a required
output of all RTAS calls) to see if there's been a hardware error.

Change the nargs/nret check to ensure nargs is <= 15, allowing room for
the status code. Users shouldn't be calling with nret == 0, but there's
no real harm if they do, so we don't stop them.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/rtas.c

index 28736ff27fea1090dc888e4ef73a6d235ce2989b..8da209fdf480e713256738de11c1c4d98c41e91b 100644 (file)
@@ -1070,7 +1070,7 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
        nret  = be32_to_cpu(args.nret);
        token = be32_to_cpu(args.token);
 
-       if (nargs > ARRAY_SIZE(args.args)
+       if (nargs >= ARRAY_SIZE(args.args)
            || nret > ARRAY_SIZE(args.args)
            || nargs + nret > ARRAY_SIZE(args.args))
                return -EINVAL;