Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3551948 authored by Jeya R's avatar Jeya R
Browse files

msm: adsprpc: Fix double fetch from fastrpc HLOS driver



Fix possible Buffer overflow due to double fetch from
fastrpc HLOS driver.

Change-Id: I03cf94e7f6fef9c8765404a6da3da47fe3bedf8b
Acked-by: default avatarDeepika Singh <dsi@qti.qualcomm.com>
Signed-off-by: default avatarJeya R <jeyr@codeaurora.org>
parent 98ed1806
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
 */
#include <linux/compat.h>
#include <linux/fs.h>
@@ -243,19 +243,15 @@ struct compat_fastrpc_ioctl_capability {
static int compat_get_fastrpc_ioctl_invoke(
			struct compat_fastrpc_ioctl_invoke_async __user *inv32,
			struct fastrpc_ioctl_invoke_async __user *inv,
			unsigned int cmd)
			unsigned int cmd, unsigned int sc)
{
	compat_uint_t u = 0, sc = 0;
	compat_uint_t u = 0;
	compat_size_t s;
	compat_uptr_t p, k;
	union compat_remote_arg *pra32;
	union remote_arg *pra;
	int err = 0, len = 0, j = 0;

	err = get_user(sc, &inv32->inv.sc);
	if (err)
		return err;

	len = REMOTE_SCALARS_LENGTH(sc);

	pra = (union remote_arg *)(inv + 1);
@@ -328,7 +324,7 @@ static int compat_fastrpc_ioctl_invoke(struct file *filp,
	if (err)
		return -EFAULT;
	VERIFY(err, 0 == compat_get_fastrpc_ioctl_invoke(inv32,
						inv, cmd));
						inv, cmd, sc));
	if (err)
		return err;
	return filp->f_op->unlocked_ioctl(filp,
@@ -382,7 +378,7 @@ static int compat_get_fastrpc_ioctl_invoke2(
		if (size < sizeof(struct compat_fastrpc_ioctl_invoke_async)) {
			lasync32_old = compat_ptr(pparam);
			VERIFY(err, 0 == compat_get_fastrpc_ioctl_invoke(lasync32,
						asyncinv_user, COMPAT_FASTRPC_IOCTL_INVOKE_CRC));
					asyncinv_user, COMPAT_FASTRPC_IOCTL_INVOKE_CRC, sc));
			if (err)
				goto bail;
			err |= put_user(NULL, &asyncinv_user->job);
@@ -394,7 +390,7 @@ static int compat_get_fastrpc_ioctl_invoke2(
				(compat_uptr_t __user *)&asyncinv_user->perf_dsp);
		} else {
			VERIFY(err, 0 == compat_get_fastrpc_ioctl_invoke(lasync32,
							asyncinv_user, req));
							asyncinv_user, req, sc));
		}
		if (err)
			goto bail;