From patchwork Thu Sep 16 15:59:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 513029 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1429589jao; Thu, 16 Sep 2021 10:26:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvzYD0n/dACZTvX2v2S4RoI7juUpOh+oq5Yb33YgmHOIXM+8PvtP353agdakg0p8Vf/bid X-Received: by 2002:aa7:d598:: with SMTP id r24mr7588392edq.285.1631813207141; Thu, 16 Sep 2021 10:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631813207; cv=none; d=google.com; s=arc-20160816; b=i5jgIztKmu+xujX0IaubwJzli6jNXwNYIQWZYkzKtOefQjHl/5jFnoClJscQtBZ6MT BOllDsZhLkafpMQAke0CZ6Kc8MbZOGeJcGPk+HE+qV6sOulFqdA+8xlK/Awtc9qZnwiQ 6/eVymJRF49ITwStbvgHYxBB/iWabGYayDpUqkY8jr1seSZQzqYwifwCTNiiNmpmTydy oKXfreq3v6vnxAGfaxmkCNXceY/2/0rbNCQ43OQ/ovszJ1dZfBrAbxHsFb1wWHAJj2Ns awafwpIB62+7bqdDBUno65UQBJ8HuZ6sDJ0Du3jEsABba3TEcqZ2XAy5MI9oP3aaOtTW Daqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fqBKJJQtODp7x1GbCP6FJ1bbsWZs6iO4bOjUVe53T6U=; b=Rj1+VGZJ/gKpwops3FBDZIj+an6GCvF813dqIHsE0iGQPSPzcddD5bEAVCQ6twBTTx 9mW7Q7stA1/kqRLYsFYfGyBh5/ziwo4IPhajXvQ0Ez3u4zUuN+F+4osMnr5j8bUugceC CTKV0pFqdMLL1dIA4hrQ/6YtGmEnuTO3vTt7vbEf+8Ie7w+qJXSfKAI6UXjOdETLIbuv XfaYR0MNcYOr5KmnvF+y2wlfWco4c99CeFGrd1BSN+CRSglWceVs2OVnMNjs9G5E/0vC RXiOFUM6y+8hiaCQgK+ZQr/qppum780027GNJbwAxgDu5mA+HoctEGe4uUOmobae4ZH4 EWiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="W/4i8MWr"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ka8si3766293ejb.83.2021.09.16.10.26.46; Thu, 16 Sep 2021 10:26:47 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="W/4i8MWr"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243154AbhIPR2D (ORCPT + 11 others); Thu, 16 Sep 2021 13:28:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:46964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348334AbhIPRZz (ORCPT ); Thu, 16 Sep 2021 13:25:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AF48661BF3; Thu, 16 Sep 2021 16:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810666; bh=2JntmivuHJPxvvoKc91C/1ZAcnZue6O8y+RHCQyB10Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W/4i8MWrEtLt40C04DsyssclXyaYPcZ2bn1fF5uL3YXEmMxfZkmL37Ezsu/VWEghd 4nR/1h3d1tjN9mqZRRzPRkYm4w+gJ8S8APsftc0ehbqYDqqRMlNY0CKfM2wazG6qOs PgGz1IWoyYoso9Jpsc0zy6c9MA9/mPFERULCzkHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Elder , "David S. Miller" , Sasha Levin Subject: [PATCH 5.14 224/432] net: ipa: always validate filter and route tables Date: Thu, 16 Sep 2021 17:59:33 +0200 Message-Id: <20210916155818.439019907@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alex Elder [ Upstream commit 546948bf362541857d4f500705efe08a2fe0bb95 ] All checks in ipa_table_validate_build() are computed at build time, so build that unconditionally. In ipa_table_valid() calls to ipa_table_valid_one() are missing the IPA pointer parameter is missing in (a bug that shows up only when IPA_VALIDATE is defined). Don't bother checking whether hashed table memory regions are valid if hashed tables are not supported. With those things fixed, have these table validation functions built unconditionally (not dependent on IPA_VALIDATE). Signed-off-by: Alex Elder Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ipa/ipa_table.c | 36 +++++++++++++++++------------------- drivers/net/ipa/ipa_table.h | 16 ---------------- 2 files changed, 17 insertions(+), 35 deletions(-) -- 2.30.2 diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 4f5b6749f6aa..c607ebec7456 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -120,8 +120,6 @@ */ #define IPA_ZERO_RULE_SIZE (2 * sizeof(__le32)) -#ifdef IPA_VALIDATE - /* Check things that can be validated at build time. */ static void ipa_table_validate_build(void) { @@ -169,7 +167,7 @@ ipa_table_valid_one(struct ipa *ipa, enum ipa_mem_id mem_id, bool route) return true; /* Hashed table regions can be zero size if hashing is not supported */ - if (hashed && !mem->size) + if (ipa_table_hash_support(ipa) && !mem->size) return true; dev_err(dev, "%s table region %u size 0x%02x, expected 0x%02x\n", @@ -183,14 +181,22 @@ bool ipa_table_valid(struct ipa *ipa) { bool valid; - valid = ipa_table_valid_one(IPA_MEM_V4_FILTER, false); - valid = valid && ipa_table_valid_one(IPA_MEM_V4_FILTER_HASHED, false); - valid = valid && ipa_table_valid_one(IPA_MEM_V6_FILTER, false); - valid = valid && ipa_table_valid_one(IPA_MEM_V6_FILTER_HASHED, false); - valid = valid && ipa_table_valid_one(IPA_MEM_V4_ROUTE, true); - valid = valid && ipa_table_valid_one(IPA_MEM_V4_ROUTE_HASHED, true); - valid = valid && ipa_table_valid_one(IPA_MEM_V6_ROUTE, true); - valid = valid && ipa_table_valid_one(IPA_MEM_V6_ROUTE_HASHED, true); + valid = ipa_table_valid_one(ipa, IPA_MEM_V4_FILTER, false); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_FILTER, false); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_ROUTE, true); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_ROUTE, true); + + if (!ipa_table_hash_support(ipa)) + return valid; + + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_FILTER_HASHED, + false); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_FILTER_HASHED, + false); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_ROUTE_HASHED, + true); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_ROUTE_HASHED, + true); return valid; } @@ -217,14 +223,6 @@ bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_map) return true; } -#else /* !IPA_VALIDATE */ -static void ipa_table_validate_build(void) - -{ -} - -#endif /* !IPA_VALIDATE */ - /* Zero entry count means no table, so just return a 0 address */ static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count) { diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 1e2be9fce2f8..b6a9a0d79d68 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -16,8 +16,6 @@ struct ipa; /* The maximum number of route table entries (IPv4, IPv6; hashed or not) */ #define IPA_ROUTE_COUNT_MAX 15 -#ifdef IPA_VALIDATE - /** * ipa_table_valid() - Validate route and filter table memory regions * @ipa: IPA pointer @@ -35,20 +33,6 @@ bool ipa_table_valid(struct ipa *ipa); */ bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask); -#else /* !IPA_VALIDATE */ - -static inline bool ipa_table_valid(struct ipa *ipa) -{ - return true; -} - -static inline bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask) -{ - return true; -} - -#endif /* !IPA_VALIDATE */ - /** * ipa_table_hash_support() - Return true if hashed tables are supported * @ipa: IPA pointer