Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3672231ima; Mon, 4 Feb 2019 03:11:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN7icPTqTZexEEtV32MfZfXZ969y+DQYWB3VkywCcxUIIXJ9mFX+2jTEnGJnq3S4xRNTLU+6 X-Received: by 2002:a62:de06:: with SMTP id h6mr52075241pfg.158.1549278710445; Mon, 04 Feb 2019 03:11:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549278710; cv=none; d=google.com; s=arc-20160816; b=yNLmTHAj5vH1FVorUuiATHuSyHcb/C+SINGevxb3CipOvlG7ahRYO0fwWVCST1uZQT 32H0M4OC8WvJYjMPEEgCgv6lt2+1Gp1ehXNkfWpZxmSUY5G/8PEItpUajLRUjReKmQLf zQV4eYOSgZCH1jYO4utJpnaFNhfgspdLyQBfgXx+RgVOn5TEk87o57R+8JqJNe5EoY20 DvgY5USlYCvx1QZdBnsIgJf2H/G0rP9hdwLFEy2QEMjlLPH0rvuuQ+abP6l2NXPtC9j2 dJaIFdMsLtZMXCKOb7tsoTgH4awI5sZq1M4TkzsX9ny+yrBeenXGqh3SrwZLqgxvRf97 ccrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Hq2u0sEMLrKn8IsYMZgXXk/RAChUCDDJyGPdCvIiTT8=; b=iTifV7n3Sq0FViIgo5mMqmceGfeZw4H+iYXvyPepAb+tyu6U0X7xDNny24q4/CRXYB e/G/eRS1NwFS1tVf4/xp30Dbgrp2mOoJW4NqlER2Q+Q3bC/kEDP1eaunNTP9btHZLjbC atB5INHKAtxFVaPbNxRoMi71a3dWbsUqALdjLEt5S+JnkxIz8BmbNaa4lTBYz4I0+5l1 BrU4xhifc4LFGz5lxEDD4rKf8fGsEFE9+egSVFml2iZwrcO94iwVYD4qKN6llEok1jxI OtuiyjO8/iHN78c6kuPF9N/Vp448q69VXKq0SEQ8pe91Zfe7IHJwkxpM+XLsMaoG/0Xm PkGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uXKkTlFI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 197si11867144pgb.564.2019.02.04.03.11.34; Mon, 04 Feb 2019 03:11:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uXKkTlFI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728241AbfBDKkL (ORCPT + 99 others); Mon, 4 Feb 2019 05:40:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:38082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729923AbfBDKkH (ORCPT ); Mon, 4 Feb 2019 05:40:07 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 16D962070C; Mon, 4 Feb 2019 10:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549276806; bh=trmpcSe3OITfTjOziUZl9FKg1pDDftfXShC19q/KqVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uXKkTlFID/XBeNfx1L5TPenO6+U5VaLHl2v/blYw3KiOLOqwzAiFjQe8nVlJuSczS K6vrChoJbAmbNAe66ety2WLyFkl7okuzkux86z+rGoiiMPdZpVmysGF5VtuW3jkvsl BG6h12TESdy9wmve1aUwNdOoKQmNfqJVMKjK0jy8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Olsson , Jamal Hadi Salim , Jiri Pirko , Cong Wang , "David S. Miller" Subject: [PATCH 4.4 04/65] net_sched: refetch skb protocol for each filter Date: Mon, 4 Feb 2019 11:35:57 +0100 Message-Id: <20190204103611.317915261@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103610.583715954@linuxfoundation.org> References: <20190204103610.583715954@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit cd0c4e70fc0ccfa705cdf55efb27519ce9337a26 ] Martin reported a set of filters don't work after changing from reclassify to continue. Looking into the code, it looks like skb protocol is not always fetched for each iteration of the filters. But, as demonstrated by Martin, TC actions could modify skb->protocol, for example act_vlan, this means we have to refetch skb protocol in each iteration, rather than using the one we fetch in the beginning of the loop. This bug is _not_ introduced by commit 3b3ae880266d ("net: sched: consolidate tc_classify{,_compat}"), technically, if act_vlan is the only action that modifies skb protocol, then it is commit c7e2b9689ef8 ("sched: introduce vlan action") which introduced this bug. Reported-by: Martin Olsson Cc: Jamal Hadi Salim Cc: Jiri Pirko Signed-off-by: Cong Wang Acked-by: Jamal Hadi Salim Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_api.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1823,7 +1823,6 @@ done: int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp, struct tcf_result *res, bool compat_mode) { - __be16 protocol = tc_skb_protocol(skb); #ifdef CONFIG_NET_CLS_ACT const struct tcf_proto *old_tp = tp; int limit = 0; @@ -1831,6 +1830,7 @@ int tc_classify(struct sk_buff *skb, con reclassify: #endif for (; tp; tp = rcu_dereference_bh(tp->next)) { + __be16 protocol = tc_skb_protocol(skb); int err; if (tp->protocol != protocol && @@ -1857,7 +1857,6 @@ reset: } tp = old_tp; - protocol = tc_skb_protocol(skb); goto reclassify; #endif }