Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1469728lqs; Sat, 15 Jun 2024 10:00:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGx7b5Hwhp81OhKIMGBDQY2KCSfwAi61qxr03+q/Cg4lcYTbpqFLlZAhrv8CSugK0pqNzY9uvgAqNS9PhFtYvw3vb3ydeoNe9dYAlNUA== X-Google-Smtp-Source: AGHT+IFnTTfv9BoGSnxuaLOFb0rb2C9Re4nOdYj0tlNzKAX/boPdMwUhjigcLN0Htu6jSAOhudQB X-Received: by 2002:a50:8d0a:0:b0:57c:6767:e841 with SMTP id 4fb4d7f45d1cf-57cbd69e5aamr4063024a12.13.1718470820174; Sat, 15 Jun 2024 10:00:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718470820; cv=pass; d=google.com; s=arc-20160816; b=fKpZCGzYscPnrW15yt/RF2OrNBibd1r6MLUOwgl0+cXsm0h6XQxh/L37F5pJMnn5Dv /S/SSUFN4Oh5uGQd94sfD0rsTI6sQdasqADsOa1EHVYvh7SfdgADqYlzFbwT5V75x1Yb VkRP4UZfsQWxT7b9y/QUhK8cfTKPnJDXflXZIaFVEl/3ANNopJP61xQf1JcA4DuHwJMw 3dceZfesc+ntVYxI9Y2RQxS6VADOCfQxE93cfrSeRD3h19B/WBHJEtlyoiMnwc6TlQgW RHe5J26y4Qj/alYNY3m2i4ic9aQpwiGL8QW9BHjj4I58+ZbEko6LBYHoDZCgfJ7qv2OG 7kOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=PTZjlzNRSwP9GntpvKn6bnVzhdAKr24YVJ985FiFhsg=; fh=0/K/f/v+1EamAMu/rWU1UnzhGOkrPebnImeBONKXKDg=; b=lm1/DI6OR1EsPFofnbtX7EuuDG6MaqWBA3RZ+R9xYuwLhg9Lk0qiJjgoDlCnuL/ORu pvcwkfXbroCcBURa8Y95J0JrYFp0WmDKAzF1bxz14hxXr7iTk3KFJee7rInJre6mnAMv YdVgKFCziV5jR2EOHwQXxYeaslpNgfb2X0bI00b/qjPpJWW5BYmCgBrpkocGuEM0nsDL 3mwV75vtYcV6eXMOna2jpPSgN6LhSQicImbaIw7JEP3cL/6moc5XHAS8NyFf2moCkTMY XXsODMihtZOPzR1TQI4YOhIfc8ZgmzsyeOlu7bnE5hvElvpSrlB6T5OsVBB2JkoOqS3R 2MNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=hiQOM69u; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-215938-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb744105esi2903014a12.371.2024.06.15.10.00.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jun 2024 10:00:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215938-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=hiQOM69u; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-215938-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DB1F01F22131 for ; Sat, 15 Jun 2024 17:00:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C24A4DA14; Sat, 15 Jun 2024 17:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="hiQOM69u" Received: from smtp.smtpout.orange.fr (smtp-23.smtpout.orange.fr [80.12.242.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C527F2E40E; Sat, 15 Jun 2024 17:00:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718470811; cv=none; b=iEyHceiZL8owXJ7VV+PYCgkGEDcXeI078CS8ZAPAuDCeyw+8NOG+nAoOJHBWFEu41E4TsxuicuJAR88/QGMBKOCbn7uTUDmc2yP37GuxTAdS6QZwRnDXhKPgGSkeu21Fcd/VN01tNFfza9Vo/kJWmblLXuTO4vx5fkEkn02ZUJE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718470811; c=relaxed/simple; bh=qPF1/OwfQhKdvkx3zxh32aqPDUxcsGhv8/DRvBq/Z8A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ULyBZ0PtOxGtzcH/5bGXtfLQCXkjf5hnFXkz1UVgGR59Qr8tL/iEGPY+mlKXJLL2UoAQZw1bGGpg4fSshCpyZmkSRDSgOF2rUh/Pxsuf0ByMmOMU+M4WAAlPlKZLmqDnQMMHtqe5p7yCWE+30TU9ukmCS5pmfNnkQvpHDfPMJ9U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=hiQOM69u; arc=none smtp.client-ip=80.12.242.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from [192.168.1.37] ([86.243.222.230]) by smtp.orange.fr with ESMTPA id INU5s0lg7j7S3INU5s5aIM; Sat, 15 Jun 2024 09:05:58 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1718435158; bh=PTZjlzNRSwP9GntpvKn6bnVzhdAKr24YVJ985FiFhsg=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=hiQOM69uCw/4OOKrtOqV2oIo8U6AdvxY7BuahOK40hMk/5CITfzQutK1lzLjBsj8K DwE94Gehm/4ieAwlJYcJpisB1VSrJgBcg3bIgU8H9xlBTsNNddaoBsYZ9jT0plJT2s 2tgNiVCAYfv8S5OM4bBG46YwASXZ+7v5OeqmNCF0SFyTcGMMNQguewxWxadNTc9+rH C3gC/DycKNTYATsBdGzyALAPH8di6KGLminlk8I7PXapHzYjq8ntvoAMCDQDbg1FN+ L66sz0S4W1AIDkFCbTr2yVm86kbhoxo9RsYFfwtr/gSSVM3VExyB/ieF12LFFxu1mU lWT7k4FnAHuZg== X-ME-Helo: [192.168.1.37] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 15 Jun 2024 09:05:58 +0200 X-ME-IP: 86.243.222.230 Message-ID: <3946b327-5e89-43d3-9dc3-10dd10bd41bc@wanadoo.fr> Date: Sat, 15 Jun 2024 09:05:56 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] ptp: fix integer overflow in max_vclocks_store To: Dan Carpenter , Yangbo Lu Cc: Richard Cochran , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: Content-Language: en-MW From: Christophe JAILLET In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 > --- > 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