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

Commit 77d80f4d authored by Praveen Kurapati's avatar Praveen Kurapati
Browse files

msm: ipa3: Add check to validate rule_cnt



Add proper check to validate table rule count
which may lead to overflow error.

Change-Id: I9bdcafcaae4e4cff1b901929c8dc6ae804f85642
Signed-off-by: default avatarPraveen Kurapati <pkurapat@codeaurora.org>
parent 75fae4d1
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, 2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1065,7 +1065,10 @@ static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
	} else {
		list_add(&entry->link, &tbl->head_flt_rule_list);
	}
	if (tbl->rule_cnt < IPA_RULE_CNT_MAX)
		tbl->rule_cnt++;
	else
		return -EINVAL;
	if (entry->rt_tbl)
		entry->rt_tbl->ref_cnt++;
	id = ipa_id_alloc(entry);
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, 2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -211,6 +211,7 @@
#define IPA2_ACTIVE_CLIENTS_LOG_LINE_LEN 96
#define IPA2_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE 50
#define IPA2_ACTIVE_CLIENTS_LOG_NAME_LEN 40
#define IPA_RULE_CNT_MAX 512

struct ipa2_active_client_htable_entry {
	struct hlist_node list;
+5 −2
Original line number Diff line number Diff line
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1087,7 +1087,10 @@ static int __ipa_add_rt_rule(enum ipa_ip_type ip, const char *name,
		list_add_tail(&entry->link, &tbl->head_rt_rule_list);
	else
		list_add(&entry->link, &tbl->head_rt_rule_list);
	if (tbl->rule_cnt < IPA_RULE_CNT_MAX)
		tbl->rule_cnt++;
	else
		return -EINVAL;
	if (entry->hdr)
		entry->hdr->ref_cnt++;
	else if (entry->proc_ctx)
+5 −2
Original line number Diff line number Diff line
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -851,7 +851,10 @@ static int __ipa_finish_flt_rule_add(struct ipa3_flt_tbl *tbl,
{
	int id;

	if (tbl->rule_cnt < IPA_RULE_CNT_MAX)
		tbl->rule_cnt++;
	else
		return -EINVAL;
	if (entry->rt_tbl)
		entry->rt_tbl->ref_cnt++;
	id = ipa3_id_alloc(entry);
+1 −0
Original line number Diff line number Diff line
@@ -388,6 +388,7 @@
#define IPA_IS_4_0_AUTO_CONFIG() \
	((ipa3_ctx->ipa_hw_type == IPA_HW_v4_0) && \
	(ipa3_ctx->ipa_config_is_auto))
#define IPA_RULE_CNT_MAX 512

struct ipa3_active_client_htable_entry {
	struct hlist_node list;
Loading