From patchwork Thu Apr 4 13:01:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 1077271 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44Zjkr4WNcz9sRW for ; Fri, 5 Apr 2019 00:01:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729570AbfDDNBj (ORCPT ); Thu, 4 Apr 2019 09:01:39 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:45712 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728743AbfDDNBh (ORCPT ); Thu, 4 Apr 2019 09:01:37 -0400 Received: by mail-ed1-f65.google.com with SMTP id m16so2085556edd.12 for ; Thu, 04 Apr 2019 06:01:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=S6sOuQgx74RtDEC2uYh2queyn1FDcATjS4e/Ke9X2+Q=; b=EmTubchfTQ6LhCM5QmxvyGHKAzCWWWgfcB92qflqSMeoVwrjavO4LJP26djE+okZu3 VPSCq4asR0bU06haNcGMnHqC+G9vB/JzqFJ48Pv4Gt4Qw33D6SAFSDDVl0l9b1QOimNS GnPwlljMYWUw5vTCZuB0IZPDemJGIG+kMBsZew1QB7iuUEQFmWfVMPgYgNjDdcx0gosk k9xOFwRAcQOmKaKIJlP/rL6/RvHyp65NXTZc+3irIjJpr9zjr4lZMSgiovkWpYF1IAcD JOOj3sRvCEMP4OFKQGcwGQtGUHG//giIZ0xMufRvNmGAwqrnt6/jMKrYx5eE+YkS39BO UAnA== X-Gm-Message-State: APjAAAU/4sEleJGj6upJSzOgxspPXn4icQvokjmeX/VdMAMRnUVhAFtw 77qkZWi05qlAAsy9Jh2mj7pbzrI2lNvUIQ== X-Google-Smtp-Source: APXvYqzQ/X0Lt2tPH8dNPYuyTP9PkSD26TObJOtKezWEr4+edR8DbQ2tuyY3Y6tN6Cdb/c6m98+frw== X-Received: by 2002:a17:906:3ed1:: with SMTP id d17mr3539823ejj.221.1554382895981; Thu, 04 Apr 2019 06:01:35 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk (alrua-x1.vpn.toke.dk. [2a00:7660:6da:10::2]) by smtp.gmail.com with ESMTPSA id k51sm5708311edd.32.2019.04.04.06.01.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2019 06:01:34 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id B4FCE1804A6; Thu, 4 Apr 2019 15:01:33 +0200 (CEST) Subject: [PATCH net 1/2] sch_cake: Use tc_skb_protocol() helper for getting packet protocol From: Toke =?utf-8?q?H=C3=B8iland-J=C3=B8rgensen?= To: David Miller Cc: netdev@vger.kernel.org, cake@lists.bufferbloat.net Date: Thu, 04 Apr 2019 15:01:33 +0200 Message-ID: <155438289368.18760.9777700364575323470.stgit@alrua-x1> In-Reply-To: <155438289359.18760.18027832614176337074.stgit@alrua-x1> References: <155438289359.18760.18027832614176337074.stgit@alrua-x1> User-Agent: StGit/unknown-version MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We shouldn't be using skb->protocol directly as that will miss cases with hardware-accelerated VLAN tags. Use the helper instead to get the right protocol number. Reported-by: Kevin Darbyshire-Bryant Signed-off-by: Toke Høiland-Jørgensen --- net/sched/sch_cake.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index acc9b9da985f..a3b55e18df04 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c @@ -1519,7 +1519,7 @@ static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash) { u8 dscp; - switch (skb->protocol) { + switch (tc_skb_protocol(skb)) { case htons(ETH_P_IP): dscp = ipv4_get_dsfield(ip_hdr(skb)) >> 2; if (wash && dscp) From patchwork Thu Apr 4 13:01:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 1077269 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44Zjkp3LFmz9sRW for ; Fri, 5 Apr 2019 00:01:38 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729214AbfDDNBg (ORCPT ); Thu, 4 Apr 2019 09:01:36 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:45711 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbfDDNBg (ORCPT ); Thu, 4 Apr 2019 09:01:36 -0400 Received: by mail-ed1-f66.google.com with SMTP id m16so2085488edd.12 for ; Thu, 04 Apr 2019 06:01:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Z36BMcmPeL6MTAr6fmch4/sChR1td0bJt2tl7Np10/w=; b=RWaWHLUoRkb9AJcXqzJxQ/iaygBzeZcWnyyWmJaqin+4lMeagzRAPY4MbT/i1U0Ina JlInkHmVuUu8HADRZDZLFomPUkWc7prud4Dla62SGrFs17VLLlHn4jkfRQxCWD+rzqFH uXy3bvLT2fMcexVAk5UUVzrUKHi+VbwNfPa0MI0wEnM+K+5oSkH0oQ/ePmPnXGEFoQ4i pfHdWYei6wsBzjBuVlgjGk1DYyMBwalHqqdQlnHlumByFrL12/MDhMA1PUgyWuEln6Og fsxaZMeInXX1Y7w/c7HWDa8ywxgN5j11I2NIO6Iu4IlWxd2VncIB3dKAUAxnk2jBSdq+ /ZOQ== X-Gm-Message-State: APjAAAUatUVyPvGCMuhIIIHskTeEe6GOfRD9PPnqyJteC5I+kYhjiJ3+ dIAnWujzCG77k7ctCEa1EwG6/Q== X-Google-Smtp-Source: APXvYqzFBnHKj/uUgXXBWaCkgh0HsA4Oit4Sp0fgL+piVkuSkh2jtjCVV+rdJQnGie2w/dy+IXuPIg== X-Received: by 2002:a50:93a6:: with SMTP id o35mr3785730eda.245.1554382894777; Thu, 04 Apr 2019 06:01:34 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk (borgediget.toke.dk. [85.204.121.218]) by smtp.gmail.com with ESMTPSA id c57sm5744538ede.28.2019.04.04.06.01.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2019 06:01:34 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id C4DE71804A7; Thu, 4 Apr 2019 15:01:33 +0200 (CEST) Subject: [PATCH net 2/2] sch_cake: Make sure we can write the IP header before changing DSCP bits From: Toke =?utf-8?q?H=C3=B8iland-J=C3=B8rgensen?= To: David Miller Cc: netdev@vger.kernel.org, cake@lists.bufferbloat.net Date: Thu, 04 Apr 2019 15:01:33 +0200 Message-ID: <155438289374.18760.4278774647362746152.stgit@alrua-x1> In-Reply-To: <155438289359.18760.18027832614176337074.stgit@alrua-x1> References: <155438289359.18760.18027832614176337074.stgit@alrua-x1> User-Agent: StGit/unknown-version MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is not actually any guarantee that the IP headers are valid before we access the DSCP bits of the packets. Fix this using the same approach taken in sch_dsmark. Reported-by: Kevin Darbyshire-Bryant Signed-off-by: Toke Høiland-Jørgensen --- net/sched/sch_cake.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index a3b55e18df04..259d97bc2abd 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c @@ -1517,16 +1517,27 @@ static unsigned int cake_drop(struct Qdisc *sch, struct sk_buff **to_free) static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash) { + int wlen = skb_network_offset(skb); u8 dscp; switch (tc_skb_protocol(skb)) { case htons(ETH_P_IP): + wlen += sizeof(struct iphdr); + if (!pskb_may_pull(skb, wlen) || + skb_try_make_writable(skb, wlen)) + return 0; + dscp = ipv4_get_dsfield(ip_hdr(skb)) >> 2; if (wash && dscp) ipv4_change_dsfield(ip_hdr(skb), INET_ECN_MASK, 0); return dscp; case htons(ETH_P_IPV6): + wlen += sizeof(struct ipv6hdr); + if (!pskb_may_pull(skb, wlen) || + skb_try_make_writable(skb, wlen)) + return 0; + dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> 2; if (wash && dscp) ipv6_change_dsfield(ipv6_hdr(skb), INET_ECN_MASK, 0);