Skip to content

Commit 03c318a

Browse files
houlz0507superm1
authored andcommitted
accel/amdxdna: Add zero check for pad in ioctl input structures
For input ioctl structures, it is better to check if the pad is zero. Thus, the pad bytes might be usable in the future. Suggested-by: Jeffrey Hugo <[email protected]> Signed-off-by: Lizhi Hou <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent d343577 commit 03c318a

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

drivers/accel/amdxdna/aie2_ctx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,9 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 size
690690
int ret;
691691

692692
XDNA_DBG(xdna, "Config %d CU to %s", config->num_cus, hwctx->name);
693+
if (XDNA_MBZ_DBG(xdna, config->pad, sizeof(config->pad)))
694+
return -EINVAL;
695+
693696
if (hwctx->status != HWCTX_STAT_INIT) {
694697
XDNA_ERR(xdna, "Not support re-config CU");
695698
return -EINVAL;

drivers/accel/amdxdna/aie2_message.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ int aie2_config_cu(struct amdxdna_hwctx *hwctx)
395395
for (i = 0; i < hwctx->cus->num_cus; i++) {
396396
struct amdxdna_cu_config *cu = &hwctx->cus->cu_configs[i];
397397

398+
if (XDNA_MBZ_DBG(xdna, cu->pad, sizeof(cu->pad)))
399+
return -EINVAL;
400+
398401
gobj = drm_gem_object_lookup(hwctx->client->filp, cu->cu_bo);
399402
if (!gobj) {
400403
XDNA_ERR(xdna, "Lookup GEM object failed");

drivers/accel/amdxdna/amdxdna_ctx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ int amdxdna_drm_destroy_hwctx_ioctl(struct drm_device *dev, void *data, struct d
243243
struct amdxdna_hwctx *hwctx;
244244
int ret = 0, idx;
245245

246+
if (XDNA_MBZ_DBG(xdna, &args->pad, sizeof(args->pad)))
247+
return -EINVAL;
248+
246249
if (!drm_dev_enter(dev, &idx))
247250
return -ENODEV;
248251

@@ -277,6 +280,9 @@ int amdxdna_drm_config_hwctx_ioctl(struct drm_device *dev, void *data, struct dr
277280
void *buf;
278281
u64 val;
279282

283+
if (XDNA_MBZ_DBG(xdna, &args->pad, sizeof(args->pad)))
284+
return -EINVAL;
285+
280286
if (!xdna->dev_info->ops->hwctx_config)
281287
return -EOPNOTSUPP;
282288

drivers/accel/amdxdna/amdxdna_gem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ int amdxdna_drm_get_bo_info_ioctl(struct drm_device *dev, void *data, struct drm
552552
struct drm_gem_object *gobj;
553553
int ret = 0;
554554

555-
if (args->ext || args->ext_flags)
555+
if (args->ext || args->ext_flags || args->pad)
556556
return -EINVAL;
557557

558558
gobj = drm_gem_object_lookup(filp, args->handle);

include/uapi/drm/amdxdna_accel.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct amdxdna_drm_create_hwctx {
8787
/**
8888
* struct amdxdna_drm_destroy_hwctx - Destroy hardware context.
8989
* @handle: Hardware context handle.
90-
* @pad: Structure padding.
90+
* @pad: MBZ.
9191
*/
9292
struct amdxdna_drm_destroy_hwctx {
9393
__u32 handle;
@@ -98,7 +98,7 @@ struct amdxdna_drm_destroy_hwctx {
9898
* struct amdxdna_cu_config - configuration for one CU
9999
* @cu_bo: CU configuration buffer bo handle.
100100
* @cu_func: Function of a CU.
101-
* @pad: Structure padding.
101+
* @pad: MBZ.
102102
*/
103103
struct amdxdna_cu_config {
104104
__u32 cu_bo;
@@ -109,7 +109,7 @@ struct amdxdna_cu_config {
109109
/**
110110
* struct amdxdna_hwctx_param_config_cu - configuration for CUs in hardware context
111111
* @num_cus: Number of CUs to configure.
112-
* @pad: Structure padding.
112+
* @pad: MBZ.
113113
* @cu_configs: Array of CU configurations of struct amdxdna_cu_config.
114114
*/
115115
struct amdxdna_hwctx_param_config_cu {
@@ -133,7 +133,7 @@ enum amdxdna_drm_config_hwctx_param {
133133
* @param_val: A structure specified by the param_type struct member.
134134
* @param_val_size: Size of the parameter buffer pointed to by the param_val.
135135
* If param_val is not a pointer, driver can ignore this.
136-
* @pad: Structure padding.
136+
* @pad: MBZ.
137137
*
138138
* Note: if the param_val is a pointer pointing to a buffer, the maximum size
139139
* of the buffer is 4KiB(PAGE_SIZE).
@@ -175,7 +175,7 @@ struct amdxdna_drm_create_bo {
175175
* @ext: MBZ.
176176
* @ext_flags: MBZ.
177177
* @handle: DRM buffer object handle.
178-
* @pad: Structure padding.
178+
* @pad: MBZ.
179179
* @map_offset: Returned DRM fake offset for mmap().
180180
* @vaddr: Returned user VA of buffer. 0 in case user needs mmap().
181181
* @xdna_addr: Returned XDNA device virtual address.

0 commit comments

Comments
 (0)