Skip to content

Commit 30c45b5

Browse files
f0rm2l1nPaolo Abeni
authored andcommitted
net/sched: act_pedit: Add size check for TCA_PEDIT_PARMS_EX
The attribute TCA_PEDIT_PARMS_EX is not be included in pedit_policy and one malicious user could fake a TCA_PEDIT_PARMS_EX whose length is smaller than the intended sizeof(struct tc_pedit). Hence, the dereference in tcf_pedit_init() could access dirty heap data. static int tcf_pedit_init(...) { // ... pattr = tb[TCA_PEDIT_PARMS]; // TCA_PEDIT_PARMS is included if (!pattr) pattr = tb[TCA_PEDIT_PARMS_EX]; // but this is not // ... parm = nla_data(pattr); index = parm->index; // parm is able to be smaller than 4 bytes // and this dereference gets dirty skb_buff // data created in netlink_sendmsg } This commit adds TCA_PEDIT_PARMS_EX length in pedit_policy which avoid the above case, just like the TCA_PEDIT_PARMS. Fixes: 71d0ed7 ("net/act_pedit: Support using offset relative to the conventional network headers") Signed-off-by: Lin Ma <[email protected]> Reviewed-by: Pedro Tammela <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 2c5d234 commit 30c45b5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/sched/act_pedit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static struct tc_action_ops act_pedit_ops;
2929

3030
static const struct nla_policy pedit_policy[TCA_PEDIT_MAX + 1] = {
3131
[TCA_PEDIT_PARMS] = { .len = sizeof(struct tc_pedit) },
32+
[TCA_PEDIT_PARMS_EX] = { .len = sizeof(struct tc_pedit) },
3233
[TCA_PEDIT_KEYS_EX] = { .type = NLA_NESTED },
3334
};
3435

0 commit comments

Comments
 (0)