accel/amdxdna: Reject zero length user buffer entry
Lizhi Hou
maintainerPATCH 1/1 accel/amdxdna: Reject zero length user buffer entry
DRM_IOCTL_AMDXDNA_CREATE_BO with DRM_AMDXDNA_BO_SHARE_DEV_MEM takes an array of user space VA entries. Each entry is validated for page alignment only. A zero length is page aligned, thus an entry with length zero is accepted. Such an entry contributes no page to the buffer.
Reject a zero length entry in the validation loop.
--- drivers/accel/amdxdna/amdxdna_ubuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/accel/amdxdna/amdxdna_ubuf.c +2 -1
@@ -111,7 +111,8 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,for (i =0 , exp_info.size =0 ; i < num_entries; i++) {if (!IS_ALIGNED (va_ent[i].vaddr,PAGE_SIZE ) || - !IS_ALIGNED (va_ent[i].len,PAGE_SIZE )) { + !IS_ALIGNED (va_ent[i].len,PAGE_SIZE ) || + !va_ent[i].len) {XDNA_ERR (xdna,"Invalid address or len %llx, %llx" , va_ent[i].vaddr, va_ent[i].len); ret = -EINVAL ;
Signature · 1 line
2.34.1
Quoted 19 lines · Lizhi Hou
DRM_IOCTL_AMDXDNA_CREATE_BOwithDRM_AMDXDNA_BO_SHARE_DEV_MEMtakes an array of user space VA entries. Each entry is validated for page alignment only. A zero length is page aligned, thus an entry with length zero is accepted. Such an entry contributes no page to the buffer.Reject a zero length entry in the validation loop.
Fixes bd72d4acda10 ("accel/amdxdna: Support user space allocated buffer")Signed-off-by Lizhi Hou <[email protected]>--- drivers/accel/amdxdna/amdxdna_ubuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/accel/amdxdna/amdxdna_ubuf.c +0
-0
drivers/accel/amdxdna/amdxdna_ubuf.c struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev, · line 115
Quoted 6 lines
drivers/accel/amdxdna/amdxdna_ubuf.c +2
-1@@ -111,7 +111,8 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,for (i =0 , exp_info.size =0 ; i < num_entries; i++) {if (!IS_ALIGNED (va_ent[i].vaddr,PAGE_SIZE ) || - !IS_ALIGNED (va_ent[i].len,PAGE_SIZE )) { + !IS_ALIGNED (va_ent[i].len,PAGE_SIZE ) || + !va_ent[i].len) {
/David
Quoted 3 lines
drivers/accel/amdxdna/amdxdna_ubuf.c +0
-0XDNA_ERR (xdna,"Invalid address or len %llx, %llx" , va_ent[i].vaddr, va_ent[i].len); ret = -EINVAL ;