[Intel-gfx] [PATCH] drm/i915: Extend GET_APERTURE ioctl to report available map space

Chris Wilson chris at chris-wilson.co.uk
Mon Sep 15 17:29:55 CEST 2014


On Mon, Sep 15, 2014 at 04:52:27PM +0300, Konstantin Belousov wrote:
> So what will happen when old usermode program (with short old structure)
> calls the ioctl ?  I believe the memory which happens to be located
> after the structure is corrupted, or am I missing some magic there ?
> 
> I.e., the question is why this patch does not break the ABI.

The ioctl is buffered in drm_ioctl. Space large enough for the kernel
structure is allocated from the heap/stack and the incoming user
structure (if required) is copied into the kernel struct and zero
extended. After the ioctl, if the struct is an out parameter, what fits
into the userspace struct is copied back from the kernel struct. This
has the dual benefit of allowing us to extend structures so long as we
take care that incoming zeroes from old userspace retain existing
behaviour, and vice versa with new userspace and old kernels, and also
moves the copy_from_user/copy_to_uesr dance for the majority of cases
into a single place (at the cost of giving up some microoptimisations).
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre



More information about the Intel-gfx mailing list