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

Commit 006a5f61 authored by Mohammed Javid's avatar Mohammed Javid
Browse files

msm: ipa: Fix use after free issue



Added code changes to avoid use-after-free
by having local copy and
cache it upon successful return.

Change-Id: Iffac9ba89658b986bd8b630d22af619300e0ff5d
Signed-off-by: default avatarMohammed Javid <mjavid@codeaurora.org>
parent c3a6cc0f
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -538,6 +538,7 @@ static int ipa_send_wan_msg(unsigned long usr_param,
	int retval;
	struct ipa_wan_msg *wan_msg;
	struct ipa_msg_meta msg_meta;
	struct ipa_wan_msg cache_wan_msg;

	wan_msg = kzalloc(sizeof(struct ipa_wan_msg), GFP_KERNEL);
	if (!wan_msg) {
@@ -551,6 +552,8 @@ static int ipa_send_wan_msg(unsigned long usr_param,
		return -EFAULT;
	}

	memcpy(&cache_wan_msg, wan_msg, sizeof(cache_wan_msg));

	memset(&msg_meta, 0, sizeof(struct ipa_msg_meta));
	msg_meta.msg_type = msg_type;
	msg_meta.msg_len = sizeof(struct ipa_wan_msg);
@@ -567,8 +570,8 @@ static int ipa_send_wan_msg(unsigned long usr_param,
		/* cache the cne event */
		memcpy(&ipa_ctx->ipa_cne_evt_req_cache[
			ipa_ctx->num_ipa_cne_evt_req].wan_msg,
			wan_msg,
			sizeof(struct ipa_wan_msg));
			&cache_wan_msg,
			sizeof(cache_wan_msg));

		memcpy(&ipa_ctx->ipa_cne_evt_req_cache[
			ipa_ctx->num_ipa_cne_evt_req].msg_meta,
+5 −2
Original line number Diff line number Diff line
@@ -604,6 +604,7 @@ static int ipa3_send_wan_msg(unsigned long usr_param,
	int retval;
	struct ipa_wan_msg *wan_msg;
	struct ipa_msg_meta msg_meta;
	struct ipa_wan_msg cache_wan_msg;

	wan_msg = kzalloc(sizeof(struct ipa_wan_msg), GFP_KERNEL);
	if (!wan_msg) {
@@ -617,6 +618,8 @@ static int ipa3_send_wan_msg(unsigned long usr_param,
		return -EFAULT;
	}

	memcpy(&cache_wan_msg, wan_msg, sizeof(cache_wan_msg));

	memset(&msg_meta, 0, sizeof(struct ipa_msg_meta));
	msg_meta.msg_type = msg_type;
	msg_meta.msg_len = sizeof(struct ipa_wan_msg);
@@ -633,8 +636,8 @@ static int ipa3_send_wan_msg(unsigned long usr_param,
		/* cache the cne event */
		memcpy(&ipa3_ctx->ipa_cne_evt_req_cache[
			ipa3_ctx->num_ipa_cne_evt_req].wan_msg,
			wan_msg,
			sizeof(struct ipa_wan_msg));
			&cache_wan_msg,
			sizeof(cache_wan_msg));

		memcpy(&ipa3_ctx->ipa_cne_evt_req_cache[
			ipa3_ctx->num_ipa_cne_evt_req].msg_meta,