All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Zhu Yanjun <yanjun.zhu@linux.dev>, Arnd Bergmann <arnd@arndb.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Yevgeny Kliteynik <kliteyn@nvidia.com>,
	Alex Vesker <valex@nvidia.com>,
	Hamdan Igbaria <hamdani@nvidia.com>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] [v2] net/mlx5: fix possible stack overflows
Date: Tue, 20 Feb 2024 08:06:24 +0000	[thread overview]
Message-ID: <20240220080624.GQ40273@kernel.org> (raw)
In-Reply-To: <20240219100506.648089-2-arnd@kernel.org>

On Mon, Feb 19, 2024 at 11:04:56AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> A couple of debug functions use a 512 byte temporary buffer and call another
> function that has another buffer of the same size, which in turn exceeds the
> usual warning limit for excessive stack usage:
> 
> drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c:1073:1: error: stack frame size (1448) exceeds limit (1024) in 'dr_dump_start' [-Werror,-Wframe-larger-than]
> dr_dump_start(struct seq_file *file, loff_t *pos)
> drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c:1009:1: error: stack frame size (1120) exceeds limit (1024) in 'dr_dump_domain' [-Werror,-Wframe-larger-than]
> dr_dump_domain(struct seq_file *file, struct mlx5dr_domain *dmn)
> drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c:705:1: error: stack frame size (1104) exceeds limit (1024) in 'dr_dump_matcher_rx_tx' [-Werror,-Wframe-larger-than]
> dr_dump_matcher_rx_tx(struct seq_file *file, bool is_rx,
> 
> Rework these so that each of the various code paths only ever has one of
> these buffers in it, and exactly the functions that declare one have
> the 'noinline_for_stack' annotation that prevents them from all being
> inlined into the same caller.
> 
> Fixes: 917d1e799ddf ("net/mlx5: DR, Change SWS usage to debug fs seq_file interface")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> [v2] no changes, just based on patch 1/2 but can still be applied independently
> ---
>  .../mellanox/mlx5/core/steering/dr_dbg.c      | 82 +++++++++----------
>  1 file changed, 41 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c
> index be7a8481d7d2..eae04f66b8f4 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c
> @@ -205,12 +205,11 @@ dr_dump_hex_print(char hex[DR_HEX_SIZE], char *src, u32 size)
>  }
>  
>  static int
> -dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id,
> +dr_dump_rule_action_mem(struct seq_file *file, char *buff, const u64 rule_id,
>  			struct mlx5dr_rule_action_member *action_mem)
>  {
>  	struct mlx5dr_action *action = action_mem->action;
>  	const u64 action_id = DR_DBG_PTR_TO_ID(action);
> -	char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH];
>  	u64 hit_tbl_ptr, miss_tbl_ptr;
>  	u32 hit_tbl_id, miss_tbl_id;
>  	int ret;

Hi Arnd,

With patch 1/2 in place this code goes on as:

	switch (action->action_type) {
	case DR_ACTION_TYP_DROP:
		memset(buff, 0, sizeof(buff));

buff is now a char * rather than an array of char.
siceof(buff) doesn't seem right here anymore.

Flagged by Coccinelle.

  reply	other threads:[~2024-02-20  8:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19 10:04 [PATCH 1/2] net/mlx5: pre-initialize sprintf buffers Arnd Bergmann
2024-02-19 10:04 ` [PATCH 2/2] [v2] net/mlx5: fix possible stack overflows Arnd Bergmann
2024-02-20  8:06   ` Simon Horman [this message]
2024-02-20  8:11     ` Arnd Bergmann
2024-02-20  8:21       ` Yevgeny Kliteynik
2024-02-21 10:34       ` Simon Horman
2024-02-20  5:50 ` [PATCH 1/2] net/mlx5: pre-initialize sprintf buffers Zhu Yanjun
2024-02-20  6:57   ` Yevgeny Kliteynik
2024-02-20 14:54     ` Zhu Yanjun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240220080624.GQ40273@kernel.org \
    --to=horms@kernel.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hamdani@nvidia.com \
    --cc=kliteyn@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=valex@nvidia.com \
    --cc=yanjun.zhu@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.