Merge "msm: ipa: Protect ipa default routing table"

This commit is contained in:
Linux Build Service Account 2018-10-10 08:55:41 -07:00 committed by Gerrit - the friendly Code Review server
commit ecee0eb12c

View file

@ -1047,13 +1047,12 @@ static int __ipa_add_rt_rule(enum ipa_ip_type ip, const char *name,
goto error; goto error;
} }
/* /*
* do not allow any rules to be added at end of the "default" routing * do not allow any rule to be added at "default" routing
* tables * table
*/ */
if (!strcmp(tbl->name, IPA_DFLT_RT_TBL_NAME) && if (!strcmp(tbl->name, IPA_DFLT_RT_TBL_NAME) &&
(tbl->rule_cnt > 0) && (at_rear != 0)) { (tbl->rule_cnt > 0)) {
IPAERR_RL("cannot add rule at end of tbl rule_cnt=%d at_rear=%d" IPAERR_RL("cannot add rules to default rt table\n");
, tbl->rule_cnt, at_rear);
goto error; goto error;
} }
@ -1275,13 +1274,12 @@ int ipa3_add_rt_rule_after(struct ipa_ioc_add_rt_rule_after *rules)
} }
/* /*
* do not allow any rules to be added at end of the "default" routing * do not allow any rule to be added at "default" routing
* tables * table
*/ */
if (!strcmp(tbl->name, IPA_DFLT_RT_TBL_NAME) && if (!strcmp(tbl->name, IPA_DFLT_RT_TBL_NAME) &&
(&entry->link == tbl->head_rt_rule_list.prev)) { (tbl->rule_cnt > 0)) {
IPAERR_RL("cannot add rule at end of tbl rule_cnt=%d\n", IPAERR_RL("cannot add rules to default rt table\n");
tbl->rule_cnt);
ret = -EINVAL; ret = -EINVAL;
goto bail; goto bail;
} }
@ -1740,6 +1738,10 @@ static int __ipa_mdfy_rt_rule(struct ipa_rt_rule_mdfy *rtrule)
goto error; goto error;
} }
if (!strcmp(entry->tbl->name, IPA_DFLT_RT_TBL_NAME)) {
IPAERR_RL("Default tbl rule cannot be modified\n");
return -EINVAL;
}
/* Adding check to confirm still /* Adding check to confirm still
* header entry present in header table or not * header entry present in header table or not
*/ */