OSDN Git Service

drm/mga/mga_ioc32: Use struct_group() for memcpy() region
authorKees Cook <keescook@chromium.org>
Tue, 25 May 2021 06:55:11 +0000 (23:55 -0700)
committerKees Cook <keescook@chromium.org>
Sat, 25 Sep 2021 15:20:48 +0000 (08:20 -0700)
commit10579b75e02362809e8db610f3160f520607b395
tree11630843d0bbe30a220a215033e842436de0f7b1
parent43d83af8a57a0500d452a2505b297e605012960d
drm/mga/mga_ioc32: Use struct_group() for memcpy() region

In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memcpy(), memmove(), and memset(), avoid
intentionally writing across neighboring fields.

Use struct_group() in struct drm32_mga_init around members chipset, sgram,
maccess, fb_cpp, front_offset, front_pitch, back_offset, back_pitch,
depth_cpp, depth_offset, depth_pitch, texture_offset, and texture_size,
so they can be referenced together. This will allow memcpy() and sizeof()
to more easily reason about sizes, improve readability, and avoid future
warnings about writing beyond the end of chipset.

"pahole" shows no size nor member offset changes to struct drm32_mga_init.
"objdump -d" shows no meaningful object code changes (i.e. only source
line number induced differences and optimizations).

Note that since this is a UAPI header, __struct_group() is used
directly.

Cc: David Airlie <airlied@linux.ie>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Link: https://lore.kernel.org/lkml/YQKa76A6XuFqgM03@phenom.ffwll.local
drivers/gpu/drm/mga/mga_ioc32.c
include/uapi/drm/mga_drm.h