• L
    drm/i915/display: fix compiler warning about array overrun · fbada3d9
    Linus Torvalds 提交于
    stable inclusion
    from stable-5.10.39
    commit 80e414e7cf7da60f2986ac07e15f5d4b01c3493e
    bugzilla: 51881
    CVE: NA
    
    --------------------------------
    
    commit fec4d427 upstream.
    
    intel_dp_check_mst_status() uses a 14-byte array to read the DPRX Event
    Status Indicator data, but then passes that buffer at offset 10 off as
    an argument to drm_dp_channel_eq_ok().
    
    End result: there are only 4 bytes remaining of the buffer, yet
    drm_dp_channel_eq_ok() wants a 6-byte buffer.  gcc-11 correctly warns
    about this case:
    
      drivers/gpu/drm/i915/display/intel_dp.c: In function ‘intel_dp_check_mst_status’:
      drivers/gpu/drm/i915/display/intel_dp.c:3491:22: warning: ‘drm_dp_channel_eq_ok’ reading 6 bytes from a region of size 4 [-Wstringop-overread]
       3491 |                     !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) {
            |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/i915/display/intel_dp.c:3491:22: note: referencing argument 1 of type ‘const u8 *’ {aka ‘const unsigned char *’}
      In file included from drivers/gpu/drm/i915/display/intel_dp.c:38:
      include/drm/drm_dp_helper.h:1466:6: note: in a call to function ‘drm_dp_channel_eq_ok’
       1466 | bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE],
            |      ^~~~~~~~~~~~~~~~~~~~
           6:14 elapsed
    
    This commit just extends the original array by 2 zero-initialized bytes,
    avoiding the warning.
    
    There may be some underlying bug in here that caused this confusion, but
    this is at least no worse than the existing situation that could use
    random data off the stack.
    
    Cc: Jani Nikula <jani.nikula@intel.com>
    Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
    Cc: Dave Airlie <airlied@redhat.com>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: NChen Jun <chenjun102@huawei.com>
    Acked-by: NWeilong Chen <chenweilong@huawei.com>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    fbada3d9
intel_dp.c 227.9 KB