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 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 6B179CE7AB1 for ; Mon, 25 Sep 2023 17:52:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 965D610E2BF; Mon, 25 Sep 2023 17:52:37 +0000 (UTC) Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by gabe.freedesktop.org (Postfix) with ESMTPS id F3FF710E2CE for ; Mon, 25 Sep 2023 17:52:34 +0000 (UTC) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-690b7cb71aeso5192107b3a.0 for ; Mon, 25 Sep 2023 10:52:34 -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=nXzCK8c8b06+9+5P03DheBH6Y3VTPL27PwSQ1Gy2JHEAzbMTCRqyyMmnTTH1l6oJ4d RzlEWzy7XxBEo0e0wmNpFjQGrQZV7RGWaNLF4t+b1U0daghCU2i8JoN85gP33pqF8yW7 +UCZchCUCfIS932eLx0/JKGqwBsvyOETbnO07lRGcuesraXq5rzJyakp8RS2zoHL5hWh NZklz/h4Fpt9rEmOKZCLH9BB4BOwUG/PjRHAnwxI2xDlxsOPwOYsvo0r3P8bnQmGiodY tVKdYYQOAoY3KKuMbaqihHq88CIF2jLtvwNgP/2UaMlH1vf0CVTgsT7O5hDiMJb50xBT Lj4g== X-Gm-Message-State: AOJu0YwdKCpAMpxZZT+t0R++yH/KiNHNu6jAWq6NV6V1Nh+dVWBNoXpU dEpp4ZFDvwhv42XOHKH9tCJAHQ== 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?= 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> Subject: Re: [Intel-gfx] [PATCH 1/9] drm/amd/pm: Annotate struct smu10_voltage_dependency_table with __counted_by X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development 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 , Evan Quan , Emma Anholt , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , VMware Graphics Reviewers , Ben Skeggs , 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 , Nathan Chancellor , Dmitry Baryshkov , Gurchetan Singh , Rodrigo Vivi , virtualization@lists.linux-foundation.org, Neil Armstrong , Xiaojian Du , Le Ma , Lang Yu , Bjorn Andersson , Nick Desaulniers , linux-kernel@vger.kernel.org, Hawking Zhang , Melissa Wen , Alex Deucher , Nirmoy Das , freedreno@lists.freedesktop.org, linux-hardening@vger.kernel.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-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 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82E93CE7AB4 for ; Mon, 25 Sep 2023 17:52:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbjIYRwp (ORCPT ); Mon, 25 Sep 2023 13:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbjIYRwo (ORCPT ); Mon, 25 Sep 2023 13:52:44 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E5A7120 for ; Mon, 25 Sep 2023 10:52:35 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-690d2441b95so5180958b3a.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=vger.kernel.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=M3fRbwNKJs/vD2DbQRvOwnUx2tVgK38v4iSmjDxmw8vepMoxpGzAvG5zM5/YGSVBFm 18wo93lzSHyfC8NkQRSAlkDoSifPfFJT/iqECR1NEX8JA/XkpZLsxbfAA1+v8GeHhaMf T9eoup+Jok6EoLs8xCCJgk9qeMKF1QGtOCTes= 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=WlQWiHijhB85VyvLA+GNi3pP+Y5OgxQgRJLodvhzlF9PuPbSHf5LGUO4clL//YBS5j 4s2+JYQakdp9gdHRGu5YSxK1J5hTQVndtxixyRjeQCSR3xxAj7Wfw2KQhuO6z1rYzGj2 n65s7HClG9Y3WyJBo/J1Q5aBGDBHUqtCgx0hYoDerczo7QOz9NZPNYvQ6Wz2NoP6wZq8 z1FppWe7z5Gbu6E98dkyr1t2I/hrAHZCfp6zH2hWSxsO/1IkqpOCWCwMlhQTGLlHnxoc Re/mUSjEthguQ1S5I4gbuiE47NfZ6IoncmDk2F88B4bOwE7BPqRtn4P5yCv/OOIzxAnx i8Rw== X-Gm-Message-State: AOJu0YyEYrDrNDXTnNtLl20ql3aXq3pJwYZTn4z+aEMmV0Zg6p46E5/g xObchtPdzDIGCdYG3eOi3BeTOg== 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?= Cc: Alex Deucher , David Airlie , Tejas Upadhyay , Emma Anholt , Tom Rix , llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , Gerd Hoffmann , Andrzej Hajda , Marijn Suijten , Matthew Brost , Karol Herbst , Neil Armstrong , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , Nathan Chancellor , VMware Graphics Reviewers , Ben Skeggs , Andi Shyti , nouveau@lists.freedesktop.org, David Airlie , virtualization@lists.linux-foundation.org, linux-hardening@vger.kernel.org, Lijo Lazar , Yifan Zhang , linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Melissa Wen , Dmitry Baryshkov , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , Evan Quan , Sean Paul , Tvrtko Ursulin , Xiaojian Du , Le Ma , freedreno@lists.freedesktop.org, Bjorn Andersson , "Pan, Xinhui" , Nick Desaulniers , linux-kernel@vger.kernel.org, Alex Deucher , Nirmoy Das , Lang Yu , John Harrison , Hawking Zhang 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> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 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 0F656CE7AB2 for ; Mon, 25 Sep 2023 17:52:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C21D10E2D2; Mon, 25 Sep 2023 17:52:36 +0000 (UTC) Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C40510E2D0 for ; Mon, 25 Sep 2023 17:52:35 +0000 (UTC) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-690b7cb71aeso5192116b3a.0 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=krNtgPQB7djp1vF1zcZIgIMjARyh+uL9y1nMeKRFgvgDbQziBTlXHwqTO41oni9bBl N+chxNF53ak/59PytuxNfS5QMHV/Ry+GzA7OMWvf+tzWMklJQZ1Ok5TVzXuwtqwO7oKl 1L0ZVnlgXLukbdDPrQxiwRZgjffRMusQPjTIj5hUFvlVSSJOfIA9t5IT4I2Vj8i5kIuF M7d5r9CDvaQaeIYUIMhD7gvYgMbW4nk3F05GKo5oE1osKGnSyiDUhqG1DCrhah7LbiQB 4h7dXv/hTq0VXYpr5U89FmqU4S0vsghLSb7bp+Wnn0HG2Im+/GtSG/VSULMrkDAXYFV2 qI3g== X-Gm-Message-State: AOJu0YyI04B4ptHxvks4Ffju/IcYCNWxOB2yNsGVlvVGZwLAl7c5OhzT iovhdeUOL4G9lfJSqpKZTyseRw== 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?= 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> Subject: Re: [Nouveau] [PATCH 1/9] drm/amd/pm: Annotate struct smu10_voltage_dependency_table with __counted_by X-BeenThere: nouveau@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Nouveau development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Pan, Xinhui" , Tom Rix , llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , Gerd Hoffmann , Andrzej Hajda , Marijn Suijten , 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: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" 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 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 smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 DED03CE7AB5 for ; Mon, 25 Sep 2023 17:52:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5C0B340195; Mon, 25 Sep 2023 17:52:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5C0B340195 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=kNAxiGvs X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aDR3rOuIsTGf; Mon, 25 Sep 2023 17:52:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 7A08640A87; Mon, 25 Sep 2023 17:52:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 7A08640A87 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4B593C0039; Mon, 25 Sep 2023 17:52:37 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4AC7DC0032 for ; Mon, 25 Sep 2023 17:52:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1F82C6125F for ; Mon, 25 Sep 2023 17:52:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1F82C6125F Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=kNAxiGvs X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ePHToWH_VxvH for ; Mon, 25 Sep 2023 17:52:35 +0000 (UTC) Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by smtp3.osuosl.org (Postfix) with ESMTPS id 31CAC61259 for ; Mon, 25 Sep 2023 17:52:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 31CAC61259 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-690d2441b95so5180961b3a.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.linux-foundation.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=kNAxiGvsuhz+CmYgWGiW3mnPQByY68dPK3P2jXUDL4+fG0povRiPAU1QWgnswAeEx8 16W9EdFiz5teVTiyfKcO+ljr226f/AcZWt130WWKTWnJBbdm3vzNM6pivQuVeqsRHdXY QPY4ZpAeE+gTH+Y49c+WP6z9IPNB3k5+9wwtg= 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=hG7m3Z934L3Iy6eEijxxvsXkJP6bJU842p6TvyA3aMSWvGJVB8cby1hjzkX2KHIwpY DwpkUaVHIBl6caZzkOpmeROjE5bQFCgAjwems9IvKc3DqIQ5DVc1IDdDrK1Ga2QahjEQ xXpOp7ShiNRAVAaRqVjl4cruYLuIFA7tydL77b12QJGjMix9J5WJAwFrUCWiQ3GHPjLf JH8iB7RkQKnp80UFA7BCECHYEA8ak8/8GBQR4TclJNfzZhn8M2URVsx3Re+XSaV6uDTa cUrUQGN4ZDlx4MN9+daJYJg+bZpjPeEh/5hC4FuTEkjywj44nWbloSmXWQWOXCZ29vu+ yuwQ== X-Gm-Message-State: AOJu0Yy9Xuiwra5HeHqE3SaAmieDQN09QEvHPG/CG8HAJbBsLxLpADHZ kbWEKIzuxenRfY1tO2MbQURJ8A== 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-Disposition: inline In-Reply-To: <2635922e-f52a-4e91-40c6-4f1358972786@amd.com> Cc: "Pan, Xinhui" , Karol Herbst , Tom Rix , llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , 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 X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" T24gTW9uLCBTZXAgMjUsIDIwMjMgYXQgMDg6MzA6MzBBTSArMDIwMCwgQ2hyaXN0aWFuIEvDtm5p ZyB3cm90ZToKPiBBbSAyMi4wOS4yMyB1bSAxOTo0MSBzY2hyaWViIEFsZXggRGV1Y2hlcjoKPiA+ IE9uIEZyaSwgU2VwIDIyLCAyMDIzIGF0IDE6MzLigK9QTSBLZWVzIENvb2sgPGtlZXNjb29rQGNo cm9taXVtLm9yZz4gd3JvdGU6Cj4gPiA+IFByZXBhcmUgZm9yIHRoZSBjb21pbmcgaW1wbGVtZW50 YXRpb24gYnkgR0NDIGFuZCBDbGFuZyBvZiB0aGUgX19jb3VudGVkX2J5Cj4gPiA+IGF0dHJpYnV0 ZS4gRmxleGlibGUgYXJyYXkgbWVtYmVycyBhbm5vdGF0ZWQgd2l0aCBfX2NvdW50ZWRfYnkgY2Fu IGhhdmUKPiA+ID4gdGhlaXIgYWNjZXNzZXMgYm91bmRzLWNoZWNrZWQgYXQgcnVuLXRpbWUgY2hl Y2tpbmcgdmlhIENPTkZJR19VQlNBTl9CT1VORFMKPiA+ID4gKGZvciBhcnJheSBpbmRleGluZykg YW5kIENPTkZJR19GT1JUSUZZX1NPVVJDRSAoZm9yIHN0cmNweS9tZW1jcHktZmFtaWx5Cj4gPiA+ IGZ1bmN0aW9ucykuCj4gPiA+IAo+ID4gPiBBcyBmb3VuZCB3aXRoIENvY2NpbmVsbGVbMV0sIGFk ZCBfX2NvdW50ZWRfYnkgZm9yIHN0cnVjdCBzbXUxMF92b2x0YWdlX2RlcGVuZGVuY3lfdGFibGUu Cj4gPiA+IAo+ID4gPiBbMV0gaHR0cHM6Ly9naXRodWIuY29tL2tlZXMva2VybmVsLXRvb2xzL2Js b2IvdHJ1bmsvY29jY2luZWxsZS9leGFtcGxlcy9jb3VudGVkX2J5LmNvY2NpCj4gPiA+IAo+ID4g PiBDYzogRXZhbiBRdWFuIDxldmFuLnF1YW5AYW1kLmNvbT4KPiA+ID4gQ2M6IEFsZXggRGV1Y2hl ciA8YWxleGFuZGVyLmRldWNoZXJAYW1kLmNvbT4KPiA+ID4gQ2M6ICJDaHJpc3RpYW4gS8O2bmln IiA8Y2hyaXN0aWFuLmtvZW5pZ0BhbWQuY29tPgo+ID4gPiBDYzogIlBhbiwgWGluaHVpIiA8WGlu aHVpLlBhbkBhbWQuY29tPgo+ID4gPiBDYzogRGF2aWQgQWlybGllIDxhaXJsaWVkQGdtYWlsLmNv bT4KPiA+ID4gQ2M6IERhbmllbCBWZXR0ZXIgPGRhbmllbEBmZndsbC5jaD4KPiA+ID4gQ2M6IFhp YW9qaWFuIER1IDxYaWFvamlhbi5EdUBhbWQuY29tPgo+ID4gPiBDYzogSHVhbmcgUnVpIDxyYXku aHVhbmdAYW1kLmNvbT4KPiA+ID4gQ2M6IEtldmluIFdhbmcgPGtldmluMS53YW5nQGFtZC5jb20+ Cj4gPiA+IENjOiBhbWQtZ2Z4QGxpc3RzLmZyZWVkZXNrdG9wLm9yZwo+ID4gPiBDYzogZHJpLWRl dmVsQGxpc3RzLmZyZWVkZXNrdG9wLm9yZwo+ID4gPiBTaWduZWQtb2ZmLWJ5OiBLZWVzIENvb2sg PGtlZXNjb29rQGNocm9taXVtLm9yZz4KPiA+IEFja2VkLWJ5OiBBbGV4IERldWNoZXIgPGFsZXhh bmRlci5kZXVjaGVyQGFtZC5jb20+Cj4gCj4gTWhtLCBJJ20gbm90IHN1cmUgaWYgdGhpcyBpcyBh IGdvb2QgaWRlYS4gVGhhdCBpcyBhIHN0cnVjdHVyZSBmaWxsZWQgaW4gYnkKPiB0aGUgZmlybXdh cmUsIGlzbid0IGl0Pwo+IAo+IFRoYXQgd291bGQgaW1wbHkgdGhhdCB3ZSBtaWdodCBuZWVkIHRv IGJ5dGUgc3dhcCBjb3VudCBiZWZvcmUgaXQgaXMKPiBjaGVja2FibGUuCgpUaGUgc2NyaXB0IGZv dW5kIHRoaXMgaW5zdGFuY2UgYmVjYXVzZSBvZiB0aGlzOgoKc3RhdGljIGludCBzbXUxMF9nZXRf Y2xvY2tfdm9sdGFnZV9kZXBlbmRlbmN5X3RhYmxlKHN0cnVjdCBwcF9od21nciAqaHdtZ3IsCiAg ICAgICAgICAgICAgICAgICAgICAgIHN0cnVjdCBzbXUxMF92b2x0YWdlX2RlcGVuZGVuY3lfdGFi bGUgKipwcHRhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBudW1fZW50cnks IGNvbnN0IERwbUNsb2NrX3QgKnBjbGtfZGVwZW5kZW5jeV90YWJsZSkKewogICAgICAgIHVpbnQz Ml90IGk7CiAgICAgICAgc3RydWN0IHNtdTEwX3ZvbHRhZ2VfZGVwZW5kZW5jeV90YWJsZSAqcHRh YmxlOwoKICAgICAgICBwdGFibGUgPSBremFsbG9jKHN0cnVjdF9zaXplKHB0YWJsZSwgZW50cmll cywgbnVtX2VudHJ5KSwgR0ZQX0tFUk5FTCk7CiAgICAgICAgaWYgKE5VTEwgPT0gcHRhYmxlKQog ICAgICAgICAgICAgICAgcmV0dXJuIC1FTk9NRU07CgogICAgICAgIHB0YWJsZS0+Y291bnQgPSBu dW1fZW50cnk7CgpTbyB0aGUgaW1wbGljYXRpb24gaXMgdGhhdCBpdCdzIG5hdGl2ZSBieXRlIG9y ZGVyLi4uIGJ1dCB5b3UgdGVsbCBtZSEgSQpjZXJ0YWlubHkgZG9uJ3Qgd2FudCB0aGlzIGFubm90 YXRpb24gaWYgaXQncyBnb2luZyB0byBicmVhayBzdHVmZi4gOikKCi0tIApLZWVzIENvb2sKX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVmlydHVhbGl6YXRp b24gbWFpbGluZyBsaXN0ClZpcnR1YWxpemF0aW9uQGxpc3RzLmxpbnV4LWZvdW5kYXRpb24ub3Jn Cmh0dHBzOi8vbGlzdHMubGludXhmb3VuZGF0aW9uLm9yZy9tYWlsbWFuL2xpc3RpbmZvL3ZpcnR1 YWxpemF0aW9u 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 23AB6CE7AB3 for ; Mon, 25 Sep 2023 17:52:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 248F010E2C4; Mon, 25 Sep 2023 17:52:38 +0000 (UTC) Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0BADA10E2CF for ; Mon, 25 Sep 2023 17:52:35 +0000 (UTC) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-690d2441b95so5180953b3a.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=PybAeG4Pa00YgfyLIKxldAkS0sISS1lJA2ekDV9tdXSNqYzFCpn2Z9+y0FSl6xs5pg oK2/VyBZc/81ttZHigb4PLhho0hhW/KbfEI4/WPuqY7lNvxJ3jecusUE3UiCih/4lD4u m16WSFRYfUV3IY+/QsDnkwBN1OpHXnlsvsrq8freeTIwfsviSLQLqI4dhTn8iU4vmHO0 /3go+whI44LQfFsPnukRd/FsaNJ8XEjv5cgD8DM/6Vzo6T60LsPx1gwU7Sx6vLNiraWR hbPIYxZPttSpRsJfhN+hnrBATeriZcvwrJ6+vare3bsywvwDHoBiqvppG4KpSPsj7EUj pyuA== X-Gm-Message-State: AOJu0YxsKouoYVc1Nig5EWBuEb1stMvged7H8DHE2AxCeSPxgAb7LkKS tdKCHr3wMQQh90uksQ+qHBpXtQ== 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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development 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 , 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 , Nirmoy Das , freedreno@lists.freedesktop.org, John Harrison , linux-hardening@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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