diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-12-16 16:21:05 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-12-16 16:21:05 -0500 |
commit | 3c55d6bcfe8163ff2b5636b4aabe3caa3f5d95f4 (patch) | |
tree | 3229c2de6e95352751d1c9e05dcd2925a3212beb /net/sched/act_pedit.c | |
parent | 4da00fd1b948b408f76488c4e506af748be5fce8 (diff) | |
parent | 29ac8e856cb3694e004037de595dec4ec53d42f2 (diff) | |
download | op-kernel-dev-3c55d6bcfe8163ff2b5636b4aabe3caa3f5d95f4.zip op-kernel-dev-3c55d6bcfe8163ff2b5636b4aabe3caa3f5d95f4.tar.gz |
Merge remote-tracking branch 'djwong/ocfs2-vfs-reflink-6' into for-linus
Diffstat (limited to 'net/sched/act_pedit.c')
-rw-r--r-- | net/sched/act_pedit.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index b54d56d..cf9b2fe 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -108,6 +108,17 @@ static void tcf_pedit_cleanup(struct tc_action *a, int bind) kfree(keys); } +static bool offset_valid(struct sk_buff *skb, int offset) +{ + if (offset > 0 && offset > skb->len) + return false; + + if (offset < 0 && -offset > skb_headroom(skb)) + return false; + + return true; +} + static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, struct tcf_result *res) { @@ -134,6 +145,11 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, if (tkey->offmask) { char *d, _d; + if (!offset_valid(skb, off + tkey->at)) { + pr_info("tc filter pedit 'at' offset %d out of bounds\n", + off + tkey->at); + goto bad; + } d = skb_header_pointer(skb, off + tkey->at, 1, &_d); if (!d) @@ -146,10 +162,10 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, " offset must be on 32 bit boundaries\n"); goto bad; } - if (offset > 0 && offset > skb->len) { - pr_info("tc filter pedit" - " offset %d can't exceed pkt length %d\n", - offset, skb->len); + + if (!offset_valid(skb, off + offset)) { + pr_info("tc filter pedit offset %d out of bounds\n", + offset); goto bad; } |