* [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member
@ 2023-03-17 18:18 Gustavo A. R. Silva
2023-03-20 17:36 ` Kees Cook
2023-03-30 20:13 ` Gustavo A. R. Silva
0 siblings, 2 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2023-03-17 18:18 UTC (permalink / raw)
To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
David Airlie, Daniel Vetter
Cc: intel-gfx, linux-hardening, linux-kernel, dri-devel, Gustavo A. R. Silva
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(-)
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 { \
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member
2023-03-17 18:18 [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member Gustavo A. R. Silva
@ 2023-03-20 17:36 ` Kees Cook
2023-03-21 8:43 ` Tvrtko Ursulin
2023-03-30 20:13 ` Gustavo A. R. Silva
1 sibling, 1 reply; 6+ messages in thread
From: Kees Cook @ 2023-03-20 17:36 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Tvrtko Ursulin, intel-gfx, linux-kernel, dri-devel, Rodrigo Vivi,
linux-hardening
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>
--
Kees Cook
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member
2023-03-20 17:36 ` Kees Cook
@ 2023-03-21 8:43 ` Tvrtko Ursulin
0 siblings, 0 replies; 6+ messages in thread
From: Tvrtko Ursulin @ 2023-03-21 8:43 UTC (permalink / raw)
To: Kees Cook, Gustavo A. R. Silva
Cc: intel-gfx, linux-kernel, dri-devel, Rodrigo Vivi, linux-hardening
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member
2023-03-17 18:18 [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member Gustavo A. R. Silva
2023-03-20 17:36 ` Kees Cook
@ 2023-03-30 20:13 ` Gustavo A. R. Silva
2023-03-31 7:02 ` Jani Nikula
1 sibling, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2023-03-30 20:13 UTC (permalink / raw)
To: Gustavo A. R. Silva, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, David Airlie, Daniel Vetter
Cc: intel-gfx, linux-kernel, dri-devel, linux-hardening
Hi all,
Friendly ping: who can take this, please? 😄
Thanks
--
Gustavo
On 3/17/23 12:18, 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>
> ---
> include/uapi/drm/i915_drm.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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 { \
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member
2023-03-30 20:13 ` Gustavo A. R. Silva
@ 2023-03-31 7:02 ` Jani Nikula
2023-04-06 16:27 ` Gustavo A. R. Silva
0 siblings, 1 reply; 6+ messages in thread
From: Jani Nikula @ 2023-03-31 7:02 UTC (permalink / raw)
To: Gustavo A. R. Silva, Gustavo A. R. Silva, Joonas Lahtinen,
Rodrigo Vivi, Tvrtko Ursulin, David Airlie, Daniel Vetter
Cc: intel-gfx, linux-kernel, dri-devel, linux-hardening
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
--
Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member
2023-03-31 7:02 ` Jani Nikula
@ 2023-04-06 16:27 ` Gustavo A. R. Silva
0 siblings, 0 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2023-04-06 16:27 UTC (permalink / raw)
To: Jani Nikula, Gustavo A. R. Silva, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, David Airlie, Daniel Vetter
Cc: intel-gfx, linux-kernel, dri-devel, linux-hardening
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
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-06 16:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 18:18 [PATCH][next] drm/i915/uapi: Replace fake flex-array with flexible-array member Gustavo A. R. Silva
2023-03-20 17:36 ` Kees Cook
2023-03-21 8:43 ` Tvrtko Ursulin
2023-03-30 20:13 ` Gustavo A. R. Silva
2023-03-31 7:02 ` Jani Nikula
2023-04-06 16:27 ` Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).