Cake - FQ_codel the next generation
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@toke.dk>
To: Eric Dumazet <eric.dumazet@gmail.com>, netdev@vger.kernel.org
Cc: cake@lists.bufferbloat.net, Dave Taht <dave.taht@gmail.com>
Subject: Re: [Cake] [PATCH net-next v4] Add Common Applications Kept Enhanced (cake) qdisc
Date: Fri, 27 Apr 2018 15:38:20 +0200	[thread overview]
Message-ID: <87in8c4vn7.fsf@toke.dk> (raw)
In-Reply-To: <efb401ac-bc79-cbc5-cd03-120803b65b4d@gmail.com>

Eric Dumazet <eric.dumazet@gmail.com> writes:

> On 04/27/2018 05:17 AM, Toke Høiland-Jørgensen wrote:
>
> ...
>
>> +
>> +static struct sk_buff *cake_ack_filter(struct cake_sched_data *q,
>> +				       struct cake_flow *flow)
>> +{
>> +	int seglen;
>> +	struct sk_buff *skb = flow->tail, *skb_check, *skb_check_prev;
>> +	struct iphdr *iph, *iph_check;
>> +	struct ipv6hdr *ipv6h, *ipv6h_check;
>> +	struct tcphdr *tcph, *tcph_check;
>> +	bool otherconn_ack_seen = false;
>> +	struct sk_buff *otherconn_checked_to = NULL;
>> +	bool thisconn_redundant_seen = false, thisconn_seen_last = false;
>> +	struct sk_buff *thisconn_checked_to = NULL, *thisconn_ack = NULL;
>> +	bool aggressive = q->ack_filter == CAKE_ACK_AGGRESSIVE;
>> +
>> +	/* no other possible ACKs to filter */
>> +	if (flow->head == skb)
>> +		return NULL;
>> +
>> +	iph = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb);
>> +	ipv6h = skb->encapsulation ? inner_ipv6_hdr(skb) : ipv6_hdr(skb);
>> +
>> +	/* check that the innermost network header is v4/v6, and contains TCP */
>> +	if (pskb_may_pull(skb, ((unsigned char *)iph - skb->head) + sizeof(struct iphdr)) &&
>> +	    iph->version == 4) {
>> +		if (iph->protocol != IPPROTO_TCP)
>> +			return NULL;
>> +		seglen = ntohs(iph->tot_len) - (4 * iph->ihl);
>> +		tcph = (struct tcphdr *)((void *)iph + (4 * iph->ihl));
>> +		if (!pskb_may_pull(skb, ((unsigned char *)tcph - skb->head) + sizeof(struct tcphdr)))
>> +			return NULL;
>> +	} else if (pskb_may_pull(skb, ((unsigned char *)ipv6h - skb->head) + sizeof(struct ipv6hdr) + sizeof(struct tcphdr)) &&
>> +	           ipv6h->version == 6) {
>> +		if (ipv6h->nexthdr != IPPROTO_TCP)
>> +			return NULL;
>> +		seglen = ntohs(ipv6h->payload_len);
>> +		tcph = (struct tcphdr *)((void *)ipv6h +
>> +					 sizeof(struct ipv6hdr));
>> +	} else {
>> +		return NULL;
>> +	}
>> +
>
>
> This is still broken.
>
> After pskb_may_pull(), skb->head might have been reallocated.
>
> You need to recompute iph , ipv6h, tcph, otherwise you are reading
> freed memory and crash kernels with sufficient debugging (KASAN and
> other CONFIG_DEBUG_PAGEALLOC / CONFIG_DEBUG_SLAB like options)

Ah, right. Will fix.

Is it safe to dereference the iph pointer before calling
pskb_may_pull()?

-Toke

  reply	other threads:[~2018-04-27 13:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-27 12:17 Toke Høiland-Jørgensen
2018-04-27 12:17 ` [Cake] [PATCH iproute2-next v5] Add support for cake qdisc Toke Høiland-Jørgensen
2018-04-27 16:17   ` Stephen Hemminger
2018-04-27 13:17 ` [Cake] [PATCH net-next v4] Add Common Applications Kept Enhanced (cake) qdisc Eric Dumazet
2018-04-27 13:38   ` Toke Høiland-Jørgensen [this message]
2018-04-27 13:44     ` Eric Dumazet
2018-04-27 13:45       ` Toke Høiland-Jørgensen

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

  List information: https://lists.bufferbloat.net/postorius/lists/cake.lists.bufferbloat.net/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87in8c4vn7.fsf@toke.dk \
    --to=toke@toke.dk \
    --cc=cake@lists.bufferbloat.net \
    --cc=dave.taht@gmail.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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