From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 776E0CE7AB1 for ; Mon, 25 Sep 2023 17:56:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A3F210E2C7; Mon, 25 Sep 2023 17:56:38 +0000 (UTC) Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CB1F10E2D1 for ; Mon, 25 Sep 2023 17:52:35 +0000 (UTC) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-692d2e8c003so2266960b3a.1 for ; Mon, 25 Sep 2023 10:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695664354; x=1696269154; darn=lists.freedesktop.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=YKkjlOQ/GPkFrKX9bDbfTnpErQ+3hoiSxDUiC5xM1v4=; b=Zx9EOJoFakMF01iDmiiBJU3OKNrHMNZc6sdu4a0rP1ezIwvbox1l8o7h+tO9gyJ51E UtN50x6uW7ap6dfZHIuWMSEM6bVyzEYHOGx6HD84u8ASZe02aX/MqHkddM1Qe+5qYZVD 7hrd6RQq3npCI+u6eDBFZ4UvASsEDSxjwGAKo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695664354; x=1696269154; h=in-reply-to:content-transfer-encoding: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=YKkjlOQ/GPkFrKX9bDbfTnpErQ+3hoiSxDUiC5xM1v4=; b=deH2Az8l2CDIhNjQtYh9vI8Lovj07LqQHmMjXTxZIpoRE/qZ5bmiYlQoUzB9Hb0uX7 7Kjx7ZQt1+mkvMumUJKigdshe9ZBP0vzxHP3T+0///i1WIZeZPN/NLiHzALispFR7Qbm RYTW7MjoogW9n6srIArVWo3HCi/Kxy2OHkoJDC8XUVFCJ2q9LqEWbSSFvqstTp81U89Q FCupdc3Gzb3BcaFmgMacwKJ/rNk/RanWIAcax6LinNFyHI1zEC3m5xFuYV3Y5qKEglBx lZ6c+/EFMj+AA2+nlnwGsFRs6zuszi+xNuyY7Lem/ufl/JqSxGg9TOni5YQpFjfpwCwp nQQw== X-Gm-Message-State: AOJu0YxJylXiU1HngdQxMr9wZo5b0P12aJDJXn0qB7Ju7dTDZtoA2fOV 7TBms07gt8CaQ4xwHXrT97Ow5Q== X-Google-Smtp-Source: AGHT+IGbOeCWSbVNrAKbhj9D9vKUNI/wwQgYtn6Pn0L0F9XDlvUNhyZJFZGUIjA69DGrRpph9k1vJQ== X-Received: by 2002:a05:6a20:3ca6:b0:13e:90aa:8c8b with SMTP id b38-20020a056a203ca600b0013e90aa8c8bmr576006pzj.4.1695664354536; Mon, 25 Sep 2023 10:52:34 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id h19-20020a633853000000b0057c3b21c01dsm6967245pgn.49.2023.09.25.10.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 10:52:33 -0700 (PDT) Date: Mon, 25 Sep 2023 10:52:33 -0700 From: Kees Cook To: Christian =?iso-8859-1?Q?K=F6nig?= Subject: Re: [PATCH 1/9] drm/amd/pm: Annotate struct smu10_voltage_dependency_table with __counted_by Message-ID: <202309251051.EE3ECE7B@keescook> References: <20230922173110.work.084-kees@kernel.org> <20230922173216.3823169-1-keescook@chromium.org> <2635922e-f52a-4e91-40c6-4f1358972786@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2635922e-f52a-4e91-40c6-4f1358972786@amd.com> X-Mailman-Approved-At: Mon, 25 Sep 2023 17:56:36 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Pan, Xinhui" , Karol Herbst , Tom Rix , llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , Gerd Hoffmann , Andrzej Hajda , Marijn Suijten , David Airlie , Matthew Brost , Evan Quan , Emma Anholt , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , VMware Graphics Reviewers , Ben Skeggs , Andi Shyti , nouveau@lists.freedesktop.org, David Airlie , Alex Deucher , Lijo Lazar , Yifan Zhang , linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Maxime Ripard , Tvrtko Ursulin , Nathan Chancellor , Dmitry Baryshkov , Gurchetan Singh , Rodrigo Vivi , virtualization@lists.linux-foundation.org, Sean Paul , Neil Armstrong , Xiaojian Du , Le Ma , Lang Yu , Bjorn Andersson , Tejas Upadhyay , Nick Desaulniers , linux-kernel@vger.kernel.org, Hawking Zhang , Melissa Wen , Alex Deucher , Nirmoy Das , freedreno@lists.freedesktop.org, John Harrison , linux-hardening@vger.kernel.org Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" On Mon, Sep 25, 2023 at 08:30:30AM +0200, Christian König wrote: > Am 22.09.23 um 19:41 schrieb Alex Deucher: > > On Fri, Sep 22, 2023 at 1:32 PM Kees Cook wrote: > > > Prepare for the coming implementation by GCC and Clang of the __counted_by > > > attribute. Flexible array members annotated with __counted_by can have > > > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > > > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > > > functions). > > > > > > As found with Coccinelle[1], add __counted_by for struct smu10_voltage_dependency_table. > > > > > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > > > > > Cc: Evan Quan > > > Cc: Alex Deucher > > > Cc: "Christian König" > > > Cc: "Pan, Xinhui" > > > Cc: David Airlie > > > Cc: Daniel Vetter > > > Cc: Xiaojian Du > > > Cc: Huang Rui > > > Cc: Kevin Wang > > > Cc: amd-gfx@lists.freedesktop.org > > > Cc: dri-devel@lists.freedesktop.org > > > Signed-off-by: Kees Cook > > Acked-by: Alex Deucher > > Mhm, I'm not sure if this is a good idea. That is a structure filled in by > the firmware, isn't it? > > That would imply that we might need to byte swap count before it is > checkable. The script found this instance because of this: static int smu10_get_clock_voltage_dependency_table(struct pp_hwmgr *hwmgr, struct smu10_voltage_dependency_table **pptable, uint32_t num_entry, const DpmClock_t *pclk_dependency_table) { uint32_t i; struct smu10_voltage_dependency_table *ptable; ptable = kzalloc(struct_size(ptable, entries, num_entry), GFP_KERNEL); if (NULL == ptable) return -ENOMEM; ptable->count = num_entry; So the implication is that it's native byte order... but you tell me! I certainly don't want this annotation if it's going to break stuff. :) -- Kees Cook