Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1612018

Re: [PATCH 1/1] get_nr_restart_syscall() should return __NR_ia32_restart_syscall if __USER32_CS

From Oleg Nesterov <oleg@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/1] get_nr_restart_syscall() should return __NR_ia32_restart_syscall if __USER32_CS
Date 2017-03-29 17:10 +0200
Message-ID <tqnot-9P-5@gated-at.bofh.it> (permalink)
References <tq0UV-12M-15@gated-at.bofh.it> <tq0UV-12M-13@gated-at.bofh.it> <tq0UX-12M-59@gated-at.bofh.it> <tq2am-1Rr-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 03/28, Oleg Nesterov wrote:
>
> On 03/28, Andy Lutomirski wrote:
> >
> > How about we store the syscall arch to be restored in task_struct
> > along with restart_block?
>
> Yes, perhaps we will have to finally do this. Not really nice too.

OK, how about the hack below?

I do not want to a new member into task_struct/restart_block, so the
patch below adds a sticky TS_COMPAT bit which logically is a member
of "struct restart_block".

TS_I386_REGS_POKED must die, I think. But this needs another discussion.

Oleg.


diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index b83c61c..a94bb5e 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -249,6 +249,17 @@ __visible inline void syscall_return_slowpath(struct pt_regs *regs)
 		local_irq_enable();
 
 	/*
+	 * Do this before debugger can change the regs.
+	 */
+	if (IS_ENABLED(CONFIG_IA32_EMULATION) &&
+	    unlikely(regs->ax == -ERESTART_RESTARTBLOCK)) {
+		if (current->thread.status & TS_COMPAT)
+			current->thread.status |= TS_COMPAT_XXX;
+		else
+			current->thread.status &= ~TS_COMPAT_XXX;
+	}
+
+	/*
 	 * First do one-time work.  If these work items are enabled, we
 	 * want to run them exactly once per syscall exit with IRQs on.
 	 */
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 1be64da..87179ab 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -477,6 +477,7 @@ struct thread_struct {
  * have to worry about atomic accesses.
  */
 #define TS_COMPAT		0x0002	/* 32bit syscall active (64BIT)*/
+#define TS_COMPAT_XXX		0x0008
 
 /*
  * Set IOPL bits in EFLAGS from given mask
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 763af1d..b3b98ff 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -785,7 +785,7 @@ static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)
 	 * than the tracee.
 	 */
 #ifdef CONFIG_IA32_EMULATION
-	if (current->thread.status & (TS_COMPAT|TS_I386_REGS_POKED))
+	if (current->thread.status & TS_COMPAT_XXX)
 		return __NR_ia32_restart_syscall;
 #endif
 #ifdef CONFIG_X86_X32_ABI

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/1] get_nr_restart_syscall() should return  __NR_ia32_restart_syscall if __USER32_CS Oleg Nesterov <oleg@redhat.com> - 2017-03-28 17:10 +0200
  Re: [PATCH 1/1] get_nr_restart_syscall() should return  __NR_ia32_restart_syscall if __USER32_CS Andy Lutomirski <luto@kernel.org> - 2017-03-28 17:10 +0200
    Re: [PATCH 1/1] get_nr_restart_syscall() should return  __NR_ia32_restart_syscall if __USER32_CS Oleg Nesterov <oleg@redhat.com> - 2017-03-28 18:30 +0200
      Re: [PATCH 1/1] get_nr_restart_syscall() should return  __NR_ia32_restart_syscall if __USER32_CS Andy Lutomirski <luto@amacapital.net> - 2017-03-28 19:20 +0200
      Re: [PATCH 1/1] get_nr_restart_syscall() should return  __NR_ia32_restart_syscall if __USER32_CS Oleg Nesterov <oleg@redhat.com> - 2017-03-29 17:10 +0200
        Re: [PATCH 1/1] get_nr_restart_syscall() should return  __NR_ia32_restart_syscall if __USER32_CS Andy Lutomirski <luto@amacapital.net> - 2017-03-29 19:10 +0200
          Re: [PATCH 1/1] get_nr_restart_syscall() should return  __NR_ia32_restart_syscall if __USER32_CS Oleg Nesterov <oleg@redhat.com> - 2017-03-30 17:30 +0200
            Re: [PATCH 1/1] get_nr_restart_syscall() should return  __NR_ia32_restart_syscall if __USER32_CS Andy Lutomirski <luto@amacapital.net> - 2017-03-30 20:40 +0200

csiph-web