Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1494465ybe; Fri, 6 Sep 2019 19:44:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVzpuohxXWaPd9m7jqFJfTdgGvZxaufUEsXEuf7IzZHsEqh/Kf9z4RSr3Jtdts738vA/dH X-Received: by 2002:a17:902:b583:: with SMTP id a3mr12147567pls.52.1567824270697; Fri, 06 Sep 2019 19:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567824270; cv=none; d=google.com; s=arc-20160816; b=VXX0mp9an3d8OPI47P4PPLV5dCqA5HiF3mH1eL9WzyIp7yJ43+ieaiiWIPeZLWBpZP 1qoOqIEvTBsU12mHATs6DUxig6HjpcuhRm3BMYyVyCva0FDB7RP73GncNPGWkyDudPYP y85++AZDs4vZYYJhCXOyEq7g/pSCGhcCU/bVfMwsGd1G578hMevYuTIqx/ohUVyKkyq8 gRTwObulcL+6o1DUxJ0Qx4L+rXmWFODZK5LlBU/j75cnfpwtG230F09a2G7dIUDRsAf6 ecjaXo9N0n3a3/Hu72FUbf7sEtsQ1O1DVk1P90Gj8C/mcr+uYFFn96vWEXGVDWcSPOYr FQ0Q== 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 :message-id:date:subject:cc:to:from; bh=0dO+voyEOm8C3Cg5FWUDURyfTL0XIbwVNwxBa1MAwOw=; b=gqtK92hSrRX0/2p5pP+fNUaqiY/esBAD/Zt7/LajtWd9Rm7knU/d4el7e9kovEEUDy 4Ljdz0tekDzBcTQ3PoQXgT4pFDVpa1AOGEETtcwigKjviTn1fjUIAIAfS8bbYG6Ye/6L NtjFjKHEEC6BBDQMye0ae4xrSXv3WajO19yiM5oM8/NMGqBjmSUy3G4hUA60ptLaVRDS gN0G1buo8dgZVeeQuqoyjYMPffK482SAMu1zNScEHLd5cx/Qvk4PpA7vv+5h9cLlrBa8 esZ+1Vn32aFwMP/9QMmqVCjgB8C4zUsT5uaS9G0jvmGeV/qpiFxG+nGc8uFrYUf7AUvC Io6w== ARC-Authentication-Results: i=1; mx.google.com; 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 v2si7676576pfm.195.2019.09.06.19.43.54; Fri, 06 Sep 2019 19:44:30 -0700 (PDT) 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; 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 S2388752AbfIFPM7 (ORCPT + 99 others); Fri, 6 Sep 2019 11:12:59 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:54149 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726019AbfIFPM7 (ORCPT ); Fri, 6 Sep 2019 11:12:59 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1McY0L-1ijAZ70D9h-00cviz; Fri, 06 Sep 2019 17:12:44 +0200 From: Arnd Bergmann To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" Cc: Arnd Bergmann , Jakub Kicinski , wenxu , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] netfilter: nf_tables: avoid excessive stack usage Date: Fri, 6 Sep 2019 17:12:30 +0200 Message-Id: <20190906151242.1115282-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content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TMT5FA+iLFsBPS2Wvs44Jq346tuA95Suve8MNFTZuAFHLC+QmM8 TSSeQQt98Sh5pXMhV5FJnuRgaslWg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The nft_offload_ctx structure is much too large to put on the stack: net/netfilter/nf_tables_offload.c:31:23: error: stack frame size of 1200 bytes in function 'nft_flow_rule_create' [-Werror,-Wframe-larger-than=] Use dynamic allocation here, as we do elsewhere in the same function. Fixes: c9626a2cbdb2 ("netfilter: nf_tables: add hardware offload support") Signed-off-by: Arnd Bergmann --- Since we only really care about two members of the structure, an alternative would be a larger rewrite, but that is probably too late for v5.4. --- net/netfilter/nf_tables_offload.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c index 3c2725ade61b..c94331aae552 100644 --- a/net/netfilter/nf_tables_offload.c +++ b/net/netfilter/nf_tables_offload.c @@ -30,15 +30,13 @@ static struct nft_flow_rule *nft_flow_rule_alloc(int num_actions) struct nft_flow_rule *nft_flow_rule_create(const struct nft_rule *rule) { - struct nft_offload_ctx ctx = { - .dep = { - .type = NFT_OFFLOAD_DEP_UNSPEC, - }, - }; + struct nft_offload_ctx *ctx; + struct nft_flow_rule *flow; int num_actions = 0, err; struct nft_expr *expr; + expr = nft_expr_first(rule); while (expr->ops && expr != nft_expr_last(rule)) { if (expr->ops->offload_flags & NFT_OFFLOAD_F_ACTION) @@ -52,21 +50,31 @@ struct nft_flow_rule *nft_flow_rule_create(const struct nft_rule *rule) return ERR_PTR(-ENOMEM); expr = nft_expr_first(rule); + + ctx = kzalloc(sizeof(struct nft_offload_ctx), GFP_KERNEL); + if (!ctx) { + err = -ENOMEM; + goto err_out; + } + ctx->dep.type = NFT_OFFLOAD_DEP_UNSPEC; + while (expr->ops && expr != nft_expr_last(rule)) { if (!expr->ops->offload) { err = -EOPNOTSUPP; goto err_out; } - err = expr->ops->offload(&ctx, flow, expr); + err = expr->ops->offload(ctx, flow, expr); if (err < 0) goto err_out; expr = nft_expr_next(expr); } - flow->proto = ctx.dep.l3num; + flow->proto = ctx->dep.l3num; + kfree(ctx); return flow; err_out: + kfree(ctx); nft_flow_rule_destroy(flow); return ERR_PTR(err); -- 2.20.0