Re: is avoiding compat ioctls possible?

Andi Kleen
2009-10-28T02:53:17Z

Dave Airlie <airlied@gmail.com> writes:

> They used uint64_t to represent userspace pointers and userspace
> casted into those and the kernel casts back out and passes it to copy_*_user

uint64_t is actually dangerous due to different alignment on x86-32 vs 64,
better use compat_u64/s64

> Now I thought cool I don't need to worry about compat ioctl hackery I can
> run 32 on 64 bit apps fine and it'll all just work.
>
> Now Dave Miller points out that I'm obivously deluded and we really need
> to add compat ioctls so that the kernel can truncate correctly 32-bit address
> in case userspace shoves garbage into the top 32bits of the u64.

When the user space sees a u64 field it should never shove garbage here.
You just have to cast on 32bit for this, which is a bit ugly.

However some architectures need special operations on compat pointers
(s390 iirc), but if you don't support those it might be reasonable
to not support that.

> Is there really no way to avoid compat ioctls? was I delusional in
> thinking there was?

Experience shows that people make mistakes and you sooner or
later need them anyways to work around them.

-Andi

--
ak@linux.intel.com -- Speaking for myself only.