Skip to content

Commit a5bff92

Browse files
danvet-intelsumitsemwal
authored andcommitted
dma-buf: Fix SET_NAME ioctl uapi
The uapi is the same on 32 and 64 bit, but the number isn't. Everyone who botched this please re-read: https://www.kernel.org/doc/html/v5.4-preprc-cpu/ioctl/botching-up-ioctls.html Also, the type argument for the ioctl macros is for the type the void __user *arg pointer points at, which in this case would be the variable-sized char[] of a 0 terminated string. So this was botched in more than just the usual ways. Cc: Sumit Semwal <[email protected]> Cc: Chenbo Feng <[email protected]> Cc: Greg Hackmann <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: Martin Liu <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Tested-by: Martin Liu <[email protected]> Reviewed-by: Martin Liu <[email protected]> Signed-off-by: Sumit Semwal <[email protected]> [sumits: updated some checkpatch fixes, corrected author email] Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 6292b8e commit a5bff92

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/dma-buf/dma-buf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ static long dma_buf_ioctl(struct file *file,
388388

389389
return ret;
390390

391-
case DMA_BUF_SET_NAME:
391+
case DMA_BUF_SET_NAME_A:
392+
case DMA_BUF_SET_NAME_B:
392393
return dma_buf_set_name(dmabuf, (const char __user *)arg);
393394

394395
default:

include/uapi/linux/dma-buf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ struct dma_buf_sync {
3939

4040
#define DMA_BUF_BASE 'b'
4141
#define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
42+
43+
/* 32/64bitness of this uapi was botched in android, there's no difference
44+
* between them in actual uapi, they're just different numbers.
45+
*/
4246
#define DMA_BUF_SET_NAME _IOW(DMA_BUF_BASE, 1, const char *)
47+
#define DMA_BUF_SET_NAME_A _IOW(DMA_BUF_BASE, 1, u32)
48+
#define DMA_BUF_SET_NAME_B _IOW(DMA_BUF_BASE, 1, u64)
4349

4450
#endif

0 commit comments

Comments
 (0)