From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 83DAE3FE4A for ; Sat, 18 May 2024 18:06:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716055592; cv=none; b=nn8eW726qDBgk1lR1Dzswblv0ujjSZpiQJMHwBpRReACbWFiGtAV8WF1m+XUbtG6OO05d3iYH+G253fym51hkOpedpT1mgE5gdcYed/AZdl0ZU24KHTtyqvkapA8LopL24T6ruLCC7+ZIqamyrzMwJ+7AaauDmbpPDyllxkBSYQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716055592; c=relaxed/simple; bh=SFtO3a4RKrkjrGHguXWwcDovKIMDazuVdb4cBPkaPTE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uRtW+vkSW1+UlPzWy8dp2n05Zc6QP0ml/Qqe6JuaQ1p0hxuded9El8SOSZHmbFv5/HUBhAIldpZIWTptDkZXbGLMLMAcEoPFy+Q+VQ8lWA1dPPTVOU2pI6BAu9vgluZzhLExVlqfPzvYe05tjGe52EtySKJaQA5bclvovqt9D2U= 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=dypsSydO; arc=none smtp.client-ip=209.85.210.176 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dypsSydO" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6f4603237e0so838345b3a.0 for ; Sat, 18 May 2024 11:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1716055589; x=1716660389; 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=eNjtPFN4gwk8FY4XhBI0pqmWHSzhdefGp6JGYF0RnSc=; b=dypsSydO/wW0nk8lSSROpX0nlTLl0hYxzIVWa8PD8KvF6CVya4v2vQHt83QgCCv467 JkY4vrQDAuV7qZqFnkdZ2tV3gi0zz9HT7PvzNoRTUjKMC3PZyvH1KeAyHjebPDfSRxOo z8KZic9m1yBDUulQ1evYi6/Rj9ab2ow+Yxt0s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716055589; x=1716660389; 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=eNjtPFN4gwk8FY4XhBI0pqmWHSzhdefGp6JGYF0RnSc=; b=Ks6aabzIKc1W8CusM5dpd86U7xRAr+0xXpwXOcLBUomdVVzJtxmGu5RpS4OwA4feue DLc9Nc61wvxIBuOVPyYu9YO9X2qdNQQSdPfp88IH1SwQVf1XqFRQ4P13cEmASwfVcwkg lqIj97LaCKLa40mM0o1eSPiI3/EIrAaIXfbUjIiACgWYAT8xlhz7SCMrR8+nVUWXqlvC cQ3PIFdFNIMUnD+w5wggMWi59fd2QXNMvWR0BX6XuWKeykKS+lhobaIlVMu2qMTwDsug lQ4xlsUt/anSktkUAKmBRJgcsLIg1iEAxOEPr7vxL8NH42J6pwmx2dOlgl0WbHiugCDZ 9nuQ== X-Forwarded-Encrypted: i=1; AJvYcCV5c5nolr8HlHvS6zZV3MMxN7IyNONxKVCeC5g3+p7y70N0DhJnzTVX0Jw1GmYTtVePsLI3CZ4XgyCcCG5rGXowj3SGFVP23nQhHb6e X-Gm-Message-State: AOJu0YyG34ZGeNdMz+o4LotKuhXHizwN2ARmmuRuMRfHqCvt8XfNTKHA yrvRx9MU43PrMB8zc/8d6xBQWlWf4VwByq1bE3cVfOYWU6GJj/Jb2lhKce5ZmQ== X-Google-Smtp-Source: AGHT+IHKKqnL3U4K71hLrs2mUP7g9TMCITdHz9CzBkr4YA8T0fm3oAZPwvplNN097FJEGyMYNzbtLA== X-Received: by 2002:a05:6a00:17a7:b0:6f6:7c56:e989 with SMTP id d2e1a72fcca58-6f69fb7d5d7mr3783518b3a.2.1716055588805; Sat, 18 May 2024 11:06:28 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f67a5ffc54sm5978034b3a.34.2024.05.18.11.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 11:06:28 -0700 (PDT) Date: Sat, 18 May 2024 11:06:27 -0700 From: Kees Cook To: Christophe JAILLET Cc: Sumit Semwal , Gustavo Padovan , Christian =?iso-8859-1?Q?K=F6nig?= , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] dma-buf/fence-array: Add flex array to struct dma_fence_array Message-ID: <202405181106.99C0C03BB@keescook> References: 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: On Sat, May 18, 2024 at 07:47:02PM +0200, Christophe JAILLET wrote: > This is an effort to get rid of all multiplications from allocation > functions in order to prevent integer overflows [1][2]. > > The "struct dma_fence_array" can be refactored to add a flex array in order > to have the "callback structures allocated behind the array" be more > explicit. > > Do so: > - makes the code more readable and safer. > - allows using __counted_by() for additional checks > - avoids some pointer arithmetic in dma_fence_array_enable_signaling() > > 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/160 [2] > Signed-off-by: Christophe JAILLET Yes please! :) Reviewed-by: Kees Cook -- Kees Cook