Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp355956rdb; Thu, 5 Oct 2023 07:57:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg+NZHmTevVd7yE9HZKcHZUj0y4HAyxWoglPWRXgDk0kY+cXIbr6OOUzJoc0oVY7GJx37E X-Received: by 2002:a05:6830:1091:b0:6bc:8afe:8a15 with SMTP id y17-20020a056830109100b006bc8afe8a15mr4537934oto.38.1696517856909; Thu, 05 Oct 2023 07:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696517856; cv=none; d=google.com; s=arc-20160816; b=TvfvAnQzD+dY4nsIC9Cw6G9GAVvSWUxBMM11DsF7rDDmrkfqdxVgu4Olj2RoLp/cEF H1eeTLEf0RG57Z8zfGVIHGt3+LJ8aAIxTPI6mJcW97yR5NjY9Lbkenazqy5MfP9l8Own e7lo904tQbEjFGZkPBmqCNd0fhm8/b+EFwQnOmqB6bpqo1FUI0Jw/Zo8r0oycrjLaznr qxCjkRkC/+02NpT+yBBOQ/LTFWeXvyu67ARiWIUz5hZQwn2uxsej9BfH8/E7crn8OPcn J9EBin4im9dxmZAtvtUwXTj7sW/cr62/CL1ih0pakkpkMONyBJ9qotdHoE7glrbEaexy xUZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=693KH3zKhYevDlo1VF7tZiOPFyQxum49fs5ILYx5v8c=; fh=90hMkCiWASwOfZSsIJ+12jIjzcncKmWxC2uofGvpBvw=; b=aopjPl9zWuvdMH+aiBT/KGlbeKuYQNl0cwdDo2+RJX1S/0N+Kf/zeZHlC0oRk08K8g g+X9bRaKR36MG+Qm1JQqU5u6wyJfDjq8yx5yZG3XZ5O+8/XUjUuv8lxfr82po6hM9ydb P3z8d9Szs7oOfsN1TVtNM6ZXzcJnW6U41l1mnWTQ3nnIg0jjBV5eMdvGw4bAy/YMez+g x979VmUQolLvkKlN63/Va7OpaQ5vaHAwSLmM9yCWq2mLLpYsMBDuKKagj5aDQCD6xRur oHgpfRG2SBuuSPpE8amCoVm0bAzSHOQxQ4QHsUVDJrGI8W8GLCxhMttVy2luELt6N6py fi9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KlQlCCxa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id by22-20020a056a02059600b00578af1e2f3esi1683416pgb.687.2023.10.05.07.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:57:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KlQlCCxa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EF2D782F08F8; Thu, 5 Oct 2023 07:57:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235462AbjJEOdE (ORCPT + 99 others); Thu, 5 Oct 2023 10:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235087AbjJEOb2 (ORCPT ); Thu, 5 Oct 2023 10:31:28 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5245BAD3D; Thu, 5 Oct 2023 02:42:46 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4065f29e933so7125545e9.1; Thu, 05 Oct 2023 02:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696498964; x=1697103764; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=693KH3zKhYevDlo1VF7tZiOPFyQxum49fs5ILYx5v8c=; b=KlQlCCxaDdbdM/77MV3aYSCaAMJZrf5XTckHj73GAqe+taEDYD3GgYGNm4ne8WslZw zs5yuTG0s8twzf52YDk9LE+CEkWflQkuE7RbyBiYaenJQoyAspvC+W/UazfKRTHC9ZSc sgWKy/TQdSqfMd1LM0fEUxLLD3+yEfZNdaQ2FhwhtrslxIm4YfMQIQLvYg68D/4aGW+C evYxsuBqEuiGkj/XxCdhQygvB45uNMM8VHQGroxqeQCX0TY1i/ZdI2dwBUqFpsc4F4sl NHWJooTwrPJgK4bgYDS4cfNsGM7FNaFynLaUBHkwhpKMio0zO9vCncwe4mpunDTosVNq 2VrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696498964; x=1697103764; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=693KH3zKhYevDlo1VF7tZiOPFyQxum49fs5ILYx5v8c=; b=VVl01rZ3FOaurFpIqNOlWRYmDSMc6TZT8uHqtDBPk3bwV+8z2338YLpqHB4gM9gngx U1p3QyGwiIxFueqqf0gHj1W61FEG0Q9mvkB8D172omUEeHmD51EIuek2Whbirkw6JzER Cpynt9uTRjjgcr16dRIpuUgP0nAiQWi8FsCPlKKNjbac9+P34ErJZylU2AZKF4xyoNBb 35bXl5sENinyB0UK1gq9Lar3ckYwVs3kjuZ12reebz7iu2nle2RbtYquDpD3mO2fnvqG UUDTTmBjYhBWhx/p7fhmcKTqaRVnxd5D1N4ggrAj6d62L6FcKDxCSIqJsQ6b5nx/J4OF zvrA== X-Gm-Message-State: AOJu0YzQed3IkYwB5N2ZTg4tL3zLzGLV6CVZw/cMRau9bJTNcd3MAFt1 C93Jox82061++sdxvYY8Dyw= X-Received: by 2002:a05:600c:c9:b0:405:3dee:3515 with SMTP id u9-20020a05600c00c900b004053dee3515mr4625492wmm.27.1696498964439; Thu, 05 Oct 2023 02:42:44 -0700 (PDT) Received: from [10.254.108.106] (munvpn.amd.com. [165.204.72.6]) by smtp.gmail.com with ESMTPSA id w21-20020a05600c015500b0040535648639sm1103836wmm.36.2023.10.05.02.42.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Oct 2023 02:42:43 -0700 (PDT) Message-ID: Date: Thu, 5 Oct 2023 11:42:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by To: Kees Cook , =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: Alex Deucher , 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, Zack Rusin , linux-hardening@vger.kernel.org References: <20230922173110.work.084-kees@kernel.org> <169601600138.3014939.8511343741428844249.b4-ty@chromium.org> <83cd056c-52ae-01dd-7576-42d41da64c26@gmail.com> <202310020952.E7DE0948C0@keescook> <10644b5f-b0a7-85ef-0658-2353ee14df0d@gmail.com> <202310021107.9BB46FB8E@keescook> <0be2dfa4-b6c1-f62a-66e1-615da7aa3c76@amd.com> <202310021122.B6DA850FB0@keescook> Content-Language: en-US From: =?UTF-8?Q?Christian_K=C3=B6nig?= In-Reply-To: <202310021122.B6DA850FB0@keescook> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:57:36 -0700 (PDT) Am 02.10.23 um 20:22 schrieb Kees Cook: > On Mon, Oct 02, 2023 at 08:11:41PM +0200, Christian König wrote: >> Am 02.10.23 um 20:08 schrieb Kees Cook: >>> On Mon, Oct 02, 2023 at 08:01:57PM +0200, Christian König wrote: >>>> Am 02.10.23 um 18:53 schrieb Kees Cook: >>>>> 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? >>>> Probably best if the relevant maintainer pick them up individually. >>>> >>>> Some of those structures are filled in by firmware/hardware and only the >>>> maintainers can judge if that value actually matches what the compiler >>>> needs. >>>> >>>> We have cases where individual bits are used as flags or when the size is >>>> byte swapped etc... >>>> >>>> Even Alex and I didn't immediately say how and where that field is actually >>>> used and had to dig that up. That's where the confusion came from. >>> Okay, I've dropped them all from my tree. Several had Acks/Reviews, so >>> hopefully those can get picked up for the DRM tree? >> I will pick those up to go through drm-misc-next. >> >> Going to ping maintainers once more when I'm not sure if stuff is correct or >> not. > Sounds great; thanks! I wasn't 100% sure for the VC4 patch, but pushed the whole set to drm-misc-next anyway. This also means that the patches are now auto merged into the drm-tip integration branch and should any build or unit test go boom we should notice immediately and can revert it pretty easily. Thanks, Christian. > > -Kees >