[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrWps4Bvd_hGviEZ+60nQFr5ovp2A0+afDWg-QOHB9x7cA@mail.gmail.com>
Date: Mon, 2 Jul 2018 13:12:51 -0700
From: Andy Lutomirski <luto@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Andrew Lutomirski <luto@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux API <linux-api@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Paul McKenney <paulmck@...ux.vnet.ibm.com>,
Boqun Feng <boqun.feng@...il.com>,
Dave Watson <davejwatson@...com>, Paul Turner <pjt@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Russell King - ARM Linux <linux@....linux.org.uk>,
Ingo Molnar <mingo@...hat.com>, Peter Anvin <hpa@...or.com>,
Andi Kleen <andi@...stfloor.org>,
Christoph Lameter <cl@...ux.com>, Ben Maurer <bmaurer@...com>,
Steven Rostedt <rostedt@...dmis.org>,
Josh Triplett <josh@...htriplett.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>,
Michael Kerrisk <mtk.manpages@...il.com>,
Joel Fernandes <joelaf@...gle.com>
Subject: Re: [RFC PATCH for 4.18 1/2] rseq: validate rseq_cs fields are < TASK_SIZE
On Mon, Jul 2, 2018 at 12:31 PM, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
> On Mon, Jul 2, 2018 at 12:02 PM Andy Lutomirski <luto@...capital.net> wrote:
>>
>> Works for me. Linus, any objection?
>
> I think the 4.19 stage may be overkill, but I don't hate it, so no
> real objections.
>
> If the main reason for this is that we silently clear the upper bits
> when returning to compat mode, I actually think that a better fix
> would be to just fix that. We shouldn't silently ignore bogus data in
> the return path.
>
> But I don't care enough, I think.
Like this:
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 3b2490b81918..ec40223c8856 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -170,6 +170,26 @@ static void exit_to_usermode_loop(struct pt_regs
*regs, u32 cached_flags)
if (cached_flags & _TIF_USER_RETURN_NOTIFY)
fire_user_return_notifiers();
+ if (unlikely(!user_64bit_mode(regs) &&
+ (regs->ip & 0xffffffff00000000ull))) {
+ siginfo_t info;
+ struct task_struct *tsk = current;
+
+ /* I haven't thought about this *that* hard. */
+ clear_siginfo(&info);
+ tsk->thread.cr2 = regs->ip;
+ tsk->thread.trap_nr = X86_TRAP_PF;
+ tsk->thread.error_code = X86_PF_USER | X86_PF_INSTR;
+ info.si_signo = SIGSEGV;
+ info.si_errno = 0;
+ info.si_code = SEGV_MAPERR;
+ info.si_addr = (void __user *)regs->ip;
+ /* si_addr_lsb? */
+ force_sig_info(SIGSEGV, &info, tsk);
+
+ /* And we'll go through the loop again. */
+ }
+
/* Disable IRQs and retry */
local_irq_disable();
It's whitespace damaged and barely tested, but it seems to at least
not be completely busted. I don't really love doing this, though.
Powered by blists - more mailing lists