Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp432088rdb; Thu, 5 Oct 2023 09:57:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVItGogN3ZLy/LFLfRA4eb4wSPkjpM5tOXMT3rJIKmiudV/Q0Ro5kmJndamw9v12GzeXjX X-Received: by 2002:a05:6871:68d:b0:1d6:3fa2:5b6e with SMTP id l13-20020a056871068d00b001d63fa25b6emr6451870oao.46.1696525051903; Thu, 05 Oct 2023 09:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525051; cv=none; d=google.com; s=arc-20160816; b=KwhTJDumecQIXDmhSym2MqX7YlTF6hgfH0+qn4Ib6pzcCw6FXkR1QxOyHu+nj148ll w39pBrJCirerxFyyg3xpL1rGJc0XlV1xCeIxJ1aiDqN7DLUSZO7dzjR5zeeBFeQrb0Yr 1PVSszS3tOoS9YJb2yf9fWNLNZHGUx3VdGnjusOeIaNP+WobynV7JGHaeznRB6/HzHVr hTsRROJ905FPc4676PEQNcze2parGtDAgE38n1I8e59fKGvKF7cBA+rpESHegFAWleH+ cXrWMMwAama4JahXKU1piE/rEWBFyxv2mmcA6Z092e7VAtSBWI9AlJe64kmzCCxiH4n8 g/jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xpZu6lqlyEvAN7T4WQyZZbFvUnbP262xmkxGmbRAMgI=; fh=Hm5VXoppn5E+yscfldO0lG3JCl5KaCs7oo7sqF0VbBk=; b=1Es1H/M/w0lGjRmvS8yY29B0ubza9t+V91KNPErzrTkYJUvGW4l7oIwVsC5dbHMt2B MW/uUZuQOJJqNjljQclWn0oRbQqQJVsugnqXvtoW8TqqPrX+3CHJQmrmqW0hglwsUurp rXskv2gtddVpSyfmQFLOSId+yUZBX4Gsa+O3ThEe0Kh4Y71XssTHZCCKSOAFdf6dNcv6 DGwa1JZjP30g8xBb7gBDL/MCGy9QnVn7PrgNOttv8gb/eHd+IS71bv1/3Pig8p3s+x69 F3XuIJfkv0m/CzaUmGZYCIeQouMyr8wogk503RMRYGloWzkkJYwNQqNPnEjv4Q+mxzbu krQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GgnioRLS; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 37-20020a631065000000b00578dfc8f11asi1759209pgq.792.2023.10.05.09.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:57:31 -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=@chromium.org header.s=google header.b=GgnioRLS; 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=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EC61C8328FE1; Thu, 5 Oct 2023 09:57:30 -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 S232547AbjJEQ1g (ORCPT + 99 others); Thu, 5 Oct 2023 12:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243196AbjJEQWh (ORCPT ); Thu, 5 Oct 2023 12:22:37 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F45F30E9 for ; Thu, 5 Oct 2023 09:16:24 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6969b391791so905472b3a.3 for ; Thu, 05 Oct 2023 09:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696522583; x=1697127383; 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=xpZu6lqlyEvAN7T4WQyZZbFvUnbP262xmkxGmbRAMgI=; b=GgnioRLSfuHluJcKeRVhJg2pJrRhq/2PX+jbibkiDkTO+pmOZPLczBLmEoTGyR4DDg LlgTMxnlBMFBrGT02fujhcmCmtkMhjWuZcWex/BjFg7Sg9mwI/m5KGMPx/VcPdwlI01B uC/TKlTqDRBhG/u3NYIC7Jo8xud5BAOa9vN7g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696522583; x=1697127383; 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=xpZu6lqlyEvAN7T4WQyZZbFvUnbP262xmkxGmbRAMgI=; b=VHyL6bET66SKn2LDYWstIOhERE5N/+nd4irnjnP2UrZeLmYBsXtXO8ewWLeFGncdok rUXlRc+wCmWW+8LX6oilw8sGh8uvUGURGYm2yuz230Ev+i/O0n//rqJRL+pq8OydO202 HjI4BQBfCXJeFTX1qzax3Lh9oo0fTjtBn+tJhGHk6pcZdPB/bbpzmHVzEmuDQCjCIf0E omeIAIpVjTcjIbPmGajj0PIEyF25ENYmq5E5HG+/icBWc5tLf6UKUjXTkC2eWDRguNJT +Z9CWQvCCHt8Mi0g4FJ+TqdhykfKXMS5+Gyw1zSa7tAqKDeU0NXLPGk/dJjYDlqSF5le qu2g== X-Gm-Message-State: AOJu0YyYjxkFvuv8yKiGCcYBE0GO5HNkwzClFWCJOg1VoeKS28lQd7XQ stWO7uYoywCjl6PpYiJqVyDauA== X-Received: by 2002:a05:6a20:7d84:b0:15c:b7ba:9137 with SMTP id v4-20020a056a207d8400b0015cb7ba9137mr6912555pzj.2.1696522583080; Thu, 05 Oct 2023 09:16:23 -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 e4-20020a170902d38400b001bc675068e2sm1903597pld.111.2023.10.05.09.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:16:22 -0700 (PDT) Date: Thu, 5 Oct 2023 09:16:21 -0700 From: Kees Cook To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Christian =?iso-8859-1?Q?K=F6nig?= , 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 Subject: Re: [PATCH 0/9] drm: Annotate structs with __counted_by Message-ID: <202310050915.ABB0419C@keescook> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 09:57:31 -0700 (PDT) On Thu, Oct 05, 2023 at 11:42:38AM +0200, Christian König wrote: > 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 very much; I'll keep an eye out for any reports. -- Kees Cook