Message ID | ZBSu2QsUJy31kjSE@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp498534wrt; Fri, 17 Mar 2023 11:39:07 -0700 (PDT) X-Google-Smtp-Source: AK7set9c2TTgD+vhZ64/jyMEVvPn9r4hyNVEWBACn1owGXXuqVvqUJeKPGU7gcusiipWRcGO4w2Y X-Received: by 2002:a05:6a20:698c:b0:d5:58df:fb93 with SMTP id t12-20020a056a20698c00b000d558dffb93mr10978910pzk.1.1679078347124; Fri, 17 Mar 2023 11:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679078347; cv=none; d=google.com; s=arc-20160816; b=aqCPp5K5NJ8SbG5hOUHctaB6OZoRgZUXlZMPmb7qJaWal13OYQAAnSvAw5tBTv7x1W jlY1MwcHpvOnHUwMMAsNXEgts0x0/6DZbq7J1IWYXmWxfjOMTouxREX+eMzKAYO7Hd8d DAT7HQUxzft0FBPaDjOjk7paUnrj75ZdndZMm6Il5L+SPh5F0QtBprvHHYkdTuVzrfuB r5D9nt/LtGqkhkmLMY9BwqPUFJHrlrmxXqpBniFk4gAtBxLV1+iMVF3qFMiMSLRZ570K b4Rz0AnYP9wAfgnxbkquTeWnUm+1yC8rNlrC1i0Qn3qNoW09LtH+XVM+OIHaK/J0OgIW b8LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=mfP6xePY+Pb+GNuFJlSkNR1G10NDEVmW4qJe/OcLVdY=; b=x/ESXewgBDZRADzxKM4JX/+oiqHmmd+iswa09Bi0R+y+hdLeY2fXaOlB8q7wTUQHm4 eYCTD13wOcz/OeOCLHpFcBf9Fq1D30Qd4RHCVE4Mvgy47RIOCzrv3duAgP/ssVw2UB6G NIsOcPqot+1czdt7DaHVffbI99HNILyDAsbFJ4xYAGbMuJBg7P73T9DqE/LFFLU7ryRm t2+OlXoubWP6qo28S/UfftgVU75gpK9Nclg8iNzP/K1fu1YPF1a4JJ3+hsT4yqS9Z3TM AflZ5NHNFTRQ02/uu/OENeVVqNKGvaBN6C8b8UcuefWpSassP9oV0EZ9LT6EanrP3L1e rWUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NaiXWbmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e29-20020a630f1d000000b0050c164c8e9asi1824072pgl.19.2023.03.17.11.38.51; Fri, 17 Mar 2023 11:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NaiXWbmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230363AbjCQSRj (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Fri, 17 Mar 2023 14:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbjCQSRh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 17 Mar 2023 14:17:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3A76CA78A; Fri, 17 Mar 2023 11:17:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9DA7BB82694; Fri, 17 Mar 2023 18:17:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D4F7C433D2; Fri, 17 Mar 2023 18:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679077052; bh=fbZaO/bjuHxIfSFiexEmKgUXmB5DqFSacCk1E1Qa7kA=; h=Date:From:To:Cc:Subject:From; b=NaiXWbmMipdUChL0sNZn8tHfaLYCNmL+GrJeQF+JVWwxbhF0cbT7JbbIdXL+Yln3C AYqXCMw7qwyYpUDj4C0DokfbR+wnEeW88kKEKjb0piZayVMG4sppxzRMg94P2yOVNq MUEYUkWMqcyM6KKsFxD94M36dquiAul4LFGp535RYZ5uXfi+HM991iMEVmHl/5wzDc t0MixSJk3S0gsYlC7ng1ePrMlMrvGKTV/gFlqLVumweHbTTROsxZEBKL3896j4jO/0 UszBUQSoo7ug+g8Mo31pf/iXpDMbHRW0IwaESH1kFKqSHPgB3V/F7AWp8f4bOmi5oz sMTi4kpTm9KFw== Date: Fri, 17 Mar 2023 12:18:01 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Jani Nikula <jani.nikula@linux.intel.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch> Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member Message-ID: <ZBSu2QsUJy31kjSE@work> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760641256651987374?= X-GMAIL-MSGID: =?utf-8?q?1760641256651987374?= |
Series |
[next] drm/i915/uapi: Replace fake flex-array with flexible-array member
|
|
Commit Message
Gustavo A. R. Silva
March 17, 2023, 6:18 p.m. UTC
Zero-length arrays as fake flexible arrays are deprecated and we are
moving towards adopting C99 flexible-array members instead.
Address the following warning found with GCC-13 and
-fstrict-flex-arrays=3 enabled:
drivers/gpu/drm/i915/gem/i915_gem_context.c: In function ‘set_proto_ctx_engines.isra’:
drivers/gpu/drm/i915/gem/i915_gem_context.c:769:41: warning: array subscript n is outside array bounds of ‘struct i915_engine_class_instance[0]’ [-Warray-bounds=]
769 | if (copy_from_user(&ci, &user->engines[n], sizeof(ci))) {
| ^~~~~~~~~~~~~~~~~
./include/uapi/drm/i915_drm.h:2494:43: note: while referencing ‘engines’
2494 | struct i915_engine_class_instance engines[0];
This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].
Link: https://github.com/KSPP/linux/issues/21
Link: https://github.com/KSPP/linux/issues/271
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
include/uapi/drm/i915_drm.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, Mar 17, 2023 at 12:18:01PM -0600, Gustavo A. R. Silva wrote: > Zero-length arrays as fake flexible arrays are deprecated and we are > moving towards adopting C99 flexible-array members instead. > > Address the following warning found with GCC-13 and > -fstrict-flex-arrays=3 enabled: > drivers/gpu/drm/i915/gem/i915_gem_context.c: In function ‘set_proto_ctx_engines.isra’: > drivers/gpu/drm/i915/gem/i915_gem_context.c:769:41: warning: array subscript n is outside array bounds of ‘struct i915_engine_class_instance[0]’ [-Warray-bounds=] > 769 | if (copy_from_user(&ci, &user->engines[n], sizeof(ci))) { > | ^~~~~~~~~~~~~~~~~ > ./include/uapi/drm/i915_drm.h:2494:43: note: while referencing ‘engines’ > 2494 | struct i915_engine_class_instance engines[0]; > > This helps with the ongoing efforts to tighten the FORTIFY_SOURCE > routines on memcpy() and help us make progress towards globally > enabling -fstrict-flex-arrays=3 [1]. > > Link: https://github.com/KSPP/linux/issues/21 > Link: https://github.com/KSPP/linux/issues/271 > Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1] > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org>
On 20/03/2023 17:36, Kees Cook wrote: > On Fri, Mar 17, 2023 at 12:18:01PM -0600, Gustavo A. R. Silva wrote: >> Zero-length arrays as fake flexible arrays are deprecated and we are >> moving towards adopting C99 flexible-array members instead. >> >> Address the following warning found with GCC-13 and >> -fstrict-flex-arrays=3 enabled: >> drivers/gpu/drm/i915/gem/i915_gem_context.c: In function ‘set_proto_ctx_engines.isra’: >> drivers/gpu/drm/i915/gem/i915_gem_context.c:769:41: warning: array subscript n is outside array bounds of ‘struct i915_engine_class_instance[0]’ [-Warray-bounds=] >> 769 | if (copy_from_user(&ci, &user->engines[n], sizeof(ci))) { >> | ^~~~~~~~~~~~~~~~~ >> ./include/uapi/drm/i915_drm.h:2494:43: note: while referencing ‘engines’ >> 2494 | struct i915_engine_class_instance engines[0]; >> >> This helps with the ongoing efforts to tighten the FORTIFY_SOURCE >> routines on memcpy() and help us make progress towards globally >> enabling -fstrict-flex-arrays=3 [1]. >> >> Link: https://github.com/KSPP/linux/issues/21 >> Link: https://github.com/KSPP/linux/issues/271 >> Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1] >> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > > Reviewed-by: Kees Cook <keescook@chromium.org> Flexible array member is even consistent with the rest of our uapi, pushed to drm-intel-gt-next, thanks! Regards, Tvrtko
Hi all, Friendly ping: who can take this, please? 😄 Thanks
On Thu, 30 Mar 2023, "Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:
> Friendly ping: who can take this, please? 😄
It's in drm-intel-gt-next.
commit 02abecdeebfcd3848b26b70778dd7f6eb0db65e1
Author: Gustavo A. R. Silva <gustavoars@kernel.org>
AuthorDate: Fri Mar 17 12:18:01 2023 -0600
Commit: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
CommitDate: Tue Mar 21 08:41:18 2023 +0000
drm/i915/uapi: Replace fake flex-array with flexible-array member
On 3/31/23 01:02, Jani Nikula wrote: > On Thu, 30 Mar 2023, "Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote: >> Friendly ping: who can take this, please? 😄 > > It's in drm-intel-gt-next. Awesome. :) Thank you! -- Gustavo > > commit 02abecdeebfcd3848b26b70778dd7f6eb0db65e1 > Author: Gustavo A. R. Silva <gustavoars@kernel.org> > AuthorDate: Fri Mar 17 12:18:01 2023 -0600 > Commit: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > CommitDate: Tue Mar 21 08:41:18 2023 +0000 > > drm/i915/uapi: Replace fake flex-array with flexible-array member > >
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 8df261c5ab9b..5e458d6f2895 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -2491,7 +2491,7 @@ struct i915_context_param_engines { #define I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 /* see i915_context_engines_load_balance */ #define I915_CONTEXT_ENGINES_EXT_BOND 1 /* see i915_context_engines_bond */ #define I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT 2 /* see i915_context_engines_parallel_submit */ - struct i915_engine_class_instance engines[0]; + struct i915_engine_class_instance engines[]; } __attribute__((packed)); #define I915_DEFINE_CONTEXT_PARAM_ENGINES(name__, N__) struct { \