msm: mink: Avoid handling output params if TZ op returns an err

Invoke operation is processed at couple of places in trusted env;
in TZ kernel and/or in TZ apps. If TZ kernel returns an error,
SMCInvoke driver does not process output params and returns
appropriate err to userspace. However, if error is returned from
trusted apps, SMCInvoke still processes output params and returns error
to userspace. Now, SMCInvoke driver will not process output params if
trusted app returns an error. Userspace is also expected to follow the
same rule.

Change-Id: Ic58e37ba714d4b384e3fa9206419c69ddd852b4a
Signed-off-by: Dinesh K Garg <dineshg@codeaurora.org>
This commit is contained in:
Dinesh K Garg 2017-05-09 15:16:04 -07:00
parent 3d82d66409
commit d1c8aa7f66

View file

@ -429,10 +429,17 @@ long smcinvoke_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
if (ret)
goto out;
ret = marshal_out(in_msg, inmsg_size, &req, args_buf);
/*
* if invoke op results in an err, no need to marshal_out and
* copy args buf to user space
*/
if (!req.result) {
ret = marshal_out(in_msg, inmsg_size, &req, args_buf);
ret |= copy_to_user((void __user *)(uintptr_t)(req.args),
ret |= copy_to_user(
(void __user *)(uintptr_t)(req.args),
args_buf, nr_args * req.argsize);
}
ret |= copy_to_user((void __user *)arg, &req, sizeof(req));
if (ret)
goto out;