diff options
author | Kees Cook <keescook@chromium.org> | 2023-10-03 16:29:52 -0700 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2023-10-05 17:59:35 -0400 |
commit | c8e7df374ba2ce715ed7f3ceba34efdbfffcb0a9 (patch) | |
tree | 9292d2f7c73a1cea7111adaba095d71b25e28874 /drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h | |
parent | e0a3e7bf62dfbf6a1730f244b2adf53fac07003b (diff) | |
download | linux-c8e7df374ba2ce715ed7f3ceba34efdbfffcb0a9.tar.gz linux-c8e7df374ba2ce715ed7f3ceba34efdbfffcb0a9.tar.bz2 linux-c8e7df374ba2ce715ed7f3ceba34efdbfffcb0a9.zip |
drm/amdgpu: Annotate struct amdgpu_bo_list with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct amdgpu_bo_list.
Additionally, since the element count member must be set before accessing
the annotated flexible array member, move its initialization earlier.
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Luben Tuikov <luben.tuikov@amd.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Felix Kuehling <Felix.Kuehling@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-hardening@vger.kernel.org
Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1]
Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h index 6a703be45d04..555cd6d877c3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h @@ -56,7 +56,7 @@ struct amdgpu_bo_list { */ struct mutex bo_list_mutex; - struct amdgpu_bo_list_entry entries[]; + struct amdgpu_bo_list_entry entries[] __counted_by(num_entries); }; int amdgpu_bo_list_get(struct amdgpu_fpriv *fpriv, int id, |