From: ebiederm@xmission.com (Eric W. Biederman)
To: David Miller <davem@davemloft.net>
Cc: rshearma@brocade.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next ] mpls: In mpls_egress verify the packet length.
Date: Thu, 12 Mar 2015 17:50:53 -0500 [thread overview]
Message-ID: <87h9tpzv76.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <20150312.182558.447886504045770209.davem@davemloft.net> (David Miller's message of "Thu, 12 Mar 2015 18:25:58 -0400 (EDT)")
David Miller <davem@davemloft.net> writes:
> From: ebiederm@xmission.com (Eric W. Biederman)
> Date: Thu, 12 Mar 2015 15:54:52 -0500
>
>> Robert Shearman noticed that mpls_egress is failing to verify that
>> the bytes to be examined are in fact present in the packet before
>> mpls_egress reads those bytes.
>>
>> Reported-by: Robert Shearman <rshearma@brocade.com>
>> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
>
> Let's see if we can consolidate these pskb_may_pull() calls into one,
> in the fast path they are relatively cheap but not zero cost.
> The caller (mpls_forward()) is doing one as well.
>
> All you care about is the version field and the hop_limit/ttl.
>
> For ipv4, version is in byte 0, and ttl is in byte 9.
By my count the ttl is in byte 8, and more importantly the
header checksum is in byte 10.
> For ipv6, version is also in byte zero and hop_limit is in byte 7.
>
> Therefore if you do pskb_may_pull(skb, 10) it will cover all cases
> whilst not exceeding the size of either protocol's total header.
Using the value of 12 that seems very reasonable.
> Above the pskb_may_pull() call can add a big comment explaining what
> you are doing and why this is sufficient.
Will do.
Eric
next prev parent reply other threads:[~2015-03-12 22:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-11 12:58 [PATCH net-next] mpls: Infer payload of packet from via address family Robert Shearman
2015-03-11 17:29 ` Eric W. Biederman
2015-03-11 22:02 ` Robert Shearman
2015-03-12 18:19 ` Eric W. Biederman
2015-03-12 20:54 ` [PATCH net-next ] mpls: In mpls_egress verify the packet length Eric W. Biederman
2015-03-12 22:25 ` David Miller
2015-03-12 22:50 ` Eric W. Biederman [this message]
2015-03-12 23:22 ` Eric W. Biederman
2015-03-13 3:05 ` David Miller
2015-03-13 14:51 ` [PATCH net-next] mpls: Infer payload of packet from via address family Robert Shearman
2015-03-13 17:08 ` Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9tpzv76.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=rshearma@brocade.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).