Re: [RFC PATCH v3 1/6] uapi: add goldfish_address_space userspace ABI header
From: Arnd Bergmann
Date: Mon Apr 13 2026 - 12:52:52 EST
On Mon, Apr 6, 2026, at 18:51, Wenzhao Liao wrote:
> +struct goldfish_address_space_allocate_block {
> + __u64 size;
> + __u64 offset;
> + __u64 phys_addr;
> +};
> +
> +struct goldfish_address_space_ping {
> + __u64 offset;
> + __u64 size;
> + __u64 metadata;
> + __u32 version;
> + __u32 wait_fd;
> + __u32 wait_flags;
> + __u32 direction;
> +};
> +
> +struct goldfish_address_space_claim_shared {
> + __u64 offset;
> + __u64 size;
> +};
All these ioctl structures are well-formed in the sense that they
are portable across architectures and won't leak kernel data
through implicit padding.
Two of the members are a bit worrying, but that may just
be my own understanding:
- the 'phys_addr' member sounds like it refers to a physical
memory location in the CPU address space, which in general
should not be visible to user space, as that tends to
expose security problems if users with access to the
device can use this to access data they should not.
- the 'version' field may refer to the version of the ioctl
command, which is similarly discouraged since it is
harder to deal with than just coming up with new ioctl
command codes. If this refers to the version of the
remote side, this is probably fine.
> +#define GOLDFISH_ADDRESS_SPACE_IOCTL_MAGIC 'G'
> +
> +#define GOLDFISH_ADDRESS_SPACE_IOCTL_OP(OP, T) \
> + _IOWR(GOLDFISH_ADDRESS_SPACE_IOCTL_MAGIC, OP, T)
I think it would be better to remove this intermediate macro, since
it prevents easy scraping of ioctl command codes from looking
at the source file with regular expressions.
It is also unusual that all commands are both reading
and writing the data. Please check if you can make some
of them read-only or write-only.
Arnd