From patchwork Tue Mar 3 17:43:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 229962 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B15ABC3F2D8 for ; Tue, 3 Mar 2020 18:03:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F6EC20866 for ; Tue, 3 Mar 2020 18:03:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583258604; bh=ICkoj4BoMcCZpXNjTu3BlqF99uO9sQthujAIdPctWzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xX1tXXZh8pLSwNTff6dtg/hOEo57fxLs0FkR7BO5TOJKyLc2oVY10vtyEH1vDVTfM QS7+Ns4o9xGPML0T8aIHh67EFS8AZQQGywo/Pn9mlHjYky/fh27CIahEhGmoTxd7Ht TDZfzkniIZiXEgkJ2TUttBWloBQ6mr3x7C9CFMAk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388025AbgCCSBh (ORCPT ); Tue, 3 Mar 2020 13:01:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:45866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388023AbgCCSBg (ORCPT ); Tue, 3 Mar 2020 13:01:36 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 0086621739; Tue, 3 Mar 2020 18:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583258496; bh=ICkoj4BoMcCZpXNjTu3BlqF99uO9sQthujAIdPctWzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=faaGG65OZfqorxptZOX6bXKYyolFRoowqknA1uywfaut4+600+FbAAkDIL6VY3im7 oNm2qCNgAAaMYyjNGlFmkcigM6F4p4SocV9CPRRLuvD6m3+EoZDYhij0+Sb1PS5Iqb CNsTUboAugjKnctZbycB78dlgj8ONigwCoZ6rGng= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Cong Wang , Jason Baron , "David S. Miller" Subject: [PATCH 4.19 32/87] net: sched: correct flower port blocking Date: Tue, 3 Mar 2020 18:43:23 +0100 Message-Id: <20200303174353.548779365@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174349.075101355@linuxfoundation.org> References: <20200303174349.075101355@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jason Baron [ Upstream commit 8a9093c79863b58cc2f9874d7ae788f0d622a596 ] tc flower rules that are based on src or dst port blocking are sometimes ineffective due to uninitialized stack data. __skb_flow_dissect() extracts ports from the skb for tc flower to match against. However, the port dissection is not done when when the FLOW_DIS_IS_FRAGMENT bit is set in key_control->flags. All callers of __skb_flow_dissect(), zero-out the key_control field except for fl_classify() as used by the flower classifier. Thus, the FLOW_DIS_IS_FRAGMENT may be set on entry to __skb_flow_dissect(), since key_control is allocated on the stack and may not be initialized. Since key_basic and key_control are present for all flow keys, let's make sure they are initialized. Fixes: 62230715fd24 ("flow_dissector: do not dissect l4 ports for fragments") Co-developed-by: Eric Dumazet Signed-off-by: Eric Dumazet Acked-by: Cong Wang Signed-off-by: Jason Baron Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/net/flow_dissector.h | 9 +++++++++ net/sched/cls_flower.c | 1 + 2 files changed, 10 insertions(+) --- a/include/net/flow_dissector.h +++ b/include/net/flow_dissector.h @@ -5,6 +5,7 @@ #include #include #include +#include #include /** @@ -306,4 +307,12 @@ static inline void *skb_flow_dissector_t return ((char *)target_container) + flow_dissector->offset[key_id]; } +static inline void +flow_dissector_init_keys(struct flow_dissector_key_control *key_control, + struct flow_dissector_key_basic *key_basic) +{ + memset(key_control, 0, sizeof(*key_control)); + memset(key_basic, 0, sizeof(*key_basic)); +} + #endif --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -196,6 +196,7 @@ static int fl_classify(struct sk_buff *s struct fl_flow_key skb_mkey; list_for_each_entry_rcu(mask, &head->masks, list) { + flow_dissector_init_keys(&skb_key.control, &skb_key.basic); fl_clear_masked_range(&skb_key, mask); skb_key.indev_ifindex = skb->skb_iif;