Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932559AbcDYNQF (ORCPT ); Mon, 25 Apr 2016 09:16:05 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:51613 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932166AbcDYNQD (ORCPT ); Mon, 25 Apr 2016 09:16:03 -0400 From: Arnd Bergmann To: Saeed Mahameed , Matan Barak , Leon Romanovsky Cc: Arnd Bergmann , "David S. Miller" , Achiad Shochat , Or Gerlitz , Amir Vadai , Tariq Toukan , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/mlx5e: avoid stack overflow in mlx5e_open_channels Date: Mon, 25 Apr 2016 15:15:23 +0200 Message-Id: <1461590139-1396745-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:4oxhuK69JyI4F6qEXTp45WiLpg8b6ooUEROufAeCa0o1eedkTn+ YihgK1AbtbEmV2oe1FSJrq6jPbzVga0BMUl29NfdMWEP60l3q4Ctmm/Kr/fXoFmq4WiC2EZ IsDT8z8oP6Z8mUDg6CWJmCpOgk6mIKHyNNqkpQdK9K4iVbU9Ej3HjhfAu3t0fNvCzkdixCf CXf7W9EOF15iAwYX5rrBA== X-UI-Out-Filterresults: notjunk:1;V01:K0:FgEpjQJSvzg=:rXSGuMNxsJ58hVl4mAYIKW wiQtdsb84AhCUGAegHmPoJ/szbl0T1PrnXJYTC2A55Tmizpqkk9/BOp0MBt69hRll/O7k9Z5P QEGOU0/1tiFFD7ofQNKkdx/cxmGstH4hDSsSNqjljy7VmYoqN9xoaIImto17OU/UvCBJl/MBP 8pyiR3L7hVzu0E9GuUvwzpW4iZ5y29THZnYFv+ZW1o5L7wV8cy7u312fGc9KqmVpuQ4rTNbtl pWRpmCAQqiIDtIUivkp5tBgM2zc9JjbAi+ch6q9IyZanpa6Ao9yc3oKBq1+evzHALfJTxcWap QmjvFuV8kpeW9iq7MXthuCyoRmzNt68NYIwhgFL2o2V0uCOgaHAxiT49BJnEH+3UId2ZYiZpC l+uRC+3I99PX6GUkwJ5gMvZJdxj5lqYMV6nz9ttZEuPkEjaML0x4dha7HZnAXdg4SW55XRtrv 017YmjmXiCYESbjnuxsG9Dh/Jrh0f9kjuoE/65jLUVwR+cKa1HI0ts0Z13ySqXujZsV/3beBU gZOiCiNHkZVVXiqX1dK1tj1W07+FA2GyhMhsTwPZhY0A1hVJLkOD/wdNzFgcJfqNied6X3PG3 yjF6eH8JRGUO4EHr/XQ66manDS94M5ob6jX1jD8S8Pe20m+EeTB3rduFLd/VJhBPOphuZop3q l9szq9QW5oJCWsom+I0Sy2vA2aLyjeqN3T1BZcJkmTpOMTamV4Nzf55c/1Serc9vwH3I= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3018 Lines: 86 struct mlx5e_channel_param is a large structure that is allocated on the stack of mlx5e_open_channels, and with a recent change it has grown beyond the warning size for the maximum stack that a single function should use: mellanox/mlx5/core/en_main.c: In function 'mlx5e_open_channels': mellanox/mlx5/core/en_main.c:1325:1: error: the frame size of 1072 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] The function is already using dynamic allocation and is not in a fast path, so the easiest workaround is to use another kzalloc for allocating the channel parameters. Signed-off-by: Arnd Bergmann Fixes: d3c9bc2743dc ("net/mlx5e: Added ICO SQs") --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 22742e1fbcb9..2ec547a80886 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -1266,12 +1266,14 @@ static void mlx5e_build_icosq_param(struct mlx5e_priv *priv, param->icosq = true; } -static void mlx5e_build_channel_param(struct mlx5e_priv *priv, - struct mlx5e_channel_param *cparam) +static struct mlx5e_channel_param *mlx5e_build_channel_param(struct mlx5e_priv *priv) { + struct mlx5e_channel_param *cparam; u8 icosq_log_wq_sz = MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE; - memset(cparam, 0, sizeof(*cparam)); + cparam = kzalloc(sizeof(struct mlx5e_channel_param), GFP_KERNEL); + if (!cparam) + return NULL; mlx5e_build_rq_param(priv, &cparam->rq); mlx5e_build_sq_param(priv, &cparam->sq); @@ -1279,11 +1281,13 @@ static void mlx5e_build_channel_param(struct mlx5e_priv *priv, mlx5e_build_rx_cq_param(priv, &cparam->rx_cq); mlx5e_build_tx_cq_param(priv, &cparam->tx_cq); mlx5e_build_ico_cq_param(priv, &cparam->icosq_cq, icosq_log_wq_sz); + + return cparam; } static int mlx5e_open_channels(struct mlx5e_priv *priv) { - struct mlx5e_channel_param cparam; + struct mlx5e_channel_param *cparam; int nch = priv->params.num_channels; int err = -ENOMEM; int i; @@ -1298,9 +1302,12 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv) if (!priv->channel || !priv->txq_to_sq_map) goto err_free_txq_to_sq_map; - mlx5e_build_channel_param(priv, &cparam); + cparam = mlx5e_build_channel_param(priv); + if (!cparam) + goto err_free_txq_to_sq_map; + for (i = 0; i < nch; i++) { - err = mlx5e_open_channel(priv, i, &cparam, &priv->channel[i]); + err = mlx5e_open_channel(priv, i, cparam, &priv->channel[i]); if (err) goto err_close_channels; } @@ -1311,11 +1318,13 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv) goto err_close_channels; } + kfree(cparam); return 0; err_close_channels: for (i--; i >= 0; i--) mlx5e_close_channel(priv->channel[i]); + kfree(cparam); err_free_txq_to_sq_map: kfree(priv->txq_to_sq_map); -- 2.7.0