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 5F87FE784AB for ; Mon, 2 Oct 2023 17:14:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 070D710E0BC; Mon, 2 Oct 2023 17:14:02 +0000 (UTC) Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by gabe.freedesktop.org (Postfix) with ESMTPS id D206F10E0BC for ; Mon, 2 Oct 2023 16:53:25 +0000 (UTC) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68bed2c786eso13287041b3a.0 for ; Mon, 02 Oct 2023 09:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=KdiwG3JXrZ6PJFfRIDnKb5hp3Ad5zFs3niO64KOrXuFctJGZjklSC9cSHyYI9GMxEJ UnpeB4Ei3OQUHvwc527QQ8IT+QNykFUZCwtpYckktx4ys5Gy3GcmFDt5jHWVHmzFkWlN yb5S/xgWrjvw4gfV4LYeg4g/o2nsSTkrzOWpw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=TmMWrkPzLCCWvvUARYXWdIHVfGJqdZhmPUpOk9T7uttP+P6/cVu6JOJrLJt1Vdu/ds 1y7cZ4npP26wcas7TKDOVEmjZR4LMOziRWpLyfjgTW9iGMRhFci6rXrDuiP5DmCnFQVk jrLa6ylODw1osGCDbkBjsNFR1rfxP0HioSKUBtjcnPaqumiQsdeP/Bw5pd1LyJyo2frV +Rdmr58MYMud7aQn4cM/SGn5l6hhsedcEmRqdm6B/EumlMJ5RK0pPhnZz9AXDVY5dA0x 5SIDUA+Z0Xv+a7qMCbSHIpk/pJ78KYkOA6HrR/ZLEHVwImJ+ALZFRHal5jyA3pGRNaO2 Jafg== X-Gm-Message-State: AOJu0YxdDYwc1sBpZBmzDuuWBrrR+Kx6jW8DSr5odookoWpq7KqHmfSw TqNg6NfGfa9J3cFlg+eKsY4RaQ== X-Google-Smtp-Source: AGHT+IFEV6bmAIpHw+or7unvvp4cwTsozoazziwp2MnJPMacuVlS3tG5VZyJpyiWZTmsINX1q284Ww== X-Received: by 2002:a05:6a20:9687:b0:15a:836:7239 with SMTP id hp7-20020a056a20968700b0015a08367239mr8898824pzc.11.1696265605341; Mon, 02 Oct 2023 09:53:25 -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 s24-20020aa78d58000000b0068fdb59e9d6sm19485160pfe.78.2023.10.02.09.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:53:24 -0700 (PDT) Date: Mon, 2 Oct 2023 09:53:21 -0700 From: Kees Cook To: Alex Deucher Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by Message-ID: <202310020952.E7DE0948C0@keescook> References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailman-Approved-At: Mon, 02 Oct 2023 17:13:59 +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: Tejas Upadhyay , Emma Anholt , Tom Rix , linux-arm-msm@vger.kernel.org, Joonas Lahtinen , 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 , Karol Herbst , Neil Armstrong , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , VMware Graphics Reviewers , Ben Skeggs , Andi Shyti , nouveau@lists.freedesktop.org, David Airlie , virtualization@lists.linux-foundation.org, Chia-I Wu , linux-hardening@vger.kernel.org, Alex Deucher , Lijo Lazar , Tvrtko Ursulin , Christian =?iso-8859-1?Q?K=F6nig?= , intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Jani Nikula , Nathan Chancellor , Le Ma , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , Evan Quan , Sean Paul , Yifan Zhang , Xiaojian Du , freedreno@lists.freedesktop.org, Bjorn Andersson , "Pan, Xinhui" , Nick Desaulniers , linux-kernel@vger.kernel.org, Rob Clark , Melissa Wen , Zack Rusin , Daniel Vetter , Dmitry Baryshkov , Nirmoy Das , Lang Yu , Christian =?iso-8859-1?Q?K=F6nig?= , John Harrison , Hawking Zhang Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" On Mon, Oct 02, 2023 at 11:06:19AM -0400, Alex Deucher wrote: > On Mon, Oct 2, 2023 at 5:20 AM Christian König > wrote: > > > > Am 29.09.23 um 21:33 schrieb Kees Cook: > > > On Fri, 22 Sep 2023 10:32:05 -0700, Kees Cook wrote: > > >> This is a batch of patches touching drm for preparing 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 to structs that would > > >> benefit from the annotation. > > >> > > >> [...] > > > Since this got Acks, I figure I should carry it in my tree. Let me know > > > if this should go via drm instead. > > > > > > Applied to for-next/hardening, thanks! > > > > > > [1/9] drm/amd/pm: Annotate struct smu10_voltage_dependency_table with __counted_by > > > https://git.kernel.org/kees/c/a6046ac659d6 > > > > STOP! In a follow up discussion Alex and I figured out that this won't work. I'm so confused; from the discussion I saw that Alex said both instances were false positives? > > > > The value in the structure is byte swapped based on some firmware > > endianness which not necessary matches the CPU endianness. > > SMU10 is APU only so the endianess of the SMU firmware and the CPU > will always match. Which I think is what is being said here? > > Please revert that one from going upstream if it's already on it's way. > > > > And because of those reasons I strongly think that patches like this > > should go through the DRM tree :) Sure, that's fine -- please let me know. It was others Acked/etc. Who should carry these patches? Thanks! -Kees > > > > Regards, > > Christian. > > > > > [2/9] drm/amdgpu/discovery: Annotate struct ip_hw_instance with __counted_by > > > https://git.kernel.org/kees/c/4df33089b46f > > > [3/9] drm/i915/selftests: Annotate struct perf_series with __counted_by > > > https://git.kernel.org/kees/c/ffd3f823bdf6 > > > [4/9] drm/msm/dpu: Annotate struct dpu_hw_intr with __counted_by > > > https://git.kernel.org/kees/c/2de35a989b76 > > > [5/9] drm/nouveau/pm: Annotate struct nvkm_perfdom with __counted_by > > > https://git.kernel.org/kees/c/188aeb08bfaa > > > [6/9] drm/vc4: Annotate struct vc4_perfmon with __counted_by > > > https://git.kernel.org/kees/c/59a54dc896c3 > > > [7/9] drm/virtio: Annotate struct virtio_gpu_object_array with __counted_by > > > https://git.kernel.org/kees/c/5cd476de33af > > > [8/9] drm/vmwgfx: Annotate struct vmw_surface_dirty with __counted_by > > > https://git.kernel.org/kees/c/b426f2e5356a > > > [9/9] drm/v3d: Annotate struct v3d_perfmon with __counted_by > > > https://git.kernel.org/kees/c/dc662fa1b0e4 > > > > > > Take care, > > > > > -- 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 4EFB8E74901 for ; Mon, 2 Oct 2023 16:53:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 292AB10E1FA; Mon, 2 Oct 2023 16:53:28 +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 F26DF10E1FC for ; Mon, 2 Oct 2023 16:53:25 +0000 (UTC) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6910ea9cca1so13103221b3a.1 for ; Mon, 02 Oct 2023 09:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=KdiwG3JXrZ6PJFfRIDnKb5hp3Ad5zFs3niO64KOrXuFctJGZjklSC9cSHyYI9GMxEJ UnpeB4Ei3OQUHvwc527QQ8IT+QNykFUZCwtpYckktx4ys5Gy3GcmFDt5jHWVHmzFkWlN yb5S/xgWrjvw4gfV4LYeg4g/o2nsSTkrzOWpw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=YD9OpEo24DS8UWForTE1YJo8qjlFjePlfSP8yhekToWW/elwvA5DaYnWSuDC3+yz52 3WPo6VBq1DhGNtTklp+CrvnXSEgQcu4zSrSz9HTXP4vjF2QAEjGTtna+56yNMIEl+NwM 76fhoUK8si7bN6hTNPndmOocOjE5+L1mIAvpkKYgNqwJvqFOytTqVhxPNbC4KFZ07HgQ 32VmcFflSYNGx617qzdWBWM4pdn98aG2659ECJSijVYIviuavOjapHaZsbrK8nVYk5Hg F3nGRnlDvLhnKwDTk2NGpW4HylsQM7j7BmlSDv3beW7BVK18Q+sjYLrRQs/tU5/1PuL1 RrTQ== X-Gm-Message-State: AOJu0YxPt0+xA7wXrryEVFkyHk7259qa4aCnpmQb4z4X3Z2ZnFpq2boM 5NlS9Rgq1JP4hSFVZ0sc1n80xg== X-Google-Smtp-Source: AGHT+IFEV6bmAIpHw+or7unvvp4cwTsozoazziwp2MnJPMacuVlS3tG5VZyJpyiWZTmsINX1q284Ww== X-Received: by 2002:a05:6a20:9687:b0:15a:836:7239 with SMTP id hp7-20020a056a20968700b0015a08367239mr8898824pzc.11.1696265605341; Mon, 02 Oct 2023 09:53:25 -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 s24-20020aa78d58000000b0068fdb59e9d6sm19485160pfe.78.2023.10.02.09.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:53:24 -0700 (PDT) Date: Mon, 2 Oct 2023 09:53:21 -0700 From: Kees Cook To: Alex Deucher Message-ID: <202310020952.E7DE0948C0@keescook> References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Subject: Re: [Intel-gfx] [PATCH 0/9] drm: Annotate structs 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: Emma Anholt , Tom Rix , linux-arm-msm@vger.kernel.org, llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , Gerd Hoffmann , Andrzej Hajda , Marijn Suijten , David Airlie , Karol Herbst , Neil Armstrong , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , VMware Graphics Reviewers , Ben Skeggs , nouveau@lists.freedesktop.org, David Airlie , virtualization@lists.linux-foundation.org, Chia-I Wu , linux-hardening@vger.kernel.org, Alex Deucher , Lijo Lazar , Christian =?iso-8859-1?Q?K=F6nig?= , intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Nathan Chancellor , Le Ma , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , Evan Quan , Yifan Zhang , Xiaojian Du , freedreno@lists.freedesktop.org, Bjorn Andersson , "Pan, Xinhui" , Nick Desaulniers , linux-kernel@vger.kernel.org, Melissa Wen , Zack Rusin , Daniel Vetter , Dmitry Baryshkov , Nirmoy Das , Lang Yu , Christian =?iso-8859-1?Q?K=F6nig?= , Hawking Zhang Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Mon, Oct 02, 2023 at 11:06:19AM -0400, Alex Deucher wrote: > On Mon, Oct 2, 2023 at 5:20 AM Christian König > wrote: > > > > Am 29.09.23 um 21:33 schrieb Kees Cook: > > > On Fri, 22 Sep 2023 10:32:05 -0700, Kees Cook wrote: > > >> This is a batch of patches touching drm for preparing 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 to structs that would > > >> benefit from the annotation. > > >> > > >> [...] > > > Since this got Acks, I figure I should carry it in my tree. Let me know > > > if this should go via drm instead. > > > > > > Applied to for-next/hardening, thanks! > > > > > > [1/9] drm/amd/pm: Annotate struct smu10_voltage_dependency_table with __counted_by > > > https://git.kernel.org/kees/c/a6046ac659d6 > > > > STOP! In a follow up discussion Alex and I figured out that this won't work. I'm so confused; from the discussion I saw that Alex said both instances were false positives? > > > > The value in the structure is byte swapped based on some firmware > > endianness which not necessary matches the CPU endianness. > > SMU10 is APU only so the endianess of the SMU firmware and the CPU > will always match. Which I think is what is being said here? > > Please revert that one from going upstream if it's already on it's way. > > > > And because of those reasons I strongly think that patches like this > > should go through the DRM tree :) Sure, that's fine -- please let me know. It was others Acked/etc. Who should carry these patches? Thanks! -Kees > > > > Regards, > > Christian. > > > > > [2/9] drm/amdgpu/discovery: Annotate struct ip_hw_instance with __counted_by > > > https://git.kernel.org/kees/c/4df33089b46f > > > [3/9] drm/i915/selftests: Annotate struct perf_series with __counted_by > > > https://git.kernel.org/kees/c/ffd3f823bdf6 > > > [4/9] drm/msm/dpu: Annotate struct dpu_hw_intr with __counted_by > > > https://git.kernel.org/kees/c/2de35a989b76 > > > [5/9] drm/nouveau/pm: Annotate struct nvkm_perfdom with __counted_by > > > https://git.kernel.org/kees/c/188aeb08bfaa > > > [6/9] drm/vc4: Annotate struct vc4_perfmon with __counted_by > > > https://git.kernel.org/kees/c/59a54dc896c3 > > > [7/9] drm/virtio: Annotate struct virtio_gpu_object_array with __counted_by > > > https://git.kernel.org/kees/c/5cd476de33af > > > [8/9] drm/vmwgfx: Annotate struct vmw_surface_dirty with __counted_by > > > https://git.kernel.org/kees/c/b426f2e5356a > > > [9/9] drm/v3d: Annotate struct v3d_perfmon with __counted_by > > > https://git.kernel.org/kees/c/dc662fa1b0e4 > > > > > > Take care, > > > > > -- 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 80202E784AB for ; Mon, 2 Oct 2023 16:53:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238480AbjJBQxa (ORCPT ); Mon, 2 Oct 2023 12:53:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238493AbjJBQx3 (ORCPT ); Mon, 2 Oct 2023 12:53:29 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A40CBB8 for ; Mon, 2 Oct 2023 09:53:25 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1bd9b4f8e0eso103015ad.1 for ; Mon, 02 Oct 2023 09:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=f16iptU4NGHN2Gshz+newGrq9CO5Bcs/ufv6XeLLZ85fOMW1YLhZQmOVWTQIY8rt+8 ON2yqMF+f1r0+7a+TlMkpnSLafnmqIBYGJ6Fi7JT2SlM9MOgZdAqte8NUOzgnc7Q5swn FDoEZ/qC4MC8IeDPukdjDGGFpV+b/aIrxufN8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=cQV1Is7asMZGDi6+PUMi7ZSNGXLr7w1RppQVFeUq5N9fMYcWPqL2D+cvYnJ+BuH2vZ nJJFA6fmJ6qqFLeMAdd2wZ56r4+TP/+5o5mpektGYOfzxxPJCTjFqP7iTGXWFefKB8a6 PlSvq4X4INjy0hRXzpNcr1fH+/2irsEOxoi11wuNmj6b9en3OjqmsRnlf//7uc2pWbT7 18Vh/ZVqQYR1SOrBdBb1WY5o1xktAHDho0VCSlzv9no1nnlZYWT+LfDAJbyTKTxMzk9n VbSPmWUMe2YuEZiMjoWccaCqzmKVHpWd2xpd63uzFDGhbqqs9mKIeIaS4qbFAheEF4FO 2DAA== X-Gm-Message-State: AOJu0YzHF7wOY4CgSbI+ZWeP1xoxUbBQGYSsMuS6VOLr9EIJDm1dYEmV BANRiI+yiCXNjnL5YI0iRrRDnO9o8wN5XcSK+pE= X-Google-Smtp-Source: AGHT+IFfbFaeQO9242udM1wOdI7Nv+81OlhqJQIxio/cgMdcj4JL3Y+uRVoQhZuEb4vC1HVU7rLNZA== X-Received: by 2002:a17:902:ec8d:b0:1c6:1fc3:6857 with SMTP id x13-20020a170902ec8d00b001c61fc36857mr13017401plg.27.1696265605046; Mon, 02 Oct 2023 09:53:25 -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 h6-20020a170902f54600b001c74876f032sm6638850plf.162.2023.10.02.09.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:53:24 -0700 (PDT) Date: Mon, 2 Oct 2023 09:53:21 -0700 From: Kees Cook To: Alex Deucher Cc: Christian =?iso-8859-1?Q?K=F6nig?= , David Airlie , "Pan, Xinhui" , Karol Herbst , Tom Rix , Joonas Lahtinen , 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 , Lijo Lazar , VMware Graphics Reviewers , Ben Skeggs , Andi Shyti , nouveau@lists.freedesktop.org, David Airlie , Dmitry Baryshkov , Chia-I Wu , llvm@lists.linux.dev, Yifan Zhang , linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Jani Nikula , Tvrtko Ursulin , Nathan Chancellor , Le Ma , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , virtualization@lists.linux-foundation.org, Sean Paul , Neil Armstrong , Xiaojian Du , Lang Yu , Bjorn Andersson , Tejas Upadhyay , Nick Desaulniers , linux-kernel@vger.kernel.org, Hawking Zhang , Rob Clark , Melissa Wen , John Harrison , Daniel Vetter , Alex Deucher , Nirmoy Das , freedreno@lists.freedesktop.org, Christian =?iso-8859-1?Q?K=F6nig?= , Zack Rusin , linux-hardening@vger.kernel.org Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by Message-ID: <202310020952.E7DE0948C0@keescook> References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Mon, Oct 02, 2023 at 11:06:19AM -0400, Alex Deucher wrote: > On Mon, Oct 2, 2023 at 5:20 AM Christian König > wrote: > > > > Am 29.09.23 um 21:33 schrieb Kees Cook: > > > On Fri, 22 Sep 2023 10:32:05 -0700, Kees Cook wrote: > > >> This is a batch of patches touching drm for preparing 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 to structs that would > > >> benefit from the annotation. > > >> > > >> [...] > > > Since this got Acks, I figure I should carry it in my tree. Let me know > > > if this should go via drm instead. > > > > > > Applied to for-next/hardening, thanks! > > > > > > [1/9] drm/amd/pm: Annotate struct smu10_voltage_dependency_table with __counted_by > > > https://git.kernel.org/kees/c/a6046ac659d6 > > > > STOP! In a follow up discussion Alex and I figured out that this won't work. I'm so confused; from the discussion I saw that Alex said both instances were false positives? > > > > The value in the structure is byte swapped based on some firmware > > endianness which not necessary matches the CPU endianness. > > SMU10 is APU only so the endianess of the SMU firmware and the CPU > will always match. Which I think is what is being said here? > > Please revert that one from going upstream if it's already on it's way. > > > > And because of those reasons I strongly think that patches like this > > should go through the DRM tree :) Sure, that's fine -- please let me know. It was others Acked/etc. Who should carry these patches? Thanks! -Kees > > > > Regards, > > Christian. > > > > > [2/9] drm/amdgpu/discovery: Annotate struct ip_hw_instance with __counted_by > > > https://git.kernel.org/kees/c/4df33089b46f > > > [3/9] drm/i915/selftests: Annotate struct perf_series with __counted_by > > > https://git.kernel.org/kees/c/ffd3f823bdf6 > > > [4/9] drm/msm/dpu: Annotate struct dpu_hw_intr with __counted_by > > > https://git.kernel.org/kees/c/2de35a989b76 > > > [5/9] drm/nouveau/pm: Annotate struct nvkm_perfdom with __counted_by > > > https://git.kernel.org/kees/c/188aeb08bfaa > > > [6/9] drm/vc4: Annotate struct vc4_perfmon with __counted_by > > > https://git.kernel.org/kees/c/59a54dc896c3 > > > [7/9] drm/virtio: Annotate struct virtio_gpu_object_array with __counted_by > > > https://git.kernel.org/kees/c/5cd476de33af > > > [8/9] drm/vmwgfx: Annotate struct vmw_surface_dirty with __counted_by > > > https://git.kernel.org/kees/c/b426f2e5356a > > > [9/9] drm/v3d: Annotate struct v3d_perfmon with __counted_by > > > https://git.kernel.org/kees/c/dc662fa1b0e4 > > > > > > Take care, > > > > > -- 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 11114E748F8 for ; Mon, 2 Oct 2023 16:53:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E991010E0DE; Mon, 2 Oct 2023 16:53:27 +0000 (UTC) Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id D27B510E0DE for ; Mon, 2 Oct 2023 16:53:25 +0000 (UTC) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-692c02adeefso10663073b3a.3 for ; Mon, 02 Oct 2023 09:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=KdiwG3JXrZ6PJFfRIDnKb5hp3Ad5zFs3niO64KOrXuFctJGZjklSC9cSHyYI9GMxEJ UnpeB4Ei3OQUHvwc527QQ8IT+QNykFUZCwtpYckktx4ys5Gy3GcmFDt5jHWVHmzFkWlN yb5S/xgWrjvw4gfV4LYeg4g/o2nsSTkrzOWpw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=EFJeWOI4DToK3rM8JJMxOUdg5oKqGNXkifk08/EkmLvUQpkCU/5MqwEQNhFAAgSTPD QOD9kxBJ7BDvYL9XTHe3/OL1JK3rVlOAk00Z8OvND+aGT1tDAFyjLjBA7flOWRdAP9DQ QAb85QeEOQZTe5L/NT91vwXgdgzCzjqOLD8ow/gfbG2qXj7yNoA9ZdlzVd8XygmHg1Os sD56TCuGSRjCwVuMi9v2vjz7Ahx4gHRRkDEXjmhlbopd6vysNEVXFpLjQ71p3jpqRL0s DKpflVo1byaAB4rpCYuAzkJ5t1NhuCwRw0UxkbxxrZ9QEZXbVXbR79RfvdErq5iZrf2C 5exg== X-Gm-Message-State: AOJu0YwQshkMwkdJe8livRLUHvh9RyHwNOhdufYkGrJREfoYc0Y5SEe0 rZk8RKu210be/Up72kiuebGx1w== X-Google-Smtp-Source: AGHT+IFEV6bmAIpHw+or7unvvp4cwTsozoazziwp2MnJPMacuVlS3tG5VZyJpyiWZTmsINX1q284Ww== X-Received: by 2002:a05:6a20:9687:b0:15a:836:7239 with SMTP id hp7-20020a056a20968700b0015a08367239mr8898824pzc.11.1696265605341; Mon, 02 Oct 2023 09:53:25 -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 s24-20020aa78d58000000b0068fdb59e9d6sm19485160pfe.78.2023.10.02.09.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:53:24 -0700 (PDT) Date: Mon, 2 Oct 2023 09:53:21 -0700 From: Kees Cook To: Alex Deucher Message-ID: <202310020952.E7DE0948C0@keescook> References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Subject: Re: [Nouveau] [PATCH 0/9] drm: Annotate structs 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: Tejas Upadhyay , Emma Anholt , Tom Rix , linux-arm-msm@vger.kernel.org, Joonas Lahtinen , llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , Gerd Hoffmann , Andrzej Hajda , Marijn Suijten , Matthew Brost , Neil Armstrong , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , VMware Graphics Reviewers , Ben Skeggs , Andi Shyti , nouveau@lists.freedesktop.org, David Airlie , virtualization@lists.linux-foundation.org, Chia-I Wu , linux-hardening@vger.kernel.org, Alex Deucher , Lijo Lazar , Tvrtko Ursulin , Christian =?iso-8859-1?Q?K=F6nig?= , intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Jani Nikula , Nathan Chancellor , Le Ma , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , Evan Quan , Sean Paul , Yifan Zhang , Xiaojian Du , freedreno@lists.freedesktop.org, Bjorn Andersson , "Pan, Xinhui" , Nick Desaulniers , linux-kernel@vger.kernel.org, Rob Clark , Melissa Wen , Zack Rusin , Daniel Vetter , Dmitry Baryshkov , Nirmoy Das , Lang Yu , Christian =?iso-8859-1?Q?K=F6nig?= , John Harrison , Hawking Zhang Errors-To: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" On Mon, Oct 02, 2023 at 11:06:19AM -0400, Alex Deucher wrote: > On Mon, Oct 2, 2023 at 5:20 AM Christian König > wrote: > > > > Am 29.09.23 um 21:33 schrieb Kees Cook: > > > On Fri, 22 Sep 2023 10:32:05 -0700, Kees Cook wrote: > > >> This is a batch of patches touching drm for preparing 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 to structs that would > > >> benefit from the annotation. > > >> > > >> [...] > > > Since this got Acks, I figure I should carry it in my tree. Let me know > > > if this should go via drm instead. > > > > > > Applied to for-next/hardening, thanks! > > > > > > [1/9] drm/amd/pm: Annotate struct smu10_voltage_dependency_table with __counted_by > > > https://git.kernel.org/kees/c/a6046ac659d6 > > > > STOP! In a follow up discussion Alex and I figured out that this won't work. I'm so confused; from the discussion I saw that Alex said both instances were false positives? > > > > The value in the structure is byte swapped based on some firmware > > endianness which not necessary matches the CPU endianness. > > SMU10 is APU only so the endianess of the SMU firmware and the CPU > will always match. Which I think is what is being said here? > > Please revert that one from going upstream if it's already on it's way. > > > > And because of those reasons I strongly think that patches like this > > should go through the DRM tree :) Sure, that's fine -- please let me know. It was others Acked/etc. Who should carry these patches? Thanks! -Kees > > > > Regards, > > Christian. > > > > > [2/9] drm/amdgpu/discovery: Annotate struct ip_hw_instance with __counted_by > > > https://git.kernel.org/kees/c/4df33089b46f > > > [3/9] drm/i915/selftests: Annotate struct perf_series with __counted_by > > > https://git.kernel.org/kees/c/ffd3f823bdf6 > > > [4/9] drm/msm/dpu: Annotate struct dpu_hw_intr with __counted_by > > > https://git.kernel.org/kees/c/2de35a989b76 > > > [5/9] drm/nouveau/pm: Annotate struct nvkm_perfdom with __counted_by > > > https://git.kernel.org/kees/c/188aeb08bfaa > > > [6/9] drm/vc4: Annotate struct vc4_perfmon with __counted_by > > > https://git.kernel.org/kees/c/59a54dc896c3 > > > [7/9] drm/virtio: Annotate struct virtio_gpu_object_array with __counted_by > > > https://git.kernel.org/kees/c/5cd476de33af > > > [8/9] drm/vmwgfx: Annotate struct vmw_surface_dirty with __counted_by > > > https://git.kernel.org/kees/c/b426f2e5356a > > > [9/9] drm/v3d: Annotate struct v3d_perfmon with __counted_by > > > https://git.kernel.org/kees/c/dc662fa1b0e4 > > > > > > Take care, > > > > > -- 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 smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 80739E748FE for ; Mon, 2 Oct 2023 16:53:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D1A9682192; Mon, 2 Oct 2023 16:53:29 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D1A9682192 Authentication-Results: smtp1.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=XF5AoUr9 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Stsirxu2VNPn; Mon, 2 Oct 2023 16:53:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4B29682295; Mon, 2 Oct 2023 16:53:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4B29682295 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1B3B8C0039; Mon, 2 Oct 2023 16:53:28 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 37EE8C0032 for ; Mon, 2 Oct 2023 16:53:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0644882295 for ; Mon, 2 Oct 2023 16:53:27 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0644882295 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id naMsMZTboLM2 for ; Mon, 2 Oct 2023 16:53:26 +0000 (UTC) Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1235282192 for ; Mon, 2 Oct 2023 16:53:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1235282192 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-692c02adeefso10663077b3a.3 for ; Mon, 02 Oct 2023 09:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=XF5AoUr9KNH5qeSplj1Dx6RNHNgmCoKqVxJIcVQQcDACg8yQ3OfiJDY5TWAeCk674s UTHGOfbpoG5yHRCoGNoG1BaMuHWFI9aBFxPVeJr/HWXJ/1HYnVgrfyD6bnebNo29QlOr zzahRBRcAoxW8+iuZzL+OZfUmphNndOcGnB/E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=hpeyJ2EVjC04w4ZH5xUShzn4olDlWIlJNcyX+CduOpjSwumXzA5SKxBA52OKWwd4bl UbEPYsAbU5Sp5S1WeHxnS1oW9gpLf3vY3fp6bpe3FBWWYbGbXkJSv8jDHRvHRwPhUS3A vJEkpyHYWgjlCnS6DZowoWXJlmaH3RthOlPwsQAnPg/X5iynfsUGVKPFj0giVuUBZXRW pwV7JBT0cEUlHg60hmXsyFNP1SUqgxx3hXHVA0ZFk/VVxVk+hTuB7gaw+Jqe2sT9bixF 3jDud3HtA975hrSXBm5G3go8jaz4yAuA0D4bhmYwIa2fN7zECcPdzlYmJUe/poXoItdb Yi5g== X-Gm-Message-State: AOJu0Yw0o7ZHBFuY+ekplRm6mBAxzE3zW+Nya+NbRxr25KbtQbISgQSG aJiNEG7JJ730se+yumB+zMXsQg== X-Google-Smtp-Source: AGHT+IFEV6bmAIpHw+or7unvvp4cwTsozoazziwp2MnJPMacuVlS3tG5VZyJpyiWZTmsINX1q284Ww== X-Received: by 2002:a05:6a20:9687:b0:15a:836:7239 with SMTP id hp7-20020a056a20968700b0015a08367239mr8898824pzc.11.1696265605341; Mon, 02 Oct 2023 09:53:25 -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 s24-20020aa78d58000000b0068fdb59e9d6sm19485160pfe.78.2023.10.02.09.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:53:24 -0700 (PDT) Date: Mon, 2 Oct 2023 09:53:21 -0700 From: Kees Cook To: Alex Deucher Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by Message-ID: <202310020952.E7DE0948C0@keescook> References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: Tejas Upadhyay , Emma Anholt , Tom Rix , linux-arm-msm@vger.kernel.org, Joonas Lahtinen , llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , Andrzej Hajda , Marijn Suijten , David Airlie , Matthew Brost , Karol Herbst , Neil Armstrong , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , VMware Graphics Reviewers , Ben Skeggs , Andi Shyti , nouveau@lists.freedesktop.org, David Airlie , virtualization@lists.linux-foundation.org, Chia-I Wu , linux-hardening@vger.kernel.org, Alex Deucher , Lijo Lazar , Tvrtko Ursulin , Christian =?iso-8859-1?Q?K=F6nig?= , intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Jani Nikula , Nathan Chancellor , Le Ma , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , Evan Quan , Sean Paul , Yifan Zhang , Xiaojian Du , freedreno@lists.freedesktop.org, Bjorn Andersson , "Pan, Xinhui" , Nick Desaulniers , linux-kernel@vger.kernel.org, Rob Clark , Melissa Wen , Zack Rusin , Daniel Vetter , Dmitry Baryshkov , Nirmoy Das , Lang Yu , Christian =?iso-8859-1?Q?K=F6nig?= , John Harrison , Hawking Zhang 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" T24gTW9uLCBPY3QgMDIsIDIwMjMgYXQgMTE6MDY6MTlBTSAtMDQwMCwgQWxleCBEZXVjaGVyIHdy b3RlOgo+IE9uIE1vbiwgT2N0IDIsIDIwMjMgYXQgNToyMOKAr0FNIENocmlzdGlhbiBLw7ZuaWcK PiA8Y2tvZW5pZy5sZWljaHR6dW1lcmtlbkBnbWFpbC5jb20+IHdyb3RlOgo+ID4KPiA+IEFtIDI5 LjA5LjIzIHVtIDIxOjMzIHNjaHJpZWIgS2VlcyBDb29rOgo+ID4gPiBPbiBGcmksIDIyIFNlcCAy MDIzIDEwOjMyOjA1IC0wNzAwLCBLZWVzIENvb2sgd3JvdGU6Cj4gPiA+PiBUaGlzIGlzIGEgYmF0 Y2ggb2YgcGF0Y2hlcyB0b3VjaGluZyBkcm0gZm9yIHByZXBhcmluZyBmb3IgdGhlIGNvbWluZwo+ ID4gPj4gaW1wbGVtZW50YXRpb24gYnkgR0NDIGFuZCBDbGFuZyBvZiB0aGUgX19jb3VudGVkX2J5 IGF0dHJpYnV0ZS4gRmxleGlibGUKPiA+ID4+IGFycmF5IG1lbWJlcnMgYW5ub3RhdGVkIHdpdGgg X19jb3VudGVkX2J5IGNhbiBoYXZlIHRoZWlyIGFjY2Vzc2VzCj4gPiA+PiBib3VuZHMtY2hlY2tl ZCBhdCBydW4tdGltZSBjaGVja2luZyB2aWEgQ09ORklHX1VCU0FOX0JPVU5EUyAoZm9yIGFycmF5 Cj4gPiA+PiBpbmRleGluZykgYW5kIENPTkZJR19GT1JUSUZZX1NPVVJDRSAoZm9yIHN0cmNweS9t ZW1jcHktZmFtaWx5IGZ1bmN0aW9ucykuCj4gPiA+Pgo+ID4gPj4gQXMgZm91bmQgd2l0aCBDb2Nj aW5lbGxlWzFdLCBhZGQgX19jb3VudGVkX2J5IHRvIHN0cnVjdHMgdGhhdCB3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ub3JnCmh0dHBzOi8vbGlz dHMubGludXhmb3VuZGF0aW9uLm9yZy9tYWlsbWFuL2xpc3RpbmZvL3ZpcnR1YWxpemF0aW9u 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 43134E748F8 for ; Mon, 2 Oct 2023 16:53:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4822410E1FB; Mon, 2 Oct 2023 16:53:28 +0000 (UTC) Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id E96F010E1FB for ; Mon, 2 Oct 2023 16:53:25 +0000 (UTC) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68bed2c786eso13287038b3a.0 for ; Mon, 02 Oct 2023 09:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=KdiwG3JXrZ6PJFfRIDnKb5hp3Ad5zFs3niO64KOrXuFctJGZjklSC9cSHyYI9GMxEJ UnpeB4Ei3OQUHvwc527QQ8IT+QNykFUZCwtpYckktx4ys5Gy3GcmFDt5jHWVHmzFkWlN yb5S/xgWrjvw4gfV4LYeg4g/o2nsSTkrzOWpw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696265605; x=1696870405; 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=zPrUH5J+k/nTCuPqHTvyGlvTCCkInD9EOwhmWD637e8=; b=vfw4z/rKpe38sq21VaV67rstxgrx4pvMCo12Ud3LUJq/hVdvEXAof7S686zg0Qx93X Hn5LUSWEpvZ/BxZjCpGGAITHKE0CsuM8ua4fIdOL/bkqUE02WDqbdfjASFjTwSsQsGpX KFyX/U2uh5rMQyG4cyMzLdGocVCBNWg4FxslmT871Qk50SX88yrFCv1EzWTbaC0Jg5Xd dcj4NqpIjtY6R98otI03MI+Pjxr1GTdMZQKk1FlGZ7zqKHJjGRtVw4XNqoKsodrkSrws W00GgWZn3KgZoR3ns8xBIkS6kR7El9+zhakbihH3TbvD3RbLEYg+nCcOzmlicXHDEOcp RQUw== X-Gm-Message-State: AOJu0YzDwdO5bfvmZnOwfWO1qXSufbj038pDalfL/iP5nJU/GJkBoZ6M PDa/zVmsrQDTkrKAJOKfyOeQBQ== X-Google-Smtp-Source: AGHT+IFEV6bmAIpHw+or7unvvp4cwTsozoazziwp2MnJPMacuVlS3tG5VZyJpyiWZTmsINX1q284Ww== X-Received: by 2002:a05:6a20:9687:b0:15a:836:7239 with SMTP id hp7-20020a056a20968700b0015a08367239mr8898824pzc.11.1696265605341; Mon, 02 Oct 2023 09:53:25 -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 s24-20020aa78d58000000b0068fdb59e9d6sm19485160pfe.78.2023.10.02.09.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:53:24 -0700 (PDT) Date: Mon, 2 Oct 2023 09:53:21 -0700 From: Kees Cook To: Alex Deucher Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by Message-ID: <202310020952.E7DE0948C0@keescook> References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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: Tejas Upadhyay , Emma Anholt , Tom Rix , linux-arm-msm@vger.kernel.org, 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 , VMware Graphics Reviewers , Ben Skeggs , Andi Shyti , nouveau@lists.freedesktop.org, David Airlie , virtualization@lists.linux-foundation.org, linux-hardening@vger.kernel.org, Alex Deucher , Lijo Lazar , Tvrtko Ursulin , Christian =?iso-8859-1?Q?K=F6nig?= , intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Nathan Chancellor , Le Ma , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , Evan Quan , Sean Paul , Yifan Zhang , Xiaojian Du , freedreno@lists.freedesktop.org, Bjorn Andersson , "Pan, Xinhui" , Nick Desaulniers , linux-kernel@vger.kernel.org, Melissa Wen , Dmitry Baryshkov , Nirmoy Das , Lang Yu , Christian =?iso-8859-1?Q?K=F6nig?= , John Harrison , Hawking Zhang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, Oct 02, 2023 at 11:06:19AM -0400, Alex Deucher wrote: > On Mon, Oct 2, 2023 at 5:20 AM Christian König > wrote: > > > > Am 29.09.23 um 21:33 schrieb Kees Cook: > > > On Fri, 22 Sep 2023 10:32:05 -0700, Kees Cook wrote: > > >> This is a batch of patches touching drm for preparing 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 to structs that would > > >> benefit from the annotation. > > >> > > >> [...] > > > Since this got Acks, I figure I should carry it in my tree. Let me know > > > if this should go via drm instead. > > > > > > Applied to for-next/hardening, thanks! > > > > > > [1/9] drm/amd/pm: Annotate struct smu10_voltage_dependency_table with __counted_by > > > https://git.kernel.org/kees/c/a6046ac659d6 > > > > STOP! In a follow up discussion Alex and I figured out that this won't work. I'm so confused; from the discussion I saw that Alex said both instances were false positives? > > > > The value in the structure is byte swapped based on some firmware > > endianness which not necessary matches the CPU endianness. > > SMU10 is APU only so the endianess of the SMU firmware and the CPU > will always match. Which I think is what is being said here? > > Please revert that one from going upstream if it's already on it's way. > > > > And because of those reasons I strongly think that patches like this > > should go through the DRM tree :) Sure, that's fine -- please let me know. It was others Acked/etc. Who should carry these patches? Thanks! -Kees > > > > Regards, > > Christian. > > > > > [2/9] drm/amdgpu/discovery: Annotate struct ip_hw_instance with __counted_by > > > https://git.kernel.org/kees/c/4df33089b46f > > > [3/9] drm/i915/selftests: Annotate struct perf_series with __counted_by > > > https://git.kernel.org/kees/c/ffd3f823bdf6 > > > [4/9] drm/msm/dpu: Annotate struct dpu_hw_intr with __counted_by > > > https://git.kernel.org/kees/c/2de35a989b76 > > > [5/9] drm/nouveau/pm: Annotate struct nvkm_perfdom with __counted_by > > > https://git.kernel.org/kees/c/188aeb08bfaa > > > [6/9] drm/vc4: Annotate struct vc4_perfmon with __counted_by > > > https://git.kernel.org/kees/c/59a54dc896c3 > > > [7/9] drm/virtio: Annotate struct virtio_gpu_object_array with __counted_by > > > https://git.kernel.org/kees/c/5cd476de33af > > > [8/9] drm/vmwgfx: Annotate struct vmw_surface_dirty with __counted_by > > > https://git.kernel.org/kees/c/b426f2e5356a > > > [9/9] drm/v3d: Annotate struct v3d_perfmon with __counted_by > > > https://git.kernel.org/kees/c/dc662fa1b0e4 > > > > > > Take care, > > > > > -- Kees Cook