History

dma-buf: give each buffer a full-fledged inode

By traversing /proc/*/fd and /proc/*/map_files, processes with CAP_ADMIN can get a lot of fine-grained data about how shmem buffers are shared among processes. stat(2) on each entry gives the caller a unique ID (st_ino), the buffer's size (st_size), and even the number of pages currently charged to the buffer (st_blocks / 512). In contrast, all dma-bufs share the same anonymous inode. So while we can count how many dma-buf fds or mappings a process has, we can't get the size of the backing buffers or tell if two entries point to the same dma-buf. On systems with debugfs, we can get a per-buffer breakdown of size and reference count, but can't tell which processes are actually holding the references to each buffer. Replace the singleton inode with full-fledged inodes allocated by alloc_anon_inode(). This involves creating and mounting a mini-pseudo-filesystem for dma-buf, following the example in fs/aio.c.

Greg Hackmann committed 7 years ago

Commit ed63bb11 parent 51e857a2 files · +58 −6Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/magic.h+1−0
@@ -91,5 +91,6 @@ · 90 unmodified lines
91#define UDF_SUPER_MAGIC 0x1501334691#define UDF_SUPER_MAGIC 0x15013346
92#define BALLOON_KVM_MAGIC 0x1366136692#define BALLOON_KVM_MAGIC 0x13661366
93#define ZSMALLOC_MAGIC 0x5829582993#define ZSMALLOC_MAGIC 0x58295829
94#define DMA_BUF_MAGIC 0x444d4142 /* "DMAB" */
94 95
95#endif /* __LINUX_MAGIC_H__ */96#endif /* __LINUX_MAGIC_H__ */