Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4574538imu; Tue, 29 Jan 2019 04:04:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ZMy8+tUXE1ia1loLNcWorflKPkUiYL7/i1O0RUm3tG9vBdPlHsgQ0kbhOE03RwYBbr3Xd X-Received: by 2002:aa7:810c:: with SMTP id b12mr25703932pfi.44.1548763468260; Tue, 29 Jan 2019 04:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548763468; cv=none; d=google.com; s=arc-20160816; b=EMXApYPRL8X8obv7xp27ZMmw27n85t6a8kpoPohj5xUL3xPmxNxkGkT55l62cEmSsQ 22GV6HZCDNG5EcuFdk+zu6tixb9HrxJfLygByfx5ZTNYxo8zBhYAB2Kpwwsif/Jp6cZZ gZ7QDRLzS+0kv8NnYEnQG2/vCvXBQbSsRlxBUIn5zjfZ9RCuM6T+QEBnJyuuVP4fS6Du 0uv3aR0a0fWhCnnqvpn4dSa++BusUobKUrw/tO/5gg0Ltjhwqmt7F61hQ6Is958YkSXu 79uIpFiGEhghx2OWUO+F/VmEHYBuBt7LBgTGrzUZsNcs0ih6XOij6v3bOye/hEfpU776 Ku1A== 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=gkX+RSPSUWo4a7Y6qsvdFfvG3zwCnPhR/mrf4o8Ix7I=; b=L/kWEKt1g/KJ2en40bsBnNFwdAG3vYXI6fy2aQr6tG0zGciPFZ7odp5hq0jE8QhdeI SWSriAPjTh6PZ2VwukXS4s2wSzWAaBfRt2fcWYT2jzrQhhZeRUBmFVAVEw8DTX5eu4mv CroSigv6PWQofhj93EPBJY1VLaQwe5bP3MhDPuaZlpK8yQ5y+fenndVj8Pdc/c6XOxPi KRvgt3kFDFVMMGvguLik+viJ9dUF9bwx/beG9DY9saUNIDdmvsB9oFuGZQE6/pOuAdBh WyFoeCTsxkBXfvjbS9b6UJcGRofMlWF/TbXdLQZ8twSr4OB5IKBGAoL5JDFvEYCLwZFo u2MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cQu3wF39; 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 j1si17819391plk.342.2019.01.29.04.04.11; Tue, 29 Jan 2019 04:04:28 -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=cQu3wF39; 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 S1730316AbfA2LnZ (ORCPT + 99 others); Tue, 29 Jan 2019 06:43:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:33278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730297AbfA2LnY (ORCPT ); Tue, 29 Jan 2019 06:43:24 -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 48B0720856; Tue, 29 Jan 2019 11:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762203; bh=n0kRVq9QpyAu7Slo0WmDiiedmmGXvLL0g6oW/x6ihuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cQu3wF39EKLR7cZXBw5FPUV9AYenZ2wyLOl1cEQcpXqD5AidUTGwtWX4Sg9LjL1Gv PO6KZc1TIQ+oQZe2ON95/x6tCLGC6KW8uiCLGduqKGs+3O6LcbZV5xnYMDCozlii74 /2LBc3LSb6pkF+C8wH4G088s1Ij8mWbjqRvZOU6k= 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.19 008/103] net_sched: refetch skb protocol for each filter Date: Tue, 29 Jan 2019 12:34:45 +0100 Message-Id: <20190129113200.023547747@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129113159.567154026@linuxfoundation.org> References: <20190129113159.567154026@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.19-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/cls_api.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -960,7 +960,6 @@ static int tcf_block_cb_call(struct tcf_ int tcf_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 int max_reclassify_loop = 4; const struct tcf_proto *orig_tp = tp; @@ -970,6 +969,7 @@ int tcf_classify(struct sk_buff *skb, co reclassify: #endif for (; tp; tp = rcu_dereference_bh(tp->next)) { + __be16 protocol = tc_skb_protocol(skb); int err; if (tp->protocol != protocol && @@ -1002,7 +1002,6 @@ reset: } tp = first_tp; - protocol = tc_skb_protocol(skb); goto reclassify; #endif }