• Kees Cook's avatar
    drm/mga/mga_ioc32: Use struct_group() for memcpy() region · 10579b75
    Kees Cook authored
    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: default avatarKees Cook <keescook@chromium.org>
    Acked-by: default avatarDaniel Vetter <daniel@ffwll.ch>
    Link: https://lore.kernel.org/lkml/YQKa76A6XuFqgM03@phenom.ffwll.local
    10579b75
mga_ioc32.c 6.09 KB