From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752416AbcFWVZb (ORCPT ); Thu, 23 Jun 2016 17:25:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52534 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752391AbcFWVZ2 (ORCPT ); Thu, 23 Jun 2016 17:25:28 -0400 Date: Thu, 23 Jun 2016 23:26:06 +0200 From: Oleg Nesterov To: Andy Lutomirski Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Pedro Alves , Kees Cook Subject: Re: [PATCH v3 3/3] x86/ptrace, x86/signal: Remove TS_I386_REGS_POKED Message-ID: <20160623212606.GB14180@redhat.com> References: <9c5c3fd519dcc2e4596ecb074e1f8967f83080ef.1466464928.git.luto@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9c5c3fd519dcc2e4596ecb074e1f8967f83080ef.1466464928.git.luto@kernel.org> 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.32]); Thu, 23 Jun 2016 21:25:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Again, I think the patch is fine, just a question On 06/20, Andy Lutomirski wrote: > > System call restart has some oddities wrt ptrace: > > 1. For whatever reason, the kernel delivers signals and triggers > ptrace before handling syscall restart. This means that > -ERESTART_RESTARTBLOCK, etc is visible to userspace. We could > plausibly get away with changing that, but it seems quite risky. How we can change this? The kernel simply can't know how it should react to (say) -ERESTARTSYS until debugger acks/nacks/changes the signal reported by tracee. > + /* > + * A 32-bit ptracer has the following expectations: > + * > + * - Storing -1 (i.e. 0xffffffff) to orig_eax will prevent > + * syscall restart handling. > + * > + * - Restoring regs saved on exit from an interrupted > + * restartable syscall will trigger syscall restart. Such > + * regs will have non-negative orig_eax and negative eax. > + * > + * The kernel's syscall restart code treats regs->orig_ax and > + * regs->ax as 64-bit signed quantities. 32-bit user code > + * doesn't care about the high bits. Keep it simple and just > + * sign-extend both values. > + */ > + R32_SIGNED(orig_eax, orig_ax); > + R32_SIGNED(eax, ax); OK. but do we really need R32_SIGNED(orig_eax) ? syscall_get_nr() returns "int", not "long". Oleg.