netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show()
@ 2023-10-21 18:03 Christophe JAILLET
  2023-10-22 10:30 ` patchwork-bot+netdevbpf
  2023-10-23  6:24 ` Hennerich, Michael
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2023-10-21 18:03 UTC (permalink / raw)
  To: keescook, Michael Hennerich, Alexander Aring, Stefan Schmidt,
	Miquel Raynal, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Marcel Holtmann
  Cc: linux-hardening, linux-kernel, kernel-janitors,
	Christophe JAILLET, Stefan Schmidt, linux-wpan, netdev

strncat() usage in adf7242_debugfs_init() is wrong.
The size given to strncat() is the maximum number of bytes that can be
written, excluding the trailing NULL.

Here, the size that is passed, DNAME_INLINE_LEN, does not take into account
the size of "adf7242-" that is already in the array.

In order to fix it, use snprintf() instead.

Fixes: 7302b9d90117 ("ieee802154/adf7242: Driver for ADF7242 MAC IEEE802154")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/ieee802154/adf7242.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c
index a03490ba2e5b..cc7ddc40020f 100644
--- a/drivers/net/ieee802154/adf7242.c
+++ b/drivers/net/ieee802154/adf7242.c
@@ -1162,9 +1162,10 @@ static int adf7242_stats_show(struct seq_file *file, void *offset)
 
 static void adf7242_debugfs_init(struct adf7242_local *lp)
 {
-	char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "adf7242-";
+	char debugfs_dir_name[DNAME_INLINE_LEN + 1];
 
-	strncat(debugfs_dir_name, dev_name(&lp->spi->dev), DNAME_INLINE_LEN);
+	snprintf(debugfs_dir_name, sizeof(debugfs_dir_name),
+		 "adf7242-%s", dev_name(&lp->spi->dev));
 
 	lp->debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show()
  2023-10-21 18:03 [PATCH net] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show() Christophe JAILLET
@ 2023-10-22 10:30 ` patchwork-bot+netdevbpf
  2023-10-23  6:24 ` Hennerich, Michael
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-22 10:30 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: keescook, michael.hennerich, alex.aring, stefan, miquel.raynal,
	davem, edumazet, kuba, pabeni, marcel, linux-hardening,
	linux-kernel, kernel-janitors, stefan, linux-wpan, netdev

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Sat, 21 Oct 2023 20:03:53 +0200 you wrote:
> strncat() usage in adf7242_debugfs_init() is wrong.
> The size given to strncat() is the maximum number of bytes that can be
> written, excluding the trailing NULL.
> 
> Here, the size that is passed, DNAME_INLINE_LEN, does not take into account
> the size of "adf7242-" that is already in the array.
> 
> [...]

Here is the summary with links:
  - [net] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show()
    https://git.kernel.org/netdev/net/c/ca082f019d8f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH net] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show()
  2023-10-21 18:03 [PATCH net] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show() Christophe JAILLET
  2023-10-22 10:30 ` patchwork-bot+netdevbpf
@ 2023-10-23  6:24 ` Hennerich, Michael
  1 sibling, 0 replies; 3+ messages in thread
From: Hennerich, Michael @ 2023-10-23  6:24 UTC (permalink / raw)
  To: Christophe JAILLET, keescook@chromium.org, Alexander Aring,
	Stefan Schmidt, Miquel Raynal, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Marcel Holtmann
  Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org, Stefan Schmidt,
	linux-wpan@vger.kernel.org, netdev@vger.kernel.org



> -----Original Message-----
> From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Sent: Samstag, 21. Oktober 2023 20:04
> To: keescook@chromium.org; Hennerich, Michael
> <Michael.Hennerich@analog.com>; Alexander Aring <alex.aring@gmail.com>;
> Stefan Schmidt <stefan@datenfreihafen.org>; Miquel Raynal
> <miquel.raynal@bootlin.com>; David S. Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo
> Abeni <pabeni@redhat.com>; Marcel Holtmann <marcel@holtmann.org>
> Cc: linux-hardening@vger.kernel.org; linux-kernel@vger.kernel.org; kernel-
> janitors@vger.kernel.org; Christophe JAILLET <christophe.jaillet@wanadoo.fr>;
> Stefan Schmidt <stefan@osg.samsung.com>; linux-wpan@vger.kernel.org;
> netdev@vger.kernel.org
> Subject: [PATCH net] net: ieee802154: adf7242: Fix some potential buffer
> overflow in adf7242_stats_show()
> 
> 
> strncat() usage in adf7242_debugfs_init() is wrong.
> The size given to strncat() is the maximum number of bytes that can be written,
> excluding the trailing NULL.
> 
> Here, the size that is passed, DNAME_INLINE_LEN, does not take into account
> the size of "adf7242-" that is already in the array.
> 
> In order to fix it, use snprintf() instead.
> 
> Fixes: 7302b9d90117 ("ieee802154/adf7242: Driver for ADF7242 MAC
> IEEE802154")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

>  drivers/net/ieee802154/adf7242.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ieee802154/adf7242.c
> b/drivers/net/ieee802154/adf7242.c
> index a03490ba2e5b..cc7ddc40020f 100644
> --- a/drivers/net/ieee802154/adf7242.c
> +++ b/drivers/net/ieee802154/adf7242.c
> @@ -1162,9 +1162,10 @@ static int adf7242_stats_show(struct seq_file *file,
> void *offset)
> 
>  static void adf7242_debugfs_init(struct adf7242_local *lp)  {
> -	char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "adf7242-";
> +	char debugfs_dir_name[DNAME_INLINE_LEN + 1];
> 
> -	strncat(debugfs_dir_name, dev_name(&lp->spi->dev),
> DNAME_INLINE_LEN);
> +	snprintf(debugfs_dir_name, sizeof(debugfs_dir_name),
> +		 "adf7242-%s", dev_name(&lp->spi->dev));
> 
>  	lp->debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL);
> 
> --
> 2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-23  6:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-21 18:03 [PATCH net] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show() Christophe JAILLET
2023-10-22 10:30 ` patchwork-bot+netdevbpf
2023-10-23  6:24 ` Hennerich, Michael

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).