]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
powerpc: Zero fill the return values of rtas argument buffer
authorNathan Fontenot <nfont@austin.ibm.com>
Wed, 30 Jul 2008 16:23:27 +0000 (02:23 +1000)
committerPaul Mackerras <paulus@samba.org>
Mon, 11 Aug 2008 00:09:56 +0000 (10:09 +1000)
The kernel copy of the rtas args struct contains the return
value(s) for the specified rtas call.  These are copied back
to user space with the assumption that every value has been
set by the rtas call, which turns out to be not always true.
Thus userspace can see random values and think the call failed
when in fact it succeeded, but for some reason didn't set one
of the return values.

This fixes the problem by zeroing out the return value fields
of the rtas args struct before processing the rtas call.

Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kernel/rtas.c

index c680f1bbd3877931d88b776940a08156cc6523ce..1f8505c235482c5fea77a9f3fd1ec175a526a202 100644 (file)
@@ -792,6 +792,9 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
        if (args.token == RTAS_UNKNOWN_SERVICE)
                return -EINVAL;
 
+       args.rets = &args.args[nargs];
+       memset(args.rets, 0, args.nret * sizeof(rtas_arg_t));
+
        /* Need to handle ibm,suspend_me call specially */
        if (args.token == ibm_suspend_me_token) {
                rc = rtas_ibm_suspend_me(&args);
@@ -808,8 +811,6 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
        enter_rtas(__pa(&rtas.args));
        args = rtas.args;
 
-       args.rets = &args.args[nargs];
-
        /* A -1 return code indicates that the last command couldn't
           be completed due to a hardware error. */
        if (args.rets[0] == -1)