Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2621702rdb; Mon, 12 Feb 2024 10:31:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVIuhfsQ8HfQhhWCJ23zEFhh+ziPMzS2s5wDOmArbPVAb1o4EuT4gEitRCwOZAhObFX8xovMVcuOIP47yUqCnNdI26ljT+gX9TXyRTn4A== X-Google-Smtp-Source: AGHT+IEc0qt1wn2Jait1zOpluXpJ0RCStld9Fi+AEGYB4TmwtOSjpeS9ZDZybXOOBPd/iqjxTC6q X-Received: by 2002:a17:90a:a013:b0:296:1127:ceca with SMTP id q19-20020a17090aa01300b002961127cecamr4779207pjp.6.1707762681527; Mon, 12 Feb 2024 10:31:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707762681; cv=pass; d=google.com; s=arc-20160816; b=XHlp2mDxJdMcvJ91Hs7DHVSzHoH27wWoPNApObpxdXm7blRLU2QvpHmVH9rrMgQY22 lhq3c8crpzwq9jzNVdyNy9Ft0I+B5mHcy43+a1Aa9M+oyf9FvxHmAUfxmp0JsA4YpwdY arI4FTIDDoMHAGG86cYv5rLzYIk6ySxysvxuaUNZ8h/vdMpeQSWXkRCoQWRrwcuhUzr0 ro+2f+hNaGgT5Hdwzwqv90Lyc3zTeCUqEq/9O2RvKxWcZoEvRTJaQug+L3R9keSS9siz ouhh08DoKLQk9/e6LZBnl/jEQKQDCfXaiCxpkGuBgSHVRhsrtbUnAD/TcMv8+7lExZMc vUsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WxYKfxVc01RvCqlquCukYbiHiXMELvJ7WajMr+fzZiM=; fh=zTKL5w7lwxyhG9WNxvk1QeZMV5pErzr69zBJqV6hCSA=; b=die5tT7aVPdfp0wk8Av6lPhaq9yFDzSG3hN786eOWF9hDCZFP8GA3Din9w8rM5pT56 wp0Zm3klO27dKVrU/wdCJfRvu+7kALPOPrGTt3m2gT0GUpYrB8/vun1KjFfa0k0R7qI7 wD7pEEhAQWjke6P3DV3wgZVbZk4m2xYOT3u5PRA/n0yMO/fzYcl2xBmhJd4vtWtrDtR9 VfQOZCHke4tlL6hMYsr12ZkA+eioV3uXFt93YCpc3ZESQ4aN+NhJwDpKYhN03OPw7tQ/ GhCwBoUm4+vZw/rkeHUUATDdIHYZMpVz081pacgwvZDKD0w8gI9SWKkA2JbKTL5o09Wv 8IrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="D/hV02gh"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-62184-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62184-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCWY7aBRuoZtHWTniTkXMDpbjfWatJPrj327zhL5aB+yupbuAk7fOlnkGt28UyU9cQVl3is5qC6J16xEnEXL5d441tZWPTSFmNHKNcuE+A== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id nn8-20020a17090b38c800b0029767908114si626479pjb.49.2024.02.12.10.31.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 10:31:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62184-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="D/hV02gh"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-62184-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62184-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2BA622817AE for ; Mon, 12 Feb 2024 18:31:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C8FC405DF; Mon, 12 Feb 2024 18:31:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="D/hV02gh" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 F2F2C45BEC for ; Mon, 12 Feb 2024 18:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707762674; cv=none; b=rRlRh9TtlR/j/9oc9QpcnCR/gbcEbLUekOW7P/W0va0JoCr18yLJcG4A920h3XVx4eXbQd0nVb5mNm+uG5Bx0zfg9I09KpuHb2l6F/Yox4r556g4Lnnp6hzrKWtzkbSAvWu73I6yfNSoL8JjiAtLQdDBQAWYZ05KcGokBwLl9Oo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707762674; c=relaxed/simple; bh=Vi6c5axLczsjAfZ/jdvV6TZrVwfcoDXEpjFAYHPKp3c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Xa6o/woY8jESl4sFBERodWcp5wZZBrIkQMqFotHpXbqkPHS1tclcmBiHBt+zbcXRAIRthIIJn+mTG67L2vq50CJTSSfQcUes0LOCX/A2I76VVKKIvZRIpq0CWfvmfflzfAcZi2P84+QT2mP8ImXQrnXLWedA+WKfg53V2dPr8Ag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=D/hV02gh; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1d953fa3286so27313025ad.2 for ; Mon, 12 Feb 2024 10:31:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707762672; x=1708367472; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=WxYKfxVc01RvCqlquCukYbiHiXMELvJ7WajMr+fzZiM=; b=D/hV02ghUOW7InC8DBjnupW8sppG3rdPN97stTmQ+RJrVoAlwtCby26PXszVlz6gMN IQ/2x0kHiBbshyjEyJHdyWlay+FMLpZIFVVU5XGxS4Pzcf9dLeVWvjDKtKOpt/ix07x8 4eD816rufukq9CNHbq4IUZRxgRy/vyHL/Z8jA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707762672; x=1708367472; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WxYKfxVc01RvCqlquCukYbiHiXMELvJ7WajMr+fzZiM=; b=n7gXiqe8A7mlm8Rz/DDDTeZIch6fHbKBf6Mlyzu4vqRtCbZlVlvBTsCa9dP7R2AJ5B cYiH/uaNL290TruoOlOOW8+ZRdhByqGkvHu9iGE9VbWRMLoxJSMTJaF6L9OnnKirPhl/ /TT+qyZeBkbYkgSfBwalw1oiQI7qnSjORwvBljVTil607v4vAJVHUhJGJKZNw7wR1VV7 BtmavDarUDmXZMgpQ6kFjrrPy+DAVFxL6FrUhV0RbRsvd6znOn4gcICrL9vHQYZOQh6G opW1aNyPLNSbigtD8xt0VqKXeWbXQBH6Ml098ZqKLQOXhKHdsvJ+i9176XrAJtLIdN+9 89og== X-Forwarded-Encrypted: i=1; AJvYcCX5A7o2p4L1DXDo9KUiLZopm2k3t37BgM8VECs/6HvfxOLUN553FxWlF+nf4OsV2Pim+Jh/ggHmorgDtyY857bjs59QWoK3ZuV2Liq7 X-Gm-Message-State: AOJu0YyhofsriR9Xg9chdoaMaUL0+GVv6KWG0QY5OWovmctKWYcJvUe9 8l01m7OeJHoT2aq/yHrca2AoPHiMZCgciZfsCfGuzA/wdFUTciv8Es7pw4W08lJoc/Qm9XQsK/E = X-Received: by 2002:a17:902:fc46:b0:1db:28b4:4475 with SMTP id me6-20020a170902fc4600b001db28b44475mr1656842plb.9.1707762672359; Mon, 12 Feb 2024 10:31:12 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUtqiIrorFvqjkApbF3idZ0NNZ5ryhVf4jv0lvSRs8BQcLjw0NMWxaEQu8LPuqrHMfyobiwwul93Aab5pCDYkBrY9W3bg2i7mqlQcoAFQQyYmGUTas1LBvaN0eXhGp9H8cMyHhB2/Q3mp7GKvlkANpIW9Wsyj84t7uczus2LAnei8WalXriCMZ7LUDrnMYTV9IHk/9NA5/PiUoWn60yClB2etHXG0QPKoMNUOUSMw4PXsAhnJztLYYRnfzHD0wF74cnM93rATXrgJcTQSYTLZO6vb+CIVa6/29VJsTH2F0UCAA90uUT8BRGcKcK504= Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f7cc00b001d8924d8dbfsm644712plw.265.2024.02.12.10.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 10:31:11 -0800 (PST) Date: Mon, 12 Feb 2024 10:31:11 -0800 From: Kees Cook To: Erick Archer Cc: David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , "Gustavo A. R. Silva" , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] iommu/vt-d: Use kcalloc() instead of kzalloc() Message-ID: <202402121031.4649560C1@keescook> References: <20240211175143.9229-1-erick.archer@gmx.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240211175143.9229-1-erick.archer@gmx.com> On Sun, Feb 11, 2024 at 06:51:43PM +0100, Erick Archer wrote: > This is an effort to get rid of all multiplications from allocation > functions in order to prevent integer overflows [1]. > > Here the multiplication is obviously safe because DMAR_LATENCY_NUM > is the number of latency types defined in the "latency_type" enum. > > enum latency_type { > DMAR_LATENCY_INV_IOTLB = 0, > DMAR_LATENCY_INV_DEVTLB, > DMAR_LATENCY_INV_IEC, > DMAR_LATENCY_PRQ, > DMAR_LATENCY_NUM > }; > > However, using kcalloc() is more appropriate [2] and improves > readability. This patch has no effect on runtime behavior. > > Link: https://github.com/KSPP/linux/issues/162 [1] > Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [2] > Signed-off-by: Erick Archer Looks reasonable. Reviewed-by: Kees Cook -- Kees Cook