Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932276AbdC2Q4C (ORCPT ); Wed, 29 Mar 2017 12:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41302 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752869AbdC2Q4A (ORCPT ); Wed, 29 Mar 2017 12:56:00 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 85CCF2EF174 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=oleg@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 85CCF2EF174 Date: Wed, 29 Mar 2017 18:55:54 +0200 From: Oleg Nesterov To: Linus Torvalds Cc: Andrew Morton , Andy Lutomirski , Denys Vlasenko , "H. Peter Anvin" , Ingo Molnar , Jan Kratochvil , Pedro Alves , Thomas Gleixner , the arch/x86 maintainers , Linux Kernel Mailing List Subject: Re: syscall_get_error() && TS_ checks Message-ID: <20170329165554.GA24250@redhat.com> References: <20170328145413.GA3164@redhat.com> <20170329163335.GA23977@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 29 Mar 2017 16:55:59 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1466 Lines: 39 On 03/29, Linus Torvalds wrote: > > On Wed, Mar 29, 2017 at 9:33 AM, Oleg Nesterov wrote: > > > > Firstly, why do we need the IS_ERR_VALUE() check? This is only used by > > do_signal/handle_signal, we do not care if it returns non-zero as long > > as the value can't be confused with -ERESTART.* codes. > > There are system calls that can return "negative" values that aren't errors. > > Notably mmap() can return a valid pointer with the high bit set. > > So syscall_get_error() should return 0 for not just positive return > values, but for those kinds of negative non-error values. Once again, it is only used in arch/x86/kernel/signal.c by do_signal() and handle_signal(). We do not care if mmap() returns a valid pointer with the high bit set, regs-ax can't be confused with -ERESTART code. > > And why do we need the TS_ checks? > > Those may be bogus. > > > So why we can't simply change putreg32() to always sign-extend regs->ax > > regs->orig_ax and just do > > > > static inline long syscall_get_error(struct task_struct *task, > > struct pt_regs *regs) > > { > > return regs-ax; > > } > > That would be *complete* garbage. Lots of system calls return positive > values that sure as hell aren't errors. See above. And please note that I actually suggest to kill this helper and just use syscall_get_return_value() in arch/x86/kernel/signal.c. Oleg.