Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1357178pxb; Fri, 21 Jan 2022 16:24:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBP3YuoDYDvMD9LkZCO2wAWhenJ0TwEOCpWCe2eIeXpyhCPjQTEMDI+2ikGQcIjfTObEV1 X-Received: by 2002:a63:2210:: with SMTP id i16mr4549938pgi.532.1642811067601; Fri, 21 Jan 2022 16:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642811067; cv=none; d=google.com; s=arc-20160816; b=AxCuyYiaKiFZifPljFcme8J0hsnE3Q5kUJ8IPMwh4gVta7qbjl3sUzVe5e21CUvBH3 23nTbeaXpNBUP9MH9QXtTsPYn/X2Wh77B+lOK2pmo0Atbs0ML78b3G9qMYrEwjwS/RLZ heRPAzzQGmXNnMhpLc1H+/TkefZd2qPsX1GI2q9pqwVcbSab7PX7Obot3ehhxxIKRLTt P5T4VjXOEflooF616MEN513iPvqFDcTnIthCwkedA+HLXr5pAWZejFyJ8XEBav2W9sNr m+l1COM9BvvIUMki/66Y4uV9Ft0mfPsmC7JmfbRf23Bp/3Yrl7lzXUkb25xhrGObum1L YnKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=W8u4xvb9YGTbkR+XB2tficjJLp06bXV9VHY3GrFF5AU=; b=zGH2+UJDlsDXQ4uzcRj7urmNEO1ERIZGyG4/5MV/g0vCppIkokAReMgV6K3OV4W2sS Fr6ibr+prMdcp/wpFjM7ad8ateORIbYEg56V0C1TxEth//UjUCb65zQaPv5l8bfqFzBX hR/3GWFHsIRuKslU5COmBqVVhf/ca5p5x3eDGmiO7fYOVifF/UzG/arJrFnerO6ME1vl h5AHYqt51PRw2tccQCgXZMOu/BkGWfUZyo0aeO36M7a9uCOTIi1imyqiBQkM/C4NHyH9 LTeMsPPBJy9QplWNhs5tPKxn259jo8mz2WH6HSttbACdZMwKTmwgnECq4YBPNz+xLIz8 0hTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kjnvRURd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si6644492plo.73.2022.01.21.16.24.16; Fri, 21 Jan 2022 16:24:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kjnvRURd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348091AbiATXeE (ORCPT + 99 others); Thu, 20 Jan 2022 18:34:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbiATXeD (ORCPT ); Thu, 20 Jan 2022 18:34:03 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3DF5C06173F for ; Thu, 20 Jan 2022 15:34:03 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id u11so6762591plh.13 for ; Thu, 20 Jan 2022 15:34:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=W8u4xvb9YGTbkR+XB2tficjJLp06bXV9VHY3GrFF5AU=; b=kjnvRURd0d5x4xaHgLsQrLQFFTt+6yuhoqo3w1AgYdyRqMIxqjqTk1Abi+NnFy1KoR 2S/bTBbPiE9z6gFVosCCBEaPqyADyS2hQbiyxp7FMquiOAB+5EulTVKKnC8kTYEy/OuS 8YIa2ev/7/gxr61vJa9wq41lGpWwuDmLHruro= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=W8u4xvb9YGTbkR+XB2tficjJLp06bXV9VHY3GrFF5AU=; b=qhwTefzpxHNty+iDpClyP0sbxrh5omt1f173VcZ4ZdYEbfVPAvFdK4+Y48VnQ+99XP l7cvOYqKj3iB06+jrC5CKCRjCAO4yApBTa96XLtyI/nVfIrktpgj2oMIHM5ogy68CPdz 6fctWjxhROkF5rMQM4GofdNCxI2o8e+jplqrBcEvQgd5GINbTa8UUgrOmTnMnMK2C7jM RphROjvzteaqaS/Fnzr2yesRjLMxuGP1S745I00ryyQ5gZPEFndD0cDRNcqw0oLvwuta zyZ9j9tBoYPPlPc5GGHbm0Vp1wunzsEyZY2JVftqKxYrtft4Z2LdB5myc1qjU/yKjwkC TlvA== X-Gm-Message-State: AOAM533VzVvLJov8O0WzVR12tVDBQe7atfCwPYL4ATT3LH65GqfKdWUe PjzLwjWslc2KtlLioo35b3fFdA== X-Received: by 2002:a17:90a:4305:: with SMTP id q5mr13751808pjg.222.1642721643308; Thu, 20 Jan 2022 15:34:03 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q6sm3168035pgb.85.2022.01.20.15.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 15:34:03 -0800 (PST) Date: Thu, 20 Jan 2022 15:34:02 -0800 From: Kees Cook To: "Gustavo A. R. Silva" Cc: Jon Mason , Dave Jiang , Allen Hubbe , linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] NTB/msi: Use struct_size() helper in devm_kzalloc() Message-ID: <202201201533.975AD386E@keescook> References: <20220120230247.GA40182@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220120230247.GA40182@embeddedor> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022 at 05:02:47PM -0600, Gustavo A. R. Silva wrote: > Make use of the struct_size() helper instead of an open-coded version, > in order to avoid any potential type mistakes or integer overflows that, > in the worst scenario, could lead to heap overflows. > > Also, address the following sparse warnings: > drivers/ntb/msi.c:46:23: warning: using sizeof on a flexible structure > > Link: https://github.com/KSPP/linux/issues/174 > Signed-off-by: Gustavo A. R. Silva Heh, the variable was even named struct_size. ;) Reviewed-by: Kees Cook -- Kees Cook