From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Dan Carpenter <dan.carpenter@linaro.org>, Yangbo Lu <yangbo.lu@nxp.com>
Cc: Richard Cochran <richardcochran@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net] ptp: fix integer overflow in max_vclocks_store
Date: Sat, 15 Jun 2024 09:05:56 +0200 [thread overview]
Message-ID: <3946b327-5e89-43d3-9dc3-10dd10bd41bc@wanadoo.fr> (raw)
In-Reply-To: <d094ecbe-8b14-45cc-8cd8-f70fdeca55d8@moroto.mountain>
Le 14/06/2024 à 19:31, Dan Carpenter a écrit :
> On 32bit systems, the "4 * max" multiply can overflow. Use size_mul()
> to fix this.
>
> Fixes: 44c494c8e30e ("ptp: track available ptp vclocks information")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/ptp/ptp_sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
> index a15460aaa03b..bc1562fcd6c9 100644
> --- a/drivers/ptp/ptp_sysfs.c
> +++ b/drivers/ptp/ptp_sysfs.c
> @@ -296,7 +296,7 @@ static ssize_t max_vclocks_store(struct device *dev,
> if (max < ptp->n_vclocks)
> goto out;
>
> - size = sizeof(int) * max;
> + size = size_mul(sizeof(int), max);
> vclock_index = kzalloc(size, GFP_KERNEL);
kcalloc() maybe?
> if (!vclock_index) {
> err = -ENOMEM;
Unrelated but, a few lines above, should the:
if (max == ptp->max_vclocks)
return count;
be after:
if (mutex_lock_interruptible(&ptp->n_vclocks_mux))
return -ERESTARTSYS;
as done in n_vclocks_store()?
CJ
next prev parent reply other threads:[~2024-06-15 17:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 17:31 [PATCH net] ptp: fix integer overflow in max_vclocks_store Dan Carpenter
2024-06-15 7:05 ` Christophe JAILLET [this message]
2024-06-17 6:01 ` Dan Carpenter
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=3946b327-5e89-43d3-9dc3-10dd10bd41bc@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=yangbo.lu@nxp.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox