From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932243AbcFTQdt (ORCPT ); Mon, 20 Jun 2016 12:33:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53920 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080AbcFTQd2 (ORCPT ); Mon, 20 Jun 2016 12:33:28 -0400 Date: Mon, 20 Jun 2016 17:24:25 +0200 From: Oleg Nesterov To: Andy Lutomirski Cc: Pedro Alves , Kees Cook , Borislav Petkov , "linux-kernel@vger.kernel.org" , X86 ML , Linus Torvalds Subject: Re: [PATCH] x86/ptrace: Remove questionable TS_COMPAT usage in ptrace Message-ID: <20160620152424.GA28057@redhat.com> References: <94bda8cd5f326ae5591c80fb5d7c1c22624accec.1466244711.git.luto@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 20 Jun 2016 16:27:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/19, Andy Lutomirski wrote: > > On Sat, Jun 18, 2016 at 10:02 AM, Andy Lutomirski wrote: > Step 1: for 4.7 and for -stable, introduce TS_I386_REGS_POKED. Set it > in putreg32. Use it in syscall_get_error, get_nr_restart_syscall, > etc. Clear it in do_signal. do_signal() won't be necessarily called... > I wonder if we could actually get away with doing syscall restart > processing before ptrace invocation. How? this doesn't look possible or I misunderstood. How about the simple change below for now? IIRC 32-bit task can't use "syscall" so if syscall_get_nr() >= 0 then even the wrong TS_COMPAT is not that bad, even if it "leaks" to user-mode. nobody should use, say, in_ia32_syscall() unless we know that "in syscall" is actually true. Hmm, arch/x86/kernel/uprobes.c does and this is wrong regardless, I'll send the fix. Oleg. --- x/arch/x86/kernel/ptrace.c +++ x/arch/x86/kernel/ptrace.c @@ -930,7 +930,7 @@ static int putreg32(struct task_struct * * exit from a 32-bit syscall with TS_COMPAT still set. */ regs->orig_ax = value; - if (syscall_get_nr(child, regs) >= 0) + if (syscall_get_nr(child, regs) >= 0 && !user_64bit_mode(regs)) task_thread_info(child)->status |= TS_COMPAT; break;