Re: Q: sys_personality() && misc oddities

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Oleg Nesterov
Date: Wednesday, May 26, 2010 - 5:36 am

On 05/25, Roland McGrath wrote:

OK,


Yes, libc itself is fine. But from the application's pov, personality()
returns int, not long.


it is already 'unsigned int' ;)


I think the same.


Yes! and despite the fact it returns -EINVAL, current->personality was
changed. This can't be right.


Well. Think about personality(0xffffffff - 1). It passes both checks
and we change current->personality. Then the application calls
personality() again, we return the old value, and since the user-space
expects "int" it gets -2.

How about

	if (personality != 0xffffffff) {
		if (personality >= 0x7fffffff)
			return -EINVAL;
		set_personality(personality);
	}

? Now that personality always fits into "insigned int" we don't need
to recheck current->personality == personality, and "< 0x7fffffff"
gurantees that "int old_personality = personality(whatever)" in user
space can be never misinterpeted as error.

As for the other oddities, they need the separate patches. Or we can
just leave this code alone ;)

Oleg.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Q: sys_personality() &amp;&amp; misc oddities, Oleg Nesterov, (Tue May 25, 7:17 am)
Re: Q: sys_personality() &amp;&amp; misc oddities, Roland McGrath, (Tue May 25, 12:33 pm)
Re: Q: sys_personality() && misc oddities, Oleg Nesterov, (Wed May 26, 5:36 am)
Re: Q: sys_personality() &amp;&amp; misc oddities, Roland McGrath, (Wed May 26, 1:31 pm)
Re: Q: sys_personality() &amp;&amp; misc oddities, H. Peter Anvin, (Wed May 26, 1:35 pm)
[PATCH 0/2] sys_personality fixes v2, Oleg Nesterov, (Fri May 28, 12:11 pm)
Re: [PATCH 0/2] sys_personality fixes v2, Linus Torvalds, (Fri May 28, 12:28 pm)
Re: [PATCH 0/2] sys_personality fixes v2, H. Peter Anvin, (Fri May 28, 12:58 pm)
Re: [PATCH 0/2] sys_personality fixes v2, Oleg Nesterov, (Fri May 28, 12:59 pm)