2012-02-26 04:25:43

by Bobby Powers

[permalink] [raw]
Subject: [PATCH] x32: make sure TS_COMPAT is cleared for x32 tasks

If a process has a non-x32 ia32 personality and changes to x32, the
process would keep its TS_COMPAT flag. x32 uses the presence of the
x32 flag on a syscall to determine compat status, so make sure
TS_COMPAT is cleared.

Signed-off-by: Bobby Powers <[email protected]>
---
arch/x86/kernel/process_64.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index e9ec8f1..a465973 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -539,6 +539,9 @@ void set_personality_ia32(bool x32)
clear_thread_flag(TIF_IA32);
set_thread_flag(TIF_X32);
current->personality &= ~READ_IMPLIES_EXEC;
+ /* is_compat_task() uses the presence of the x32
+ syscall bit flag to determine compat status */
+ current_thread_info()->status &= ~TS_COMPAT;
} else {
set_thread_flag(TIF_IA32);
clear_thread_flag(TIF_X32);
--
1.7.7.6


2012-02-26 05:51:15

by Bobby Powers

[permalink] [raw]
Subject: [tip:x86/x32] x32: Make sure TS_COMPAT is cleared for x32 tasks

Commit-ID: ce5f7a99df87918b5be4618a9386213a8e9a7146
Gitweb: http://git.kernel.org/tip/ce5f7a99df87918b5be4618a9386213a8e9a7146
Author: Bobby Powers <[email protected]>
AuthorDate: Sat, 25 Feb 2012 23:25:38 -0500
Committer: H. Peter Anvin <[email protected]>
CommitDate: Sat, 25 Feb 2012 20:42:18 -0800

x32: Make sure TS_COMPAT is cleared for x32 tasks

If a process has a non-x32 ia32 personality and changes to x32, the
process would keep its TS_COMPAT flag. x32 uses the presence of the
x32 flag on a syscall to determine compat status, so make sure
TS_COMPAT is cleared.

Signed-off-by: Bobby Powers <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: H. Peter Anvin <[email protected]>
---
arch/x86/kernel/process_64.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index a0701da..32e0412 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -540,6 +540,9 @@ void set_personality_ia32(bool x32)
clear_thread_flag(TIF_IA32);
set_thread_flag(TIF_X32);
current->personality &= ~READ_IMPLIES_EXEC;
+ /* is_compat_task() uses the presence of the x32
+ syscall bit flag to determine compat status */
+ current_thread_info()->status &= ~TS_COMPAT;
} else {
set_thread_flag(TIF_IA32);
clear_thread_flag(TIF_X32);

2012-02-26 05:55:23

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] x32: make sure TS_COMPAT is cleared for x32 tasks

On 02/25/2012 08:25 PM, Bobby Powers wrote:
> If a process has a non-x32 ia32 personality and changes to x32, the
> process would keep its TS_COMPAT flag. x32 uses the presence of the
> x32 flag on a syscall to determine compat status, so make sure
> TS_COMPAT is cleared.
>
> Signed-off-by: Bobby Powers <[email protected]>
> ---
> arch/x86/kernel/process_64.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> index e9ec8f1..a465973 100644
> --- a/arch/x86/kernel/process_64.c
> +++ b/arch/x86/kernel/process_64.c
> @@ -539,6 +539,9 @@ void set_personality_ia32(bool x32)
> clear_thread_flag(TIF_IA32);
> set_thread_flag(TIF_X32);
> current->personality &= ~READ_IMPLIES_EXEC;
> + /* is_compat_task() uses the presence of the x32
> + syscall bit flag to determine compat status */
> + current_thread_info()->status &= ~TS_COMPAT;
> } else {
> set_thread_flag(TIF_IA32);
> clear_thread_flag(TIF_X32);

I suspect we should also clear TS_COMPAT in set_personality_64() ...
this is not x32-related, but would affect the behavior when execing a
64-bit task from an i386 compatibility task. I have no idea if it
actually makes any difference, and clearly it can't have been too broken
since noone has found a problem all these years, but it looks wrong...

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.