summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammed Javid <mjavid@codeaurora.org>2018-08-06 12:58:30 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2018-08-28 03:48:36 -0700
commit7471a8d40f8c41dfc114ac6d09c4118e2485f8a3 (patch)
tree9a735e91418295a71b0920f6ddc7cb3796171ffc
parente440301cac877425eb10116e1c95902353655955 (diff)
msm: ipa: Validate routing rule id
IPA driver expose routing rule id IOCTL's to user space. There is a chance of getting invalid routing rule-id. Validate it before committing it to IPA hardware. Change-Id: If80b94d3a055f9212d25aff9a57d1b45001ba586 Signed-off-by: Mohammed Javid <mjavid@codeaurora.org>
-rw-r--r--drivers/platform/msm/ipa/ipa_v3/ipa_rt.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
index 0e75d10bae54..a260dbe010f3 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
@@ -908,6 +908,20 @@ static int __ipa_del_rt_tbl(struct ipa3_rt_tbl *entry)
return 0;
}
+static int __ipa_rt_validate_rule_id(u16 rule_id)
+{
+ if (!rule_id)
+ return 0;
+
+ if ((rule_id < ipahal_get_rule_id_hi_bit()) ||
+ (rule_id >= ((ipahal_get_rule_id_hi_bit()<<1)-1))) {
+ IPAERR_RL("Invalid rule_id provided 0x%x\n",
+ rule_id);
+ return -EPERM;
+ }
+
+ return 0;
+}
static int __ipa_rt_validate_hndls(const struct ipa_rt_rule *rule,
struct ipa3_hdr_entry **hdr,
struct ipa3_hdr_proc_ctx_entry **proc_ctx)
@@ -1023,6 +1037,8 @@ static int __ipa_add_rt_rule(enum ipa_ip_type ip, const char *name,
if (__ipa_rt_validate_hndls(rule, &hdr, &proc_ctx))
goto error;
+ if (__ipa_rt_validate_rule_id(rule_id))
+ goto error;
tbl = __ipa_add_rt_tbl(ip, name);
if (tbl == NULL || (tbl->cookie != IPA_RT_TBL_COOKIE)) {