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 46F08E784AF for ; Mon, 2 Oct 2023 09:20:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EA4810E26C; Mon, 2 Oct 2023 09:20:51 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id C751D10E26C; Mon, 2 Oct 2023 09:20:17 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso14945850f8f.0; Mon, 02 Oct 2023 02:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696238416; x=1696843216; darn=lists.freedesktop.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=hpul48jc5wRgYuuq7rjWOuldRr3Cz9nGdNrRFKhLCSavyavqMoagsUnusKybAJHuKA xE046GUSPsZTRflARG4QV+okYn9/EzkY3povCmvJ5Ik1GrCj5Ln9lbAmh48xN4moydyS Ob0E2wJN29J2EQksMeSZ09nE0LGVTMfQwQYSuQk0qsMjIhriV7625WbkTiavmwYjaLqD UHXgnOE3qWqbwPTE1XChcntGdNGGp7w49mOcrOfHtkSnNRlfSSMvU1dMNWke9VL0l3zU sCHGzEt0FvM1pGp6qohTFb5z2sf0rVb6W87Vmo3P3pPk/heYC/hymC4KcrnC0WYc0EL+ MVCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696238416; x=1696843216; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=EV+IoY/hoj/U/elpIXBrMJjo2eti6i/r6uC0vZ7zP36Ogv4Ehbm+OV2vjkvsAHmIcN DYEslUo4u6DNhyJOUEWXr2dJPqFSu24/OZiG36ERZus5uME1+uPKJK16ycwjwDRVokMu h5eF68WrC1H59Y9xt1X4nbNZcWn3T068qLW4JiowOcH0He62g2zwsxhbn2GST4BcXNh9 3ayItguHqMVMyj8uyBQ8MfYpTPkqGPRqzHEJLdHQWGOPlLsw3vHG9yE2TVK/A4LDNVzu 0Ez17qAq9s+Hxrgd3DAvWjFmnidUAdES7WVwSff99TOeMYrKboJ5az85F6wByCnvwSXu Gb1w== X-Gm-Message-State: AOJu0Yxuxi6j+6ZPC8jWUDKviP1iS9xz8P3l4OeXzr1B/1a65fSaNCnL dOiz5T1a81XUOektcnKGqU8= X-Google-Smtp-Source: AGHT+IHbGguNFjowt/WUg4Hv4Wpy0nhMxW4/Lz37ilFeyba8QPT16aUDMsJeXvW8elMT4DQ7Chc9QA== X-Received: by 2002:adf:ee10:0:b0:319:71be:9248 with SMTP id y16-20020adfee10000000b0031971be9248mr9703358wrn.19.1696238415942; Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Received: from [10.254.108.106] (munvpn.amd.com. [165.204.72.6]) by smtp.gmail.com with ESMTPSA id t3-20020a5d5343000000b0030ae53550f5sm27500038wrv.51.2023.10.02.02.20.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Message-ID: <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> Date: Mon, 2 Oct 2023 11:20:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by Content-Language: en-US To: Kees Cook , David Airlie References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 , 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, =?UTF-8?Q?Christian_K=c3=b6nig?= , Zack Rusin , linux-hardening@vger.kernel.org Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" 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. The value in the structure is byte swapped based on some firmware endianness which not necessary matches the CPU endianness. 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 :) 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, > 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 98E32E784AF for ; Mon, 2 Oct 2023 09:21:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9FA4510E26F; Mon, 2 Oct 2023 09:20:54 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id C751D10E26C; Mon, 2 Oct 2023 09:20:17 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso14945850f8f.0; Mon, 02 Oct 2023 02:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696238416; x=1696843216; darn=lists.freedesktop.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=hpul48jc5wRgYuuq7rjWOuldRr3Cz9nGdNrRFKhLCSavyavqMoagsUnusKybAJHuKA xE046GUSPsZTRflARG4QV+okYn9/EzkY3povCmvJ5Ik1GrCj5Ln9lbAmh48xN4moydyS Ob0E2wJN29J2EQksMeSZ09nE0LGVTMfQwQYSuQk0qsMjIhriV7625WbkTiavmwYjaLqD UHXgnOE3qWqbwPTE1XChcntGdNGGp7w49mOcrOfHtkSnNRlfSSMvU1dMNWke9VL0l3zU sCHGzEt0FvM1pGp6qohTFb5z2sf0rVb6W87Vmo3P3pPk/heYC/hymC4KcrnC0WYc0EL+ MVCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696238416; x=1696843216; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=EV+IoY/hoj/U/elpIXBrMJjo2eti6i/r6uC0vZ7zP36Ogv4Ehbm+OV2vjkvsAHmIcN DYEslUo4u6DNhyJOUEWXr2dJPqFSu24/OZiG36ERZus5uME1+uPKJK16ycwjwDRVokMu h5eF68WrC1H59Y9xt1X4nbNZcWn3T068qLW4JiowOcH0He62g2zwsxhbn2GST4BcXNh9 3ayItguHqMVMyj8uyBQ8MfYpTPkqGPRqzHEJLdHQWGOPlLsw3vHG9yE2TVK/A4LDNVzu 0Ez17qAq9s+Hxrgd3DAvWjFmnidUAdES7WVwSff99TOeMYrKboJ5az85F6wByCnvwSXu Gb1w== X-Gm-Message-State: AOJu0Yxuxi6j+6ZPC8jWUDKviP1iS9xz8P3l4OeXzr1B/1a65fSaNCnL dOiz5T1a81XUOektcnKGqU8= X-Google-Smtp-Source: AGHT+IHbGguNFjowt/WUg4Hv4Wpy0nhMxW4/Lz37ilFeyba8QPT16aUDMsJeXvW8elMT4DQ7Chc9QA== X-Received: by 2002:adf:ee10:0:b0:319:71be:9248 with SMTP id y16-20020adfee10000000b0031971be9248mr9703358wrn.19.1696238415942; Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Received: from [10.254.108.106] (munvpn.amd.com. [165.204.72.6]) by smtp.gmail.com with ESMTPSA id t3-20020a5d5343000000b0030ae53550f5sm27500038wrv.51.2023.10.02.02.20.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Message-ID: <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> Date: Mon, 2 Oct 2023 11:20:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: Kees Cook , David Airlie References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: "Pan, Xinhui" , Karol Herbst , Tom Rix , dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , Gerd Hoffmann , Andrzej Hajda , Marijn Suijten , Evan Quan , Emma Anholt , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , Lijo Lazar , VMware Graphics Reviewers , Ben Skeggs , 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 , Nathan Chancellor , Le Ma , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , virtualization@lists.linux-foundation.org, Neil Armstrong , Xiaojian Du , Lang Yu , Bjorn Andersson , Nick Desaulniers , linux-kernel@vger.kernel.org, Hawking Zhang , Melissa Wen , Daniel Vetter , Alex Deucher , Nirmoy Das , freedreno@lists.freedesktop.org, =?UTF-8?Q?Christian_K=c3=b6nig?= , Zack Rusin , linux-hardening@vger.kernel.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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. The value in the structure is byte swapped based on some firmware endianness which not necessary matches the CPU endianness. 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 :) 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, > 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 DB2E1E784AF for ; Mon, 2 Oct 2023 09:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235965AbjJBJUV (ORCPT ); Mon, 2 Oct 2023 05:20:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235972AbjJBJUU (ORCPT ); Mon, 2 Oct 2023 05:20:20 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E56C83; Mon, 2 Oct 2023 02:20:17 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-327b7e08456so1180296f8f.2; Mon, 02 Oct 2023 02:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696238416; x=1696843216; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=KQ0dl6DG/gw/Hgo5l5nZaGLUdcfsyzPXK0Vl+YI9Z0jCK5GCk962bYwXX0RLBZq2gX +6QVeKOHq/I58Rhv+mTMqG5ZkMXRk42Qsn4Ew0qmdRCoFcWBeU0YVXc4vL/BRjfybICR F7/Nzp1hAwbviYRptLniM2r9SrX7tAFzQH378tzdfxjtg90Q1IWsKm/WFe2yVTlc9vAk 8k4+Vn7rQ0/Uxqm0rGfILoOXl/LDF+pmimqA9Q8AEY6XFKdHFFn53m1Z1QfyOn4YqWTS nPn3AD8spQ9nN4kPboMAwusR+FheTbfOVKuWaSKJDzMR+rfAUhSoEQmv66tf6+KaZdTL PORw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696238416; x=1696843216; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=V2z+cdDpluqzJqEE1WvFWZtdOvLDStFlwT2OV+UBGBI3LJWELJcBOENtOf7W2XL/LV lR/W/qnj3V1PsRjPmS2btDEAg/C3U5Nrdxg5bHXr/6RVayux3yDlXU2O3E/KNEPUx410 CDQF1U8fkaZRpg8PI2UztuuatqMcr03IsKn3UmbCt6kMlBkUWkX0gNIrHLDq05INQnJJ Mbw8HJ8Lo9pQUX0ZjS9nvvXHY5MTJGa+7kpx0ojGsw+nsZioXY4VzQ7Njn4yEaI2K6+b 6igVoXxt+SZO+OtOeHvecWDgLtFqnJoIvPZMxhKA74AJUb+FEkBNJn1Bl3MnnXgBLd3/ jAKQ== X-Gm-Message-State: AOJu0YxZbUFRdKMjA206ULWPwEJ/JokoP+hvzWguOYMcyHgCdyqCp+rP aD/47/aCUFe7c8gfdDFn8/s= X-Google-Smtp-Source: AGHT+IHbGguNFjowt/WUg4Hv4Wpy0nhMxW4/Lz37ilFeyba8QPT16aUDMsJeXvW8elMT4DQ7Chc9QA== X-Received: by 2002:adf:ee10:0:b0:319:71be:9248 with SMTP id y16-20020adfee10000000b0031971be9248mr9703358wrn.19.1696238415942; Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Received: from [10.254.108.106] (munvpn.amd.com. [165.204.72.6]) by smtp.gmail.com with ESMTPSA id t3-20020a5d5343000000b0030ae53550f5sm27500038wrv.51.2023.10.02.02.20.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Message-ID: <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> Date: Mon, 2 Oct 2023 11:20:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by Content-Language: en-US To: Kees Cook , David Airlie Cc: Tejas Upadhyay , Emma Anholt , Tom Rix , 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 , 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, Chia-I Wu , linux-hardening@vger.kernel.org, Lijo Lazar , Yifan Zhang , linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Jani Nikula , Melissa Wen , Alex Deucher , 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, Rob Clark , Zack Rusin , Daniel Vetter , Dmitry Baryshkov , Nirmoy Das , Lang Yu , =?UTF-8?Q?Christian_K=c3=b6nig?= , John Harrison , Hawking Zhang References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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. The value in the structure is byte swapped based on some firmware endianness which not necessary matches the CPU endianness. 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 :) 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, > 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 28056E7849A for ; Mon, 2 Oct 2023 09:21:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4864E10E270; Mon, 2 Oct 2023 09:20:55 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id C751D10E26C; Mon, 2 Oct 2023 09:20:17 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso14945850f8f.0; Mon, 02 Oct 2023 02:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696238416; x=1696843216; darn=lists.freedesktop.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=hpul48jc5wRgYuuq7rjWOuldRr3Cz9nGdNrRFKhLCSavyavqMoagsUnusKybAJHuKA xE046GUSPsZTRflARG4QV+okYn9/EzkY3povCmvJ5Ik1GrCj5Ln9lbAmh48xN4moydyS Ob0E2wJN29J2EQksMeSZ09nE0LGVTMfQwQYSuQk0qsMjIhriV7625WbkTiavmwYjaLqD UHXgnOE3qWqbwPTE1XChcntGdNGGp7w49mOcrOfHtkSnNRlfSSMvU1dMNWke9VL0l3zU sCHGzEt0FvM1pGp6qohTFb5z2sf0rVb6W87Vmo3P3pPk/heYC/hymC4KcrnC0WYc0EL+ MVCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696238416; x=1696843216; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=EV+IoY/hoj/U/elpIXBrMJjo2eti6i/r6uC0vZ7zP36Ogv4Ehbm+OV2vjkvsAHmIcN DYEslUo4u6DNhyJOUEWXr2dJPqFSu24/OZiG36ERZus5uME1+uPKJK16ycwjwDRVokMu h5eF68WrC1H59Y9xt1X4nbNZcWn3T068qLW4JiowOcH0He62g2zwsxhbn2GST4BcXNh9 3ayItguHqMVMyj8uyBQ8MfYpTPkqGPRqzHEJLdHQWGOPlLsw3vHG9yE2TVK/A4LDNVzu 0Ez17qAq9s+Hxrgd3DAvWjFmnidUAdES7WVwSff99TOeMYrKboJ5az85F6wByCnvwSXu Gb1w== X-Gm-Message-State: AOJu0Yxuxi6j+6ZPC8jWUDKviP1iS9xz8P3l4OeXzr1B/1a65fSaNCnL dOiz5T1a81XUOektcnKGqU8= X-Google-Smtp-Source: AGHT+IHbGguNFjowt/WUg4Hv4Wpy0nhMxW4/Lz37ilFeyba8QPT16aUDMsJeXvW8elMT4DQ7Chc9QA== X-Received: by 2002:adf:ee10:0:b0:319:71be:9248 with SMTP id y16-20020adfee10000000b0031971be9248mr9703358wrn.19.1696238415942; Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Received: from [10.254.108.106] (munvpn.amd.com. [165.204.72.6]) by smtp.gmail.com with ESMTPSA id t3-20020a5d5343000000b0030ae53550f5sm27500038wrv.51.2023.10.02.02.20.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Message-ID: <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> Date: Mon, 2 Oct 2023 11:20:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: Kees Cook , David Airlie References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: "Pan, Xinhui" , 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, =?UTF-8?Q?Christian_K=c3=b6nig?= , Zack Rusin , linux-hardening@vger.kernel.org Errors-To: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" 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. The value in the structure is byte swapped based on some firmware endianness which not necessary matches the CPU endianness. 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 :) 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, > 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 smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 724EDE784B0 for ; Mon, 2 Oct 2023 09:20:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id DC10360F71; Mon, 2 Oct 2023 09:20:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org DC10360F71 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=a5SsAz/N 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 3QJmoZOVrq-U; Mon, 2 Oct 2023 09:20:22 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 69B7F607E3; Mon, 2 Oct 2023 09:20:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 69B7F607E3 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 47674C0071; Mon, 2 Oct 2023 09:20:21 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id A3A1AC0032 for ; Mon, 2 Oct 2023 09:20:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7D82A41767 for ; Mon, 2 Oct 2023 09:20:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7D82A41767 Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=a5SsAz/N X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2WQX-0uZEcFG for ; Mon, 2 Oct 2023 09:20:18 +0000 (UTC) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by smtp4.osuosl.org (Postfix) with ESMTPS id 03F9A4175B for ; Mon, 2 Oct 2023 09:20:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 03F9A4175B Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-327b7e08456so1180295f8f.2 for ; Mon, 02 Oct 2023 02:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696238416; x=1696843216; darn=lists.linux-foundation.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=a5SsAz/NcOC0j9ef3CoBSKHRWA5RN3axyWaVhLdW1fboivE+Na9ckIVaeDcMgL/GW2 jhVwGlL2xANhuxmhzt5UrWDHNTY50eZWifV4Xlz9ftwgUnBCAQyCArQaUFPYP2L3TuHV ObFXyl7qUav1AZLffgterK9a9IrVlmsjvUIkZ0o+66XQd94kfMXy6aLbPL9m2sthaQfw ySX/6dhHH8gdjvahY1NBsS03n19/QUfxg7fCxqR4bP9mq8gULzBLtfisIjcS4VG5brDZ fb34iMirpXtgONY7kvxSDudoMX0mEs/mK/vZDX0o1z1akymVWHDm3eKc5CJjj1oaWiQK qNtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696238416; x=1696843216; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=aSwB93rqYmnfLGt8nz2IH0GlfrHGykIRJ2xHF6C+dghbepnfZ2foWxuqlJxuNEhkli J8M71vVcF6BN/nG+x/VFg2pBebwURvjwDbnx6n4HG8JNddugE6mmTBCVDsk3modDe4ze Yk4s8ypdmrzXn4hRMvSYuJFXK2UShk4UFnL7c6wUCgaSC7C98KU6EyWqtuq98zh6HGN2 7tJAEsiXY8fyMIylPgUoVMtUSS2OjbiVFvZEw0g3vLOLXVDh4JilUuncufQpAUxneoFb odWoQotpF72KH5f0j0dM/OfS9YWaxZ1MyxhPQFdee6gw1M2oLrTipcKxkAUn8LVKvB0H oqmw== X-Gm-Message-State: AOJu0YyRsH9hSt8CaAXaOAR3aKdjCc/iYrZ6gZlba51zNxRo7WeR/6OK yPgYSHtf/JENOg7fG92xH1k= X-Google-Smtp-Source: AGHT+IHbGguNFjowt/WUg4Hv4Wpy0nhMxW4/Lz37ilFeyba8QPT16aUDMsJeXvW8elMT4DQ7Chc9QA== X-Received: by 2002:adf:ee10:0:b0:319:71be:9248 with SMTP id y16-20020adfee10000000b0031971be9248mr9703358wrn.19.1696238415942; Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Received: from [10.254.108.106] (munvpn.amd.com. [165.204.72.6]) by smtp.gmail.com with ESMTPSA id t3-20020a5d5343000000b0030ae53550f5sm27500038wrv.51.2023.10.02.02.20.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Message-ID: <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> Date: Mon, 2 Oct 2023 11:20:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by Content-Language: en-US To: Kees Cook , David Airlie References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> Cc: "Pan, Xinhui" , Karol Herbst , Tom Rix , Joonas Lahtinen , dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , 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, =?UTF-8?Q?Christian_K=c3=b6nig?= , Zack Rusin , 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" 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. The value in the structure is byte swapped based on some firmware endianness which not necessary matches the CPU endianness. 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 :) 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, > _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization 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 364F5E784AF for ; Mon, 2 Oct 2023 09:20:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F4D310E26E; Mon, 2 Oct 2023 09:20:52 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id C751D10E26C; Mon, 2 Oct 2023 09:20:17 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso14945850f8f.0; Mon, 02 Oct 2023 02:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696238416; x=1696843216; darn=lists.freedesktop.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=hpul48jc5wRgYuuq7rjWOuldRr3Cz9nGdNrRFKhLCSavyavqMoagsUnusKybAJHuKA xE046GUSPsZTRflARG4QV+okYn9/EzkY3povCmvJ5Ik1GrCj5Ln9lbAmh48xN4moydyS Ob0E2wJN29J2EQksMeSZ09nE0LGVTMfQwQYSuQk0qsMjIhriV7625WbkTiavmwYjaLqD UHXgnOE3qWqbwPTE1XChcntGdNGGp7w49mOcrOfHtkSnNRlfSSMvU1dMNWke9VL0l3zU sCHGzEt0FvM1pGp6qohTFb5z2sf0rVb6W87Vmo3P3pPk/heYC/hymC4KcrnC0WYc0EL+ MVCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696238416; x=1696843216; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vNiEun8BJgZFmuZelXrrpN/XVazT12AxKny5brwsu7w=; b=EV+IoY/hoj/U/elpIXBrMJjo2eti6i/r6uC0vZ7zP36Ogv4Ehbm+OV2vjkvsAHmIcN DYEslUo4u6DNhyJOUEWXr2dJPqFSu24/OZiG36ERZus5uME1+uPKJK16ycwjwDRVokMu h5eF68WrC1H59Y9xt1X4nbNZcWn3T068qLW4JiowOcH0He62g2zwsxhbn2GST4BcXNh9 3ayItguHqMVMyj8uyBQ8MfYpTPkqGPRqzHEJLdHQWGOPlLsw3vHG9yE2TVK/A4LDNVzu 0Ez17qAq9s+Hxrgd3DAvWjFmnidUAdES7WVwSff99TOeMYrKboJ5az85F6wByCnvwSXu Gb1w== X-Gm-Message-State: AOJu0Yxuxi6j+6ZPC8jWUDKviP1iS9xz8P3l4OeXzr1B/1a65fSaNCnL dOiz5T1a81XUOektcnKGqU8= X-Google-Smtp-Source: AGHT+IHbGguNFjowt/WUg4Hv4Wpy0nhMxW4/Lz37ilFeyba8QPT16aUDMsJeXvW8elMT4DQ7Chc9QA== X-Received: by 2002:adf:ee10:0:b0:319:71be:9248 with SMTP id y16-20020adfee10000000b0031971be9248mr9703358wrn.19.1696238415942; Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Received: from [10.254.108.106] (munvpn.amd.com. [165.204.72.6]) by smtp.gmail.com with ESMTPSA id t3-20020a5d5343000000b0030ae53550f5sm27500038wrv.51.2023.10.02.02.20.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 02:20:15 -0700 (PDT) Message-ID: <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> Date: Mon, 2 Oct 2023 11:20:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by Content-Language: en-US To: Kees Cook , David Airlie References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 , 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 , llvm@lists.linux.dev, Yifan Zhang , linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , 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 , Melissa Wen , John Harrison , Alex Deucher , Nirmoy Das , freedreno@lists.freedesktop.org, =?UTF-8?Q?Christian_K=c3=b6nig?= , linux-hardening@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. The value in the structure is byte swapped based on some firmware endianness which not necessary matches the CPU endianness. 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 :) 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, >