Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753671AbdC1PE3 (ORCPT ); Tue, 28 Mar 2017 11:04:29 -0400 Received: from mail.kernel.org ([198.145.29.136]:52536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753213AbdC1PE1 (ORCPT ); Tue, 28 Mar 2017 11:04:27 -0400 MIME-Version: 1.0 In-Reply-To: <20170328145432.GA3163@redhat.com> References: <20170328145413.GA3164@redhat.com> <20170328145432.GA3163@redhat.com> From: Andy Lutomirski Date: Tue, 28 Mar 2017 08:03:48 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/1] get_nr_restart_syscall() should return __NR_ia32_restart_syscall if __USER32_CS To: Oleg Nesterov Cc: Andrew Morton , Andy Lutomirski , Linus Torvalds , Denys Vlasenko , "H. Peter Anvin" , Ingo Molnar , Jan Kratochvil , Pedro Alves , Thomas Gleixner , X86 ML , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 795 Lines: 18 On Tue, Mar 28, 2017 at 7:54 AM, Oleg Nesterov wrote: > get_nr_restart_syscall() checks TS_I386_REGS_POKED but this bit is only > set if debugger is 32-bit. If a 64-bit debugger restores the registers > of a 32-bit debugee outside of syscall exit path get_nr_restart_syscall() > wrongly returns __NR_restart_syscall. I had sent a patch that introduced a new syscall nr, but it's not quite safe because it could break seccomp-using programs. But your patch here is also screwy. How about we store the syscall arch to be restored in task_struct along with restart_block? It's not perfect, but it should be 99% of the way there without heuristics as nasty as yours. --Andy P.S. __USER32_CS is the wrong check even if we used your approach. user_64bit_regs() is much better.