From patchwork Thu Mar 4 10:29:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 393369 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 D3AE7C433E0 for ; Thu, 4 Mar 2021 10:31:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB1AC64F32 for ; Thu, 4 Mar 2021 10:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238499AbhCDKa4 (ORCPT ); Thu, 4 Mar 2021 05:30:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238477AbhCDKaf (ORCPT ); Thu, 4 Mar 2021 05:30:35 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AF4AC061574 for ; Thu, 4 Mar 2021 02:29:55 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id w9so488856edc.11 for ; Thu, 04 Mar 2021 02:29:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+1F8iOv0nfSeXuYHm8Yzgo/v5HFID2Xq5yv5D/mRLKw=; b=SmJlrrpGqZeRQg8axPl4oGDAGghvBL6WRxW/Dd5Jx7Cvpb2Eys5oNpTnp5AT18Qcyc MXDkUei4+FJBvfkV5iecjBVxTkHM2zFLg76eQO6160DUSu/18TIuePfuIuGpBz9+qcfT luIQukKNYiTMJmkrkCvVO9PT3NOxQCiUCTHstf2U3BAGTQ1HmC/Om0/gzm/+PfpF//Bv 8magJ1/a0CD6XKGa/z/LSUS6mzqxpx/4kESdkYXPrd0uBLirDGq3IU5dJ3oWm0KmcN4c MM1+lc119cKGJITqscyuJNAWVFP6kbrSeybGBqwkCBqL3ldSnZhsEFiakThDdAewGeY3 ODkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+1F8iOv0nfSeXuYHm8Yzgo/v5HFID2Xq5yv5D/mRLKw=; b=oO2wB1s3rYaj7X+2Cc6zq34Jywl+HJc3fD6PCtpLAycy3u58k9+RkX4elsK+bK8zZa fEDREMPp64DO5op0QgxGDprBmxsKfQdjuht6eTkR4noasxLllwJ102EcFh8kwzJRw8Pz +a/wpGp+nr1n2etH+sUX2VH0nxB3K3CTq6dfA/BqiBFm3+1niZ8XKPiW6MONPD+MOCHz 86uazPBpQfZFGm2BwJSEoRMnFplNcu89N3RYQ79iCs73L8GBWBtHeb7yB+j19JjN/Ux3 mfrEFoL8EcWsHIwm5GW3/8SVOPUH716CgtNpizCH6ml9OEKLbLjCXTaBuAuO6arZTJ4S IULg== X-Gm-Message-State: AOAM530PkmAwfTUBalnPGwKn4cE6MBhI71HpZrNJ0IhfXks6ZbAFG+IA 5s/TJpLsMNVVsihYzJ/7o6E= X-Google-Smtp-Source: ABdhPJxONPwmF4DPeW8P8uO3ppRBfLE9h7j99j8FZN7MoRepsgYXvXhCAW1tINi5fFqWyJrBdhiMoQ== X-Received: by 2002:a05:6402:3075:: with SMTP id bs21mr3566556edb.274.1614853794152; Thu, 04 Mar 2021 02:29:54 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id bx24sm10260145ejc.88.2021.03.04.02.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 02:29:53 -0800 (PST) From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Vladimir Oltean , Colin Ian King Subject: [PATCH net] net: mscc: ocelot: properly reject destination IP keys in VCAP IS1 Date: Thu, 4 Mar 2021 12:29:43 +0200 Message-Id: <20210304102943.865874-1-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean An attempt is made to warn the user about the fact that VCAP IS1 cannot offload keys matching on destination IP (at least given the current half key format), but sadly that warning fails miserably in practice, due to the fact that it operates on an uninitialized "match" variable. We must first decode the keys from the flow rule. Fixes: 75944fda1dfe ("net: mscc: ocelot: offload ingress skbedit and vlan actions to VCAP IS1") Reported-by: Colin Ian King Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot_flower.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c index c3ac026f6aea..a41b458b1b3e 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -540,13 +540,14 @@ ocelot_flower_parse_key(struct ocelot *ocelot, int port, bool ingress, return -EOPNOTSUPP; } + flow_rule_match_ipv4_addrs(rule, &match); + if (filter->block_id == VCAP_IS1 && *(u32 *)&match.mask->dst) { NL_SET_ERR_MSG_MOD(extack, "Key type S1_NORMAL cannot match on destination IP"); return -EOPNOTSUPP; } - flow_rule_match_ipv4_addrs(rule, &match); tmp = &filter->key.ipv4.sip.value.addr[0]; memcpy(tmp, &match.key->src, 4);