mirror_ubuntu-kernels/drivers/gpu/drm/nouveau/nvif
Kees Cook 4076ea2419 drm/nouveau/disp: Fix nvif_outp_acquire_dp() argument size
Both Coverity and GCC with -Wstringop-overflow noticed that
nvif_outp_acquire_dp() accidentally defined its second argument with 1
additional element:

drivers/gpu/drm/nouveau/dispnv50/disp.c: In function 'nv50_pior_atomic_enable':
drivers/gpu/drm/nouveau/dispnv50/disp.c:1813:17: error: 'nvif_outp_acquire_dp' accessing 16 bytes in a region of size 15 [-Werror=stringop-overflow=]
 1813 |                 nvif_outp_acquire_dp(&nv_encoder->outp, nv_encoder->dp.dpcd, 0, 0, false, false);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/nouveau/dispnv50/disp.c:1813:17: note: referencing argument 2 of type 'u8[16]' {aka 'unsigned char[16]'}
drivers/gpu/drm/nouveau/include/nvif/outp.h:24:5: note: in a call to function 'nvif_outp_acquire_dp'
   24 | int nvif_outp_acquire_dp(struct nvif_outp *, u8 dpcd[16],
      |     ^~~~~~~~~~~~~~~~~~~~

Avoid these warnings by defining the argument size using the matching
define (DP_RECEIVER_CAP_SIZE, 15) instead of having it be a literal
(and incorrect) value (16).

Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1527269 ("Memory - corruptions")
Addresses-Coverity-ID: 1527268 ("Memory - corruptions")
Link: https://lore.kernel.org/lkml/202211100848.FFBA2432@keescook/
Link: https://lore.kernel.org/lkml/202211100848.F4C2819BB@keescook/
Fixes: 8134437213 ("drm/nouveau/disp: move DP link config into acquire")
Reviewed-by: Lyude Paul <lyude@redhat.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Karol Herbst <kherbst@redhat.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: dri-devel@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20221127183036.never.139-kees@kernel.org
2023-01-27 11:42:41 -08:00
..
client.c drm/nouveau: rip out nvkm_client.super 2021-08-18 19:00:15 +10:00
conn.c drm/nouveau/disp: expose conn event class 2022-11-09 10:44:27 +10:00
device.c drm/nouveau/nvif: give every usermode object a human-readable identifier 2020-07-24 18:50:51 +10:00
disp.c drm/nouveau/disp: add head class 2022-11-09 10:43:10 +10:00
driver.c drm/nouveau/nvif: rename client ctor/dtor 2020-07-24 18:50:50 +10:00
event.c drm/nouveau/nvkm: add a replacement for nvkm_notify 2022-11-09 10:44:26 +10:00
fifo.c drm/nouveau/fifo/gk104-: remove use of subdev index in runlist topology info 2021-02-11 11:49:58 +10:00
head.c drm/nouveau/disp: expose head event class 2022-11-09 10:44:27 +10:00
Kbuild drm/nouveau/nvkm: rip out old notify 2022-11-09 10:44:27 +10:00
mem.c drm/nouveau/nvif: give every mem object a human-readable identifier 2020-07-24 18:50:51 +10:00
mmu.c drm/nouveau/nvif: give every mmu object a human-readable identifier 2020-07-24 18:50:50 +10:00
object.c drm/nouveau/nvif: add wrapper for open-coded nvif_object_constructed() 2022-07-13 13:55:12 +10:00
outp.c drm/nouveau/disp: Fix nvif_outp_acquire_dp() argument size 2023-01-27 11:42:41 -08:00
timer.c drm/nouveau/nvif: protect waits against GPU falling off the bus 2020-04-07 14:37:50 +10:00
user.c drm/nouveau/vfn: move NV_USERMODE class from host 2022-11-09 10:44:36 +10:00
userc361.c drm/nouveau/nvif: access PTIMER through usermode class, if available 2020-04-07 14:37:50 +10:00
vmm.c drm/nouveau/nvif: give every vmm object a human-readable identifier 2020-07-24 18:50:51 +10:00