[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ef479074-966f-142d-2839-f5bb690b5d76@intel.com>
Date: Wed, 18 Oct 2023 22:34:17 +0200
From: Przemek Kitszel <przemyslaw.kitszel@...el.com>
To: Dan Carpenter <dan.carpenter@...aro.org>, Xabier Marquiegui
<reibax@...il.com>
CC: Richard Cochran <richardcochran@...il.com>, "David S. Miller"
<davem@...emloft.net>, <netdev@...r.kernel.org>,
<kernel-janitors@...r.kernel.org>
Subject: Re: [PATCH net-next] ptp: prevent string overflow
On 10/18/23 16:20, Dan Carpenter wrote:
> The ida_alloc_max() function can return up to INT_MAX so this buffer is
> not large enough. Also use snprintf() for extra safety.
>
> Fixes: 403376ddb422 ("ptp: add debugfs interface to see applied channel masks")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> ---
> drivers/ptp/ptp_clock.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> index 2e801cd33220..3d1b0a97301c 100644
> --- a/drivers/ptp/ptp_clock.c
> +++ b/drivers/ptp/ptp_clock.c
> @@ -220,7 +220,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
> struct ptp_clock *ptp;
> struct timestamp_event_queue *queue = NULL;
> int err = 0, index, major = MAJOR(ptp_devt);
> - char debugfsname[8];
> + char debugfsname[16];
> size_t size;
>
> if (info->n_alarm > PTP_MAX_ALARMS)
> @@ -343,7 +343,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
> }
>
> /* Debugfs initialization */
> - sprintf(debugfsname, "ptp%d", ptp->index);
> + snprintf(debugfsname, sizeof(debugfsname), "ptp%d", ptp->index);
> ptp->debugfs_root = debugfs_create_dir(debugfsname, NULL);
>
> return ptp;
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>
Powered by blists - more mailing lists