Skip to contentSkip to conversation

x86: get rid of the insane TIF_ABI_PENDING bit

PATCH In review Oleg Nesterov 5 participants 27 messages Feb 15, 2010 – Feb 17, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

commit 05d43ed8a89c159ff641d472f970e3f1baa66318

Author: H. Peter Anvin <[email protected]>
Date:   Thu Jan 28 22:14:43 2010 -0800
Quoted 6 lines
arch/x86/include/asm/elf.h +0 -0
@@ -181,14 +181,8 @@ do {							\
 void start_thread_ia32(struct pt_regs *regs, u32 new_ip, u32 new_sp);
 #define compat_start_thread start_thread_ia32
 

arch/x86/include/asm/elf.h do { \ · line 185

Quoted 10 lines
arch/x86/include/asm/elf.h +2 -8
-#define COMPAT_SET_PERSONALITY(ex)			\
-do {							\
-	if (test_thread_flag(TIF_IA32))			\
-		clear_thread_flag(TIF_ABI_PENDING);	\
-	else						\
-		set_thread_flag(TIF_ABI_PENDING);	\
-	current->personality |= force_personality32;	\
-} while (0)
+void set_personality_ia32(void);
+#define COMPAT_SET_PERSONALITY(ex) set_personality_ia32()

OK, but what about force_personality32? With this patch it becomes unused?

arch/x86/include/asm/elf.h do { \

Quoted 9 lines
arch/x86/include/asm/elf.h +9 -0
+void set_personality_ia32(void)
+{
+	/* inherit personality from parent */
+
+	/* Make sure to be in 32bit mode */
+	set_thread_flag(TIF_IA32);
+
+	/* Prepare the first "return" to user space */
+	current_thread_info()->status |= TS_COMPAT;

Can't understand why we need TS_COMPAT. I assume this is correct, this was copied from flush_thread().

What TS_COMPAT actually means? I thought it just means "the task is inside 32-bit syscall".

If a 64bit task execs a 32bit app, can't this TS_COMPAT break, say, syscall_get_arguments() ?

Just curious, I don't really understand COMPAT issues anyway.

Oleg.

#1 lore raw
Quoted 14 lines · Oleg Nesterov

Review

Quoted 10 lines
(quoted diff) +9 -0
+void set_personality_ia32(void)
+{
+	/* inherit personality from parent */
+
+	/* Make sure to be in 32bit mode */
+	set_thread_flag(TIF_IA32);
+
+	/* Prepare the first "return" to user space */
+	current_thread_info()->status |= TS_COMPAT;

Can't understand why we need TS_COMPAT. I assume this is correct, this was copied from flush_thread().

Quoted 2 lines

What TS_COMPAT actually means? I thought it just means "the task is inside 32-bit syscall".

Yes. In this case, though, it was a 64-bit syscall when the process did the exec, but it needs to "return" as if it came from a 32-bit syscall; that's why we set the TS_COMPAT bit.

Quoted 3 lines

If a 64bit task execs a 32bit app, can't this TS_COMPAT break, say, syscall_get_arguments() ?

At that point (this is after the exec!) we don't get arguments anyway.

Quoted 1 line

Just curious, I don't really understand COMPAT issues anyway.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#2 lore raw
Quoted 16 lines · H. Peter Anvin
Quoted 14 lines · Oleg Nesterov

Review

Quoted 10 lines
(quoted diff) +9 -0
+void set_personality_ia32(void)
+{
+	/* inherit personality from parent */
+
+	/* Make sure to be in 32bit mode */
+	set_thread_flag(TIF_IA32);
+
+	/* Prepare the first "return" to user space */
+	current_thread_info()->status |= TS_COMPAT;

Can't understand why we need TS_COMPAT. I assume this is correct, this was copied from flush_thread().

Quoted 5 lines
Quoted 2 lines

What TS_COMPAT actually means? I thought it just means "the task is inside 32-bit syscall".

Yes. In this case, though, it was a 64-bit syscall when the process did the exec, but it needs to "return" as if it came from a 32-bit syscall;

Could you please point me where do we check TS_COMPAT during return to user-mode?

Quoted 5 lines
Quoted 3 lines

If a 64bit task execs a 32bit app, can't this TS_COMPAT break, say, syscall_get_arguments() ?

At that point (this is after the exec!) we don't get arguments anyway.

I meant /proc/pid/syscall, but even if I am right this probably doesn't matter.

Oleg.

#3 lore raw
Quoted 4 lines · Oleg Nesterov

Could you please point me where do we check TS_COMPAT during return to user-mode?

Sorry, I was thinking about TIF_IA32, which is examined on line 415 of entry_64.S.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

If a 64bit task execs a 32bit app, can't this TS_COMPAT break, say, syscall_get_arguments() ?

At that point (this is after the exec!) we don't get arguments anyway.

I meant /proc/pid/syscall, but even if I am right this probably doesn't matter.

What does getting the arguments from a process which has never done a system call yet even mean? Presumably we get some kind of "null answer" which depends on the default register set; in that case the compat null answer is the correct one.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#4 lore raw
Quoted 9 lines · H. Peter Anvin
Quoted 4 lines · Oleg Nesterov

Could you please point me where do we check TS_COMPAT during return to user-mode?

Sorry, I was thinking about TIF_IA32, which is examined on line 415 of entry_64.S.

Yes, I understand we should set TIF_IA32, but my question was about TS_COMPAT.

Oh. And ELF_PLAT_INIT() clears TIF_IA32... at this point it should be already cleared by SET_PERSONALITY() ?

OK. If this is all really needed, please ignore me, I don't really understand these details anyway.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

At that point (this is after the exec!) we don't get arguments anyway.

I meant /proc/pid/syscall, but even if I am right this probably doesn't matter.

What does getting the arguments from a process which has never done a system call yet even mean? Presumably we get some kind of "null answer" which depends on the default register set; in that case the compat null answer is the correct one.

Indeed, not sure what I was thinking about, thanks.

Oleg.

#5 lore raw
In reply to Oleg Nesterov
Quoted 5 lines · Oleg Nesterov

Review

Quoted 2 lines
(quoted diff) +2 -0
+void set_personality_ia32(void);
+#define COMPAT_SET_PERSONALITY(ex) set_personality_ia32()

OK, but what about force_personality32? With this patch it becomes unused?

This is a bug... I happened not to notice it before on my system force_personality32 is zero.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#6 lore raw
In reply to Oleg Nesterov
Quoted 7 lines · Oleg Nesterov

Review

Quoted 3 lines
(quoted diff) +3 -0
+
+	/* Prepare the first "return" to user space */
+	current_thread_info()->status |= TS_COMPAT;

Can't understand why we need TS_COMPAT. I assume this is correct, this was copied from flush_thread().

Quoted 8 lines

What TS_COMPAT actually means? I thought it just means "the task is inside 32-bit syscall".

If a 64bit task execs a 32bit app, can't this TS_COMPAT break, say, syscall_get_arguments() ?

Just curious, I don't really understand COMPAT issues anyway.

I suspect the purpose of TS_COMPAT is actually so you can ptrace() the newly exec'd process (and see it as a 32-bit process!) before it returns to userspace. The comment, obviously, is wrong -- that again refers to TIF_IA32.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#7 lore raw
Quoted 4 lines

I suspect the purpose of TS_COMPAT is actually so you can ptrace() the newly exec'd process (and see it as a 32-bit process!) before it returns to userspace. The comment, obviously, is wrong -- that again refers to TIF_IA32.

I don't follow you. TS_COMPAT does not affect ptrace. It affects syscall-audit, but only at syscall entry time. It affects asm/syscall.h accessors, but ptrace does not use those. It affects whatever uses is_compat_task(), but I can't see anything where that matters except inside some particular syscall or for syscall restart after signals.

TS_COMPAT does not affect the syscall return machinery itself. The return path just follows from the particular entry path.

Thanks,
Roland

#8 lore raw
Quoted 3 lines · Roland McGrath

It affects whatever uses is_compat_task(), but I can't see anything where that matters except inside some particular syscall or for syscall restart after signals.

FWIW, the origin of this is checkin 4d9bc79cd28b779610d9590b3a96a28a0f64a25a (2.6.18-rc1), which somewhat unhelpfully states "Make sure is_compat_task works early". It doesn't specify what the failure is if is_compat_task doesn't work early. On the other hand, it sure as heck seems better to set it and not need it than the other way around.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#9 lore raw
Quoted 4 lines

FWIW, the origin of this is checkin 4d9bc79cd28b779610d9590b3a96a28a0f64a25a (2.6.18-rc1), which somewhat unhelpfully states "Make sure is_compat_task works early". It doesn't specify what the failure is if is_compat_task doesn't work early.

I can't figure out what could care. Maybe at the time something else tested it that doesn't do so now.

Quoted 2 lines

On the other hand, it sure as heck seems better to set it and not need it than the other way around.

Agreed.

Thanks,
Roland

#25 lore raw
In reply to Roland McGrath
Quoted 12 lines · Roland McGrath
Quoted 4 lines

I suspect the purpose of TS_COMPAT is actually so you can ptrace() the newly exec'd process (and see it as a 32-bit process!) before it returns to userspace. The comment, obviously, is wrong -- that again refers to TIF_IA32.

I don't follow you. TS_COMPAT does not affect ptrace. It affects syscall-audit, but only at syscall entry time. It affects asm/syscall.h accessors, but ptrace does not use those. It affects whatever uses is_compat_task(), but I can't see anything where that matters except inside some particular syscall or for syscall restart after signals.

Quoted 2 lines

TS_COMPAT does not affect the syscall return machinery itself. The return path just follows from the particular entry path.

It's entirely possible it is completely superfluous. The patch in question only moves the setting. I don't know what gdb or strace use to distinguish a 32-bit and a 64-bit process, which is why I thought it might have something to do with ptrace.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#26 lore raw
Quoted 4 lines

It's entirely possible it is completely superfluous. The patch in question only moves the setting. I don't know what gdb or strace use to distinguish a 32-bit and a 64-bit process, which is why I thought it might have something to do with ptrace.

Well, whatever it that might be, they have no way to know about the TS_COMPAT setting. TS_COMPAT affects three things: audit_syscall_entry() parameters, asm/syscall.h stuff, and is_compat_task()--nothing that is directly visible from userland unless you count /proc/pid/syscall values. Notably, that includes syscall_get_error() that is used in signal recovery.

AFAICT the only interesting use of is_compat_task() is the drivers/input stuff.

Thanks,
Roland

#10 lore raw
In reply to H. Peter Anvin
Quoted 10 lines · H. Peter Anvin
Quoted 3 lines · Roland McGrath

It affects whatever uses is_compat_task(), but I can't see anything where that matters except inside some particular syscall or for syscall restart after signals.

FWIW, the origin of this is checkin 4d9bc79cd28b779610d9590b3a96a28a0f64a25a (2.6.18-rc1), which somewhat unhelpfully states "Make sure is_compat_task works early". It doesn't specify what the failure is if is_compat_task doesn't work early.

Perhaps Andi could explain us why this is needed,

Quoted 3 lines

On
the other hand, it sure as heck seems better to set it and not need it than the other way around.

Agreed, but otoh it is always good to understand the code. If we really have a reason for TS_COMPAT, a small comment can help other readers.

Oleg.

#11 lore raw
Quoted 14 lines · Oleg Nesterov
Quoted 10 lines · H. Peter Anvin
Quoted 3 lines · Roland McGrath

It affects whatever uses is_compat_task(), but I can't see anything where that matters except inside some particular syscall or for syscall restart after signals.

FWIW, the origin of this is checkin 4d9bc79cd28b779610d9590b3a96a28a0f64a25a (2.6.18-rc1), which somewhat unhelpfully states "Make sure is_compat_task works early". It doesn't specify what the failure is if is_compat_task doesn't work early.

Perhaps Andi could explain us why this is needed,

Quoted 7 lines
Quoted 3 lines

On
the other hand, it sure as heck seems better to set it and not need it than the other way around.

Agreed, but otoh it is always good to understand the code. If we really have a reason for TS_COMPAT, a small comment can help other readers.

My memory is somewhat fuzzy on this one, but I think it was related to VMA placement (probably for stack randomization or something like that) This happens before the first call. I might be wrong on that.

There might also have been other is_compat_task checks in the exec init path, so partly it was defensive programming.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#12 lore raw

cover Was: x86: get rid of the insane TIF_ABI_PENDING bit

Quoted 10 lines · Andi Kleen
Quoted 4 lines · Oleg Nesterov

Agreed, but otoh it is always good to understand the code. If we really have a reason for TS_COMPAT, a small comment can help other readers.

My memory is somewhat fuzzy on this one, but I think it was related to VMA placement (probably for stack randomization or something like that) This happens before the first call. I might be wrong on that.

Afaics we never check TS_COMPAT/is_compat_task for this...

Quoted 2 lines

There might also have been other is_compat_task checks in the exec init path, so partly it was defensive programming.

Understand, but it looks so confusing...

OK. Please feel free to ignore, but I am sending the trivial, but only compile-tested patches. My main motivation is to simplify the reading and understanding of this code.

The first patch looks like an "obvious" bugfix for 2.6.33 though, but still untested.

Oleg.

#13 lore raw

PATCH 1/3 x86: set_personality_ia32() misses force_personality32

05d43ed8a "x86: get rid of the insane TIF_ABI_PENDING bit" forgot about force_personality32, fix.

---

 arch/x86/kernel/process_64.c |    1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/process_64.c renamed from arch/x86/kernel/process_64.c~1_force_personality32 +1 -0
@@ -527,6 +527,7 @@ void set_personality_ia32(void)
 
 	/* Make sure to be in 32bit mode */
 	set_thread_flag(TIF_IA32);
+	current->personality |= force_personality32;
 
 	/* Prepare the first "return" to user space */
 	current_thread_info()->status |= TS_COMPAT;
#15 lore raw

PATCH 2/3 x86: set_personality_ia32() abuses TS_COMPAT

In reply to Oleg Nesterov

set_personality_ia32() sets TS_COMPAT for unknown reason.

This doesn't hurt but this is unneeded and confusing, TS_COMPAT means we are inside the 32bit syscall.

In fact I'd say this is not right, but fortunetely do_execve() can never return something which could confuse syscall_get_error(). And apart from do_signal() we never check TS_COMPAT during return to user-mode.

Another reason why I think this is not right. I am not sure I fully understand this asm, but it seems to me that system_call_fastpath can "leak" TS_COMPAT. While probably this doesn't really matter, we can return to user-mode with this bit set.

---

 arch/x86/kernel/process_64.c |    3 ---
 1 file changed, 3 deletions(-)
arch/x86/kernel/process_64.c renamed from arch/x86/kernel/process_64.c~2_dont_set_compat +0 -3
@@ -528,9 +528,6 @@ void set_personality_ia32(void)
 	/* Make sure to be in 32bit mode */
 	set_thread_flag(TIF_IA32);
 	current->personality |= force_personality32;
-
-	/* Prepare the first "return" to user space */
-	current_thread_info()->status |= TS_COMPAT;
 }
 
 unsigned long get_wchan(struct task_struct *p)
#23 lore raw

PATCH 3/3 x86: ELF_PLAT_INIT() shouldn't worry about TIF_IA32

In reply to Oleg Nesterov

64bit vesrion of ELF_PLAT_INIT() clears TIF_IA32, but at this point it must be already cleared by SET_PERSONALITY == set_personality_64bit.

---

 arch/x86/include/asm/elf.h |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/include/asm/elf.h renamed from arch/x86/include/asm/elf.h~3_ELF_PLAT_INIT_IA32 +1 -4
@@ -170,10 +170,7 @@ static inline void elf_common_init(struc
 }
 
 #define ELF_PLAT_INIT(_r, load_addr)			\
-do {							\
-	elf_common_init(&current->thread, _r, 0);	\
-	clear_thread_flag(TIF_IA32);			\
-} while (0)
+	elf_common_init(&current->thread, _r, 0);
 
 #define	COMPAT_ELF_PLAT_INIT(regs, load_addr)		\
 	elf_common_init(&current->thread, regs, __USER_DS)
#24 lore raw

Re: [PATCH 3/3] x86: ELF_PLAT_INIT() shouldn't worry about TIF_IA32

Review

Quoted 7 lines · Oleg Nesterov

#define ELF_PLAT_INIT(_r, load_addr) \

(quoted diff) +1 -4
-do {							\
-	elf_common_init(&current->thread, _r, 0);	\
-	clear_thread_flag(TIF_IA32);			\
-} while (0)
+	elf_common_init(&current->thread, _r, 0);
                                                ^

unneeded semicolon, sorry...

------------------------------------------------------------------------------
[PATCH 3/3] x86: ELF_PLAT_INIT() shouldn't worry about TIF_IA32

64bit vesrion of ELF_PLAT_INIT() clears TIF_IA32, but at this point it must be already cleared by SET_PERSONALITY == set_personality_64bit.

---

 arch/x86/include/asm/elf.h |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/include/asm/elf.h renamed from arch/x86/include/asm/elf.h~3_ELF_PLAT_INIT_IA32 +1 -4
@@ -170,10 +170,7 @@ static inline void elf_common_init(struc
 }
 
 #define ELF_PLAT_INIT(_r, load_addr)			\
-do {							\
-	elf_common_init(&current->thread, _r, 0);	\
-	clear_thread_flag(TIF_IA32);			\
-} while (0)
+	elf_common_init(&current->thread, _r, 0)
 
 #define	COMPAT_ELF_PLAT_INIT(regs, load_addr)		\
 	elf_common_init(&current->thread, regs, __USER_DS)
#16 lore raw

Re: [PATCH 2/3] x86: set_personality_ia32() abuses TS_COMPAT

In reply to Oleg Nesterov
Quoted 5 lines · Oleg Nesterov

In fact I'd say this is not right, but fortunetely do_execve() can never return something which could confuse syscall_get_error(). And apart from do_signal() we never check TS_COMPAT during return to user-mode.

But 'do_signal()' _can_ happen the first thing after an execve(), no?

And after we have switched to 32-bit mode, we _are_ inside a 32-bit system
call: the execve has "changed" from a 64-bit one to a 32-bit one.

So I really don't understand why you dislike TS_COMPAT here.

I understand not liking TS_COMPAT in the first place (it would be nice to not have that flag at all), but considering that it exists, and it is supposed to be set while in 32-bit system calls, setting it on a 32-bit execve() seems to be the RightThing(tm) to do.

Linus

#17 lore raw

Re: [PATCH 2/3] x86: set_personality_ia32() abuses TS_COMPAT

Quoted 9 lines · Linus Torvalds
Quoted 5 lines · Oleg Nesterov

In fact I'd say this is not right, but fortunetely do_execve() can never return something which could confuse syscall_get_error(). And apart from do_signal() we never check TS_COMPAT during return to user-mode.

But 'do_signal()' _can_ happen the first thing after an execve(), no?

this is what I meant,

Quoted 2 lines

And after we have switched to 32-bit mode, we _are_ inside a 32-bit system
call: the execve has "changed" from a 64-bit one to a 32-bit one.

And this is what I do not understand, we are still in 64-bit execve.

With ot without TS_COMPAT we take the same return path and I can't see why should we sign-extend ->ax. But I didn't claim this is wrong, and it is possible I missed something.

Quoted 1 line

So I really don't understand why you dislike TS_COMPAT here.

The only reason I dislike TS_COMPAT is that I spent a lot of time trying to understand the necessity to set it here when I tried to understand the basics of compat issues.

Quoted 4 lines

I understand not liking TS_COMPAT in the first place (it would be nice to not have that flag at all), but considering that it exists, and it is supposed to be set while in 32-bit system calls, setting it on a 32-bit execve() seems to be the RightThing(tm) to do.

OK, please ignore the patch then.

As I said, only the first patch probably makes sense, and even it was not tested.

Cough. And since I already made a lot of noise...

Now that we always call setup_new_exec() which does arch_pick_mmap_layout(), what is the point of exec_mmap()->arch_pick_mmap_layout() ?

Oleg.

#18 lore raw

Re: [PATCH 2/3] x86: set_personality_ia32() abuses TS_COMPAT

Quoted 5 lines · Oleg Nesterov

The only reason I dislike TS_COMPAT is that I spent a lot of time trying to understand the necessity to set it here when I tried to understand the basics of compat issues.

Just to throw something else into here...

please also keep in mind that there is value to the notion of keeping a software invariant true. In this case, even if setting TS_COMPAT doesn't do anything *right now*, it helps maintain an invariant which might avoid bugs in the future.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#19 lore raw

Re: [PATCH 2/3] x86: set_personality_ia32() abuses TS_COMPAT

In reply to Linus Torvalds
Quoted 5 lines · Linus Torvalds

And after we have switched to 32-bit mode, we _are_ inside a 32-bit system
call: the execve has "changed" from a 64-bit one to a 32-bit one.

So I really don't understand why you dislike TS_COMPAT here.

and, following this logic, shouldn't set_personality_64bit() clear TS_COMPAT ?

OK, in any case I do not claim we need fixes. Just I am confused.

Oleg.

#20 lore raw

Re: [PATCH 2/3] x86: set_personality_ia32() abuses TS_COMPAT

Quoted 10 lines · Oleg Nesterov
Quoted 5 lines · Linus Torvalds

And after we have switched to 32-bit mode, we _are_ inside a 32-bit system
call: the execve has "changed" from a 64-bit one to a 32-bit one.

So I really don't understand why you dislike TS_COMPAT here.

and, following this logic, shouldn't set_personality_64bit() clear TS_COMPAT ?

It's quite possible it should... I haven't dug into if that isn't either done elsewhere or isn't done for some other reason. This would be worth looking into.

Quoted 1 line

OK, in any case I do not claim we need fixes. Just I am confused.

Trying to understand the code is good. However, you seem to have started out with a point of view that we should have the minimal set of state changes possible instead of keeping state as self-consistent as possible. Invariants are a Very Good Thing. Documented invariants are even better ;)

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#22 lore raw

Re: [PATCH 2/3] x86: set_personality_ia32() abuses TS_COMPAT

In reply to Oleg Nesterov
Quoted 3 lines · Oleg Nesterov

and, following this logic, shouldn't set_personality_64bit() clear TS_COMPAT ?

Yes, I think it should. If we come from a 32-bit environment, and execute a 64-bit binary, I think the execve() environment of the new 64-bit binary should be _exactly_ the same as if it was executed from a 64-bit one.

Of course, it's entirely possible that TS_COMPAT simply doesn't matter at all in either context, but I do think that we should strive for "the binary does exactly the same regardless of whether it was started from a 32-bit or a 64-bit binary".

And the best way to guarantee that is to make sure that we really do set the environment to the same thing. So yes, set_personality_64bit() should clear all the 32-bit compat bits.

Linus

#14 lore raw

[tip:x86/urgent] x86: set_personality_ia32() misses force_personality32

In reply to Oleg Nesterov
Commit-ID:  1dfc76ec37a59018d8ed39152695ff27a434415b
Gitweb:     http://git.kernel.org/tip/1dfc76ec37a59018d8ed39152695ff27a434415b
Author:     Oleg Nesterov <[email protected]>
AuthorDate: Tue, 16 Feb 2010 15:02:13 +0100
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 16 Feb 2010 09:44:30 -0800

x86: set_personality_ia32() misses force_personality32

05d43ed8a "x86: get rid of the insane TIF_ABI_PENDING bit" forgot about force_personality32, fix.

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/process_64.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/x86/kernel/process_64.c +1 -0
index 41a26a8..126f0b4 100644
@@ -527,6 +527,7 @@ void set_personality_ia32(void)
 
 	/* Make sure to be in 32bit mode */
 	set_thread_flag(TIF_IA32);
+	current->personality |= force_personality32;
 
 	/* Prepare the first "return" to user space */
 	current_thread_info()->status |= TS_COMPAT;
#21 lore raw

Re: [PATCH 2/3] x86: set_personality_ia32() abuses TS_COMPAT

In reply to H. Peter Anvin
Quoted 9 lines · H. Peter Anvin
Quoted 3 lines · Oleg Nesterov

and, following this logic, shouldn't set_personality_64bit() clear TS_COMPAT ?

It's quite possible it should... I haven't dug into if that isn't either done elsewhere or isn't done for some other reason. This would be worth looking into.

OK. This was another source of confusion for me...

Quoted 5 lines
Quoted 1 line

OK, in any case I do not claim we need fixes. Just I am confused.

Trying to understand the code is good. However, you seem to have started out with a point of view that we should have the minimal set of state changes possible

Well, I must admit... the only point of this patch was "please change your code so that I could convince myself I understand what it does" ;)

Quoted 3 lines

instead of keeping state as self-consistent as
possible. Invariants are a Very Good Thing. Documented invariants are even better ;)

Agreed! But to me it looks as if TS_COMPAT breaks invariants. In particular, because set_personality_64bit() didn't clear this flag.

Anyway. At least I can assume there is no "hard" reason to set this bit currently, and this was my main question.

Thanks to all for your explanations!

Oleg.