[PATCH 3/4] binder: Add flags to relinquish ownership of fds
Hillf Danton
hdanton at sina.com
Tue Jan 10 01:47:20 UTC 2023
On 9 Jan 2023 21:38:06 +0000 T.J. Mercier <tjmercier at google.com>
>
> @@ -2275,6 +2276,26 @@ static int binder_translate_fd(u32 fd, binder_size_t fd_offset,
> goto err_security;
> }
>
> + if (IS_ENABLED(CONFIG_MEMCG) && (flags & BINDER_FD_FLAG_XFER_CHARGE)) {
> + struct dma_buf *dmabuf;
> +
> + if (unlikely(!is_dma_buf_file(file))) {
> + binder_user_error(
> + "%d:%d got transaction with XFER_CHARGE for non-dmabuf fd, %d\n",
> + proc->pid, thread->pid, fd);
> + ret = -EINVAL;
> + goto err_dmabuf;
> + }
It barely makes sense to expose is_dma_buf_file() only for this.
> +
> + dmabuf = file->private_data;
> + ret = dma_buf_transfer_charge(dmabuf, target_proc->tsk);
> + if (ret) {
> + pr_warn("%d:%d Unable to transfer DMA-BUF fd charge to %d\n",
> + proc->pid, thread->pid, target_proc->pid);
> + goto err_xfer;
> + }
> + }
> +
This whole hunk should go to dma-buf instead by adding change to
dma_buf_transfer_charge() for instance.
More information about the dri-devel
mailing list