Skip to content

Commit 6abbd18

Browse files
Praveen KurapatiExactExampl
authored andcommitted
msm: ipa2: Add check to validate rule_cnt
Add proper check to validate table rule count which may lead to overflow error. Change-Id: Idfa86878db49ad4803f8902c995eb4186a2d3523 Signed-off-by: Praveen Kurapati <pkurapat@codeaurora.org>
1 parent c1fe23f commit 6abbd18

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

drivers/platform/msm/ipa/ipa_v2/ipa_flt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,10 @@ static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
10551055
} else {
10561056
list_add(&entry->link, &tbl->head_flt_rule_list);
10571057
}
1058-
tbl->rule_cnt++;
1058+
if (tbl->rule_cnt < IPA_RULE_CNT_MAX)
1059+
tbl->rule_cnt++;
1060+
else
1061+
return -EINVAL;
10591062
if (entry->rt_tbl)
10601063
entry->rt_tbl->ref_cnt++;
10611064
id = ipa_id_alloc(entry);

drivers/platform/msm/ipa/ipa_v2/ipa_i.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
#define IPA2_ACTIVE_CLIENTS_LOG_LINE_LEN 96
205205
#define IPA2_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE 50
206206
#define IPA2_ACTIVE_CLIENTS_LOG_NAME_LEN 40
207+
#define IPA_RULE_CNT_MAX 512
207208

208209
struct ipa2_active_client_htable_entry {
209210
struct hlist_node list;

drivers/platform/msm/ipa/ipa_v2/ipa_rt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,10 @@ static int __ipa_add_rt_rule(enum ipa_ip_type ip, const char *name,
10771077
list_add_tail(&entry->link, &tbl->head_rt_rule_list);
10781078
else
10791079
list_add(&entry->link, &tbl->head_rt_rule_list);
1080-
tbl->rule_cnt++;
1080+
if (tbl->rule_cnt < IPA_RULE_CNT_MAX)
1081+
tbl->rule_cnt++;
1082+
else
1083+
return -EINVAL;
10811084
if (entry->hdr)
10821085
entry->hdr->ref_cnt++;
10831086
else if (entry->proc_ctx)

0 commit comments

Comments
 (0)