Messages in this thread |  | | Date | Tue, 24 Feb 2015 16:54:17 -0500 | From | Chris Metcalf <> | Subject | Re: [PATCH] compat: Fix endian issue in union sigval |
| |
On 2/14/2015 6:22 AM, Catalin Marinas wrote: > 1. user populates sival_int compat_sigevent and invokes > compat_sys_mq_notify() > 2. kernel get_compat_sigevent() copies compat_sigevent into the native > sigevent. compat and native sival_int are the same, no problem so > far. The other half of 64-bit sival_ptr is zeroed by a memset in this > function (this other half can be top or bottom, depending on > endianness) > 3. signal is about to be delivered to user via arch code. The > compat_ptr(from->si_ptr) conversion always takes the least > significant part of the native si_ptr. On big endian 64-bit, this is > zero because get_compat_sigevent() populated the top part of si_ptr > with si_int. > > So delivering such signals to compat user always sets si_int to 0. > Little endian is fine.
I looked at this again as I was getting ready to do a tile patch, and realized why tile and arm64 are different here: tile does a field-by-field copy in copy_siginfo_from_user32(), like parisc and s390. As a result, we initialize the 64-bit kernel si_ptr value by cast from the 32-bit user si_ptr value, rather than blindly writing into the lower-addressed half of the 64-bit sigval.
As a result, I think I will leave the existing code alone, though unfortunately that leaves it somewhat unique in manipulating the si_ptr field directly. But I think the s390 and parisc copy_siginfo_from_user32 leave the high bits of si_ptr uninitialized, which also strikes me as a bad idea in general.
-- Chris Metcalf, EZChip Semiconductor http://www.ezchip.com
|  |