[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <SN7PR03MB7132B2112186F40E268727D38ED8A@SN7PR03MB7132.namprd03.prod.outlook.com>
Date: Mon, 23 Oct 2023 06:24:16 +0000
From: "Hennerich, Michael" <Michael.Hennerich@...log.com>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>,
"keescook@...omium.org" <keescook@...omium.org>,
Alexander Aring <alex.aring@...il.com>,
Stefan Schmidt <stefan@...enfreihafen.org>,
Miquel Raynal <miquel.raynal@...tlin.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Marcel Holtmann <marcel@...tmann.org>
CC: "linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
Stefan Schmidt <stefan@....samsung.com>,
"linux-wpan@...r.kernel.org" <linux-wpan@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH net] net: ieee802154: adf7242: Fix some potential buffer
overflow in adf7242_stats_show()
> -----Original Message-----
> From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> Sent: Samstag, 21. Oktober 2023 20:04
> To: keescook@...omium.org; Hennerich, Michael
> <Michael.Hennerich@...log.com>; Alexander Aring <alex.aring@...il.com>;
> Stefan Schmidt <stefan@...enfreihafen.org>; Miquel Raynal
> <miquel.raynal@...tlin.com>; David S. Miller <davem@...emloft.net>; Eric
> Dumazet <edumazet@...gle.com>; Jakub Kicinski <kuba@...nel.org>; Paolo
> Abeni <pabeni@...hat.com>; Marcel Holtmann <marcel@...tmann.org>
> Cc: linux-hardening@...r.kernel.org; linux-kernel@...r.kernel.org; kernel-
> janitors@...r.kernel.org; Christophe JAILLET <christophe.jaillet@...adoo.fr>;
> Stefan Schmidt <stefan@....samsung.com>; linux-wpan@...r.kernel.org;
> netdev@...r.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@...adoo.fr>
> ---
Acked-by: Michael Hennerich <michael.hennerich@...log.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
Powered by blists - more mailing lists