From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932855AbcFJUOr (ORCPT ); Fri, 10 Jun 2016 16:14:47 -0400 Received: from mail-oi0-f52.google.com ([209.85.218.52]:34368 "EHLO mail-oi0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752230AbcFJUOq (ORCPT ); Fri, 10 Jun 2016 16:14:46 -0400 MIME-Version: 1.0 In-Reply-To: <20160610200739.GA14789@redhat.com> References: <1464786697-20639-1-git-send-email-dsafonov@virtuozzo.com> <1464786697-20639-6-git-send-email-dsafonov@virtuozzo.com> <20160606211918.GB23681@redhat.com> <20160610200739.GA14789@redhat.com> From: Andy Lutomirski Date: Fri, 10 Jun 2016 13:14:24 -0700 Message-ID: Subject: Re: [PATCH 5/6] x86/ptrace: down with test_thread_flag(TIF_IA32) To: Oleg Nesterov Cc: Dmitry Safonov , "H. Peter Anvin" , Dmitry Safonov <0x7f454c46@gmail.com>, khorenko@virtuozzo.com, "linux-kernel@vger.kernel.org" , Thomas Gleixner , Cyrill Gorcunov , xemul@virtuozzo.com, X86 ML , Ingo Molnar Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 10, 2016 at 1:07 PM, Oleg Nesterov wrote: > On 06/09, Andy Lutomirski wrote: >> >> On Jun 6, 2016 3:21 PM, "Oleg Nesterov" wrote: >> > >> > On 06/01, Dmitry Safonov wrote: >> > > >> > > Note, that this will work only if application has changed it's CS. >> > >> > So, suppose it changes it's CS and crashes, >> > >> > > If the application does 32-bit syscall with __USER_CS, ptrace >> > > @@ -1355,7 +1355,7 @@ void update_regset_xstate_info(unsigned int size, u64 xstate_mask) >> > > const struct user_regset_view *task_user_regset_view(struct task_struct *task) >> > > { >> > > #ifdef CONFIG_IA32_EMULATION >> > > - if (test_tsk_thread_flag(task, TIF_IA32)) >> > > + if (!user_64bit_mode(task_pt_regs(task))) >> > > #endif >> > >> > then coredump will do fill_elf_header(view->e_machine) and use EM_X86_64 >> > instead of EM_386, or vice versa... >> > >> > I simply can't understand is this better or worse, I guess gdb or any >> > other tool which looks at this coredump will be confused anyway. >> > >> >> I think it's better. > > and I tend to agree, I didn't try to argue with this change, but > >> CRIU will change CS and someone will make the >> restored process crash afterwards. > > I don't understand what do you mean... could you explain? > > IIRC, CRIU can't c/r the 32-bit applications, or this is no longer true? > CRIU has a horrible, nasty, brilliant idea: it will start restoring 32-bit processes by treating them mostly like 64-bit processes. The restorer will start out 64-bit, set everything up, and long jump/return/sigreturn/whatever back to 32-bit mode. My proposal was that, rather than coming up with nasty hacks to switch the kernel's idea of the task bitness, we instead teach the kernel to respect that actual bitness as indicated by CS and the syscalls used to the extent possible. So, yes, a restored 32-bit process that crashes should dump core as though it's 32-bit even though it was 64-bit when execve was last called :) --Andy