Received: by 2002:a05:622a:4ca:b0:41c:c224:f26f with SMTP id q10csp526634qtx; Thu, 16 Nov 2023 10:28:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPL8P5Y5P0FvgskcqgeH6dbDRU2j2xin4JPow8txarg8ZveKgXA0PYIGRA8B5pWJ+pTYaj X-Received: by 2002:a17:90b:716:b0:27d:469b:8847 with SMTP id s22-20020a17090b071600b0027d469b8847mr3501560pjz.3.1700159324010; Thu, 16 Nov 2023 10:28:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700159323; cv=none; d=google.com; s=arc-20160816; b=ryrsuPktfrlIoA/j88Kt+gIUdj0xbwrSFis9hgBUTdrusILBiIdVVRnxLqrhiXa/da ZGDoqGn78gfZI+EVLnPQhYBN+vlzSBePev/4HZ8C5vK4RLOz368Djmo/psBWuI1ORR0n j4EhGy6PU4cdmNPMpNz+KLiUpgg/8DLBIoR+i0mmSoHitD3WADt7EYjLpnm0Jyn5rwQL v9YwSu3JCWOxixIQOlJltUGHxkojPRoejPIsGRMX4zROo3wbPMR2YzPFFmVJ5Db66mPJ aTC3VbXX/BuZeSc9iXoop6eSlylvYPOVswnO/ftxVtbwvtGPvT8wmUpFmdCH/1cJ5iog QUsA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7reBGJiccGvFEPh84DNhsMy+d8d0VEfZ803Vs8wYx6A=; fh=OAa2tOql+UyqAo7atvWeYKqcNWC9CUKoJSU4RN6mkxA=; b=rIUbSDwaISIjiuZn0Mb5Q8Z1vu/pSMfe496vvyFdMo1WNfx8NMmibh0cWue7cb+SXi spyqo4fRtfs8S2ucg1a+98CuO5wXMp+JpppJvT50CT2m37I0XTUioq4aRThu08tVqNoz 2oGreILwppRcpTv2WpNz84JJ9Cygx26NgWiY4PGUnak0nLVx6oTYUPd9fnC9tviVM1Wf s8mR5pJF+ssu93h+lfSXxqA1ci+sUoBHyQhx1aXJX/v5wZU/dHr68c8u0eJXbSWnrknx 4bRBnrR8SYNfwJ/lPFvdBdp3KDNPVBBZ1IqeIjLmu2Cr6roF/TtDD9z3ujHuoiZrmBBy 0NcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Bw1+HklB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id rm14-20020a17090b3ece00b00280277d721dsi78623pjb.83.2023.11.16.10.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 10:28:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Bw1+HklB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 0F04181DC7B7; Thu, 16 Nov 2023 10:28:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231294AbjKPS2m (ORCPT + 99 others); Thu, 16 Nov 2023 13:28:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbjKPS2l (ORCPT ); Thu, 16 Nov 2023 13:28:41 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A25DD1A8 for ; Thu, 16 Nov 2023 10:28:38 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1cc131e52f1so17448365ad.0 for ; Thu, 16 Nov 2023 10:28:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1700159318; x=1700764118; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7reBGJiccGvFEPh84DNhsMy+d8d0VEfZ803Vs8wYx6A=; b=Bw1+HklBx24qQvlrxlGvf87SNTxgtB2H7RSTrdsZR2AFH/KEUZU6rNkusOea1sCbaZ 6s+REsEmrGSJdW+777sPyeSg/94oYl4/QHj/FAyXh8+M8PfDWi6pDCAEIkfxgQFMh9np TfsUBXnvkRI3p21iy2fFS/mz0lThRZHYoOrjM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700159318; x=1700764118; h=in-reply-to: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=7reBGJiccGvFEPh84DNhsMy+d8d0VEfZ803Vs8wYx6A=; b=APmqezBQgU3Zr/mw3rimAaCSZbjS3UCIvHbU/ruR2fJhc0Nf2fjXVfm/i9RNK3wDSl 2TE4LbNrSRpNHhZJIaeWJXDyotchXphjI1ssEen8DvWmCOUIXFSzXlD5WRq6naq/k2U/ VEk3Cz4uyJiCImZgvjeHFJHKobzS0lVH4OMuj7zpZUkHgwrkaLGnf+zx2LCM8yjpBPRO SyzJDXJ9uUgJD8rf9vvsmCRGg/rtqkfVUlr5y064aTyFXUgHx/OykRFQeFUAkQLp7MDs sx+mn+152ZUtSBBG+uiICJj0x85OjzV5BTEYYAaOXyByi++s8wD0M1z5QFt2BPlx5syr UYhQ== X-Gm-Message-State: AOJu0YwSO4rZlwix9rsOC9aNdz9NiOwXk+wgOQIBWD9yF8Jchq0R5rUf n8XJyPw1Xx1zJAZO8Wun6ixqZw== X-Received: by 2002:a17:903:485:b0:1cc:38e6:f097 with SMTP id jj5-20020a170903048500b001cc38e6f097mr3076987plb.7.1700159318125; Thu, 16 Nov 2023 10:28:38 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id t18-20020a1709028c9200b001bdeedd8579sm9514614plo.252.2023.11.16.10.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 10:28:37 -0800 (PST) Date: Thu, 16 Nov 2023 10:28:37 -0800 From: Kees Cook To: "Gustavo A. R. Silva" Cc: Karol Herbst , Lyude Paul , Danilo Krummrich , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] nouveau/gsp: replace zero-length array with flex-array member and use __counted_by Message-ID: <202311161028.E780FBB146@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.2 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,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable 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, 16 Nov 2023 10:28:43 -0800 (PST) On Thu, Nov 16, 2023 at 12:11:43PM -0600, Gustavo A. R. Silva wrote: > Fake flexible arrays (zero-length and one-element arrays) are deprecated, > and should be replaced by flexible-array members. So, replace > zero-length array with a flexible-array member in `struct > PACKED_REGISTRY_TABLE`. > > Also annotate array `entries` with `__counted_by()` to prepare for the > coming implementation by GCC and Clang of the `__counted_by` attribute. > Flexible array members annotated with `__counted_by` can have their > accesses bounds-checked at run-time via `CONFIG_UBSAN_BOUNDS` (for array > indexing) and `CONFIG_FORTIFY_SOURCE` (for strcpy/memcpy-family functions). > > This fixes multiple -Warray-bounds warnings: > drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c:1069:29: warning: array subscript 0 is outside array bounds of 'PACKED_REGISTRY_ENTRY[0]' [-Warray-bounds=] > drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c:1070:29: warning: array subscript 0 is outside array bounds of 'PACKED_REGISTRY_ENTRY[0]' [-Warray-bounds=] > drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c:1071:29: warning: array subscript 0 is outside array bounds of 'PACKED_REGISTRY_ENTRY[0]' [-Warray-bounds=] > drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c:1072:29: warning: array subscript 0 is outside array bounds of 'PACKED_REGISTRY_ENTRY[0]' [-Warray-bounds=] > > While there, also make use of the struct_size() helper, and address > checkpatch.pl warning: > WARNING: please, no spaces at the start of a line > > This results in no differences in binary output. > > Signed-off-by: Gustavo A. R. Silva Looks nice to me. Reviewed-by: Kees Cook -- Kees Cook