Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1268692rdb; Fri, 9 Feb 2024 16:26:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVAaJE/Lu7y28TRiZQTnkcTk0aiyEqAFjPNa3wKfadBggy/6vkk+UGaOknEl+0ikIuLjrf3vZ/5ODdkcxNYEMUSJCjP0mfWIRRVT22kBA== X-Google-Smtp-Source: AGHT+IF7pFcgNYmvmk25dIrk7iCVi61D2fDDEsjWrWMf8yW5jSCqaTYHj3YMdgK1fegvpbor+xRc X-Received: by 2002:a17:906:af10:b0:a3c:b14:32e with SMTP id lx16-20020a170906af1000b00a3c0b14032emr395935ejb.47.1707524809260; Fri, 09 Feb 2024 16:26:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707524809; cv=pass; d=google.com; s=arc-20160816; b=TpK81YizIvmO/ptKgXBmxd9ImD4L10ST+PF/iu/BUZjJyK8fTamf84Hqv6SdNB0FDr OYjkLhBj03dkYxpA1hM6VfavmiNJLIq9zbXB4EDGCshBkSjPHHpXq194yFCReyOZGwq2 YpyRG2ac3FF5My3prZwvZ4j1tMwWPG8DDL7WrhHPEq2+gmY3kCll1+IqFUFk1VMPdgkL HC3qR0jFthr2X+lxQn6JXQ+pfI1Ssu5mKCZPIsX+stz32s9KP+qAJ7UK6YzljU+sANzs TEKzjZZhee/vD9zO1PPcONG98O2hRYRpwejjb7+JfIRcS3V2JLutfR5MCLP7Itx3lyFk KUeQ== 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=wpUjtDpALKnkVEQ80qom9sdufdRNVtjYZoE0nb9Fp9w=; fh=rVsYcAShfquZ5FiysVg6XlStsVnMZcBoT5qcN2CgZGE=; b=RkpGLivWeZjav5c6fRtakZh4SYycbc073HBCOn/snS459B7lnLJ4xhvuVbawqtafrh MIaG/51pvCHAemSpbR4lqf+w8aYWxylYaAk5ExIPcPtv5hqrodkhcb9cD3W3v9aIDfSD qUjde5QuRTyuVIoS1YPaZomUMjTv9eLj8hII4APc3bk8pz83G0jyIzs1tw0N5HypPUQj 8fk/iN7uMPFttSXXRolH7M+nrYloQeWv2a4X06XkhbA/J1mpUg1ASLKVmVehDs4+x/FA lmS6DzLaLJoZRRSxM6T4UaiFLEwobIBcKFi34N4UhXR30oMqNU320aY2EmW3lj8DIkSl Eybw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UYrDWC6t; 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-60174-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60174-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; AJvYcCV46prRjTBPETp6AXrcufH8GBALMmVKlTOUEoZ6VYa863FUcTR3K/OO318Cw6ynhlr1qZsePhycZzn2h8EmKi9tx08w5QAvZEkGFqw/vw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id wr15-20020a170907700f00b00a388c7ea180si1332697ejb.604.2024.02.09.16.26.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 16:26:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60174-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UYrDWC6t; 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-60174-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60174-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E58C81F28300 for ; Sat, 10 Feb 2024 00:19:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A5BB139F; Sat, 10 Feb 2024 00:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="UYrDWC6t" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 D13AB37A for ; Sat, 10 Feb 2024 00:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707524357; cv=none; b=RyV4U4YlyeS5Ll5FKGTAnnJXM/DrBvrhAA88EAffQTyw+ubCsnEc60ay/tPANSD7sFTuKGVscfPBQEKI9ugrva7mMD7FBc8s+oUtaMlBoVUFtMK93NazDgsDiyzSHJLPceXb4JVirv6R4DfQKWZ9Hqmg52JDXsx79az3/4whu94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707524357; c=relaxed/simple; bh=iq6fpzNvbrNJsO1zqHNpHfgJclfdwgHoVjvfJjXyk8Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LgM8Yz8sjLSc+bl1BHTnW1GtYofwA29F+4vnxJWJ3Ob5R8pOS7v3ideLuZP3Z0ExsUzF1+GPUTbbKBSnn+6Pe7xfrYcBNGWkkbmh58ZxBzGDZqgfHtYq/SfiwJwu3QnuB+u59MtIsLz2IDghUhWoZ4d9f0B05MQytDlxGXDLdNU= 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=UYrDWC6t; arc=none smtp.client-ip=209.85.214.169 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-f169.google.com with SMTP id d9443c01a7336-1d94323d547so14166265ad.3 for ; Fri, 09 Feb 2024 16:19:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707524355; x=1708129155; 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=wpUjtDpALKnkVEQ80qom9sdufdRNVtjYZoE0nb9Fp9w=; b=UYrDWC6tIM7omHrmRTTJsCJUa2c/XicRE2tzQ2uRVBXOTu8734asInWDCqR6lE2Sa3 CKUP+cdHX/SJx07MjXMaAySBfBEuR/GxyvhN//kdaqOv9tEXH8aqdbTIHLBc0lrvZn0v UrD0j8OqRmniFiHZBdtPxlPvWo+G5pGJ4P13Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707524355; x=1708129155; 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=wpUjtDpALKnkVEQ80qom9sdufdRNVtjYZoE0nb9Fp9w=; b=c0AMmgMt+Ct0QneA817Jxlq+642eR+dXp/02vyttiPnrG3AEEC5pHnWIm1baRY3DD0 7NwHzPIzoS1bo/EqNbDHKwcEFQhdKi2cIeBRsrdWbwEPHdX9++1KBAcHHAgvaKys+TEH DCrbQHbHKQt4RwxPd0fbo8t2/poyDFQrc7iMLpOxfkluOp/HyjNyWUQWLasaZBFpcJy0 XkQconHHiX0mivErKAr7bIohQjuHnjqPlodzQjsO5R9+xZOiaDUNA1Wh7RNtcqOS4xOy YgZqF4YC8IlnQhTY7gVCJjqelRFIiAFT1Ye+Zt0BlUSRrcPiNNoNkOgzfqMfqvO/xNAj yYGg== X-Forwarded-Encrypted: i=1; AJvYcCWsk51HzMXSMgPS9wODeL70bhuO/koYER1leMJhT7heLAuzxCSht/ZaAXVMdxtpHQZvJTq0Wul57Bga5nHVy4UZUwQQydqXYgQSGe/G X-Gm-Message-State: AOJu0YxU8JxLN6zdJpRTS5QiXFJiKRe9zQA8uwOA0XDQuVygymKnEmuX B7yhHNj9ctBwJ/1MBAvEqJdIcs7oupEXegxoDPp7wsuZnGVI/HKPFiIGfcXlRQ== X-Received: by 2002:a17:903:28e:b0:1d9:c0a0:b3c8 with SMTP id j14-20020a170903028e00b001d9c0a0b3c8mr1269965plr.17.1707524355084; Fri, 09 Feb 2024 16:19:15 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVWzJB3vM8kE82tscM0uXjwXFtLiuKgEcIbJeO/MfXudqoMVv4GPR4GutCMGagbghF3TM43L91pHWQJS0YbZ/USWxr4nMQdu0MHtSxprge0pe8hl7WtjsO+43KuUT3djqjHrBDavO1+OJZWU1QI2x/1JnJ7rWWr2Js/rTMw7+TfobFYaR2TUmrWW18msicFvg8bVxr92aNyEcu6ygqKoN5u9hsvGkwkax6dLEdx7HSj6H2a9G4Xr1hbxbLP+mC/QntrZNQsFcDIpyOSQ+mNfk6uvOZyU8Sb5zuncks= Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id m2-20020a1709026bc200b001d958f8ab2bsm2043788plt.107.2024.02.09.16.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 16:19:14 -0800 (PST) Date: Fri, 9 Feb 2024 16:19:14 -0800 From: Kees Cook To: Erick Archer Cc: Florian Fainelli , Thomas Gleixner , "Gustavo A. R. Silva" , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Broadcom internal kernel review list , linux-hardening@vger.kernel.org Subject: Re: [PATCH] irqchip/bcm-6345-l1: Prefer struct_size over open coded arithmetic Message-ID: <202402091619.80D0AE3141@keescook> References: <20240209181600.9472-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: <20240209181600.9472-1-erick.archer@gmx.com> On Fri, Feb 09, 2024 at 07:16:00PM +0100, Erick Archer wrote: > This is an effort to get rid of all multiplications from allocation > functions in order to prevent integer overflows [1]. > > As the cpu variable is a pointer to "struct bcm6345_l1_cpu" and this > structure ends in a flexible array: > > struct bcm6345_l1_cpu { > [...] > u32 enable_cache[]; > }; > > the preferred way in the kernel is to use the struct_size() helper to > do the arithmetic instead of the argument "size + count * size" in the > kzalloc() function. > > This way, the code is more readable and more safer. > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] > Link: https://github.com/KSPP/linux/issues/162 [2] > Signed-off-by: Erick Archer Thanks! Reviewed-by: Kees Cook -- Kees Cook