Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753213AbdC2QpP (ORCPT ); Wed, 29 Mar 2017 12:45:15 -0400 Received: from mail-it0-f49.google.com ([209.85.214.49]:38763 "EHLO mail-it0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752536AbdC2QpO (ORCPT ); Wed, 29 Mar 2017 12:45:14 -0400 MIME-Version: 1.0 In-Reply-To: <20170329163335.GA23977@redhat.com> References: <20170328145413.GA3164@redhat.com> <20170329163335.GA23977@redhat.com> From: Linus Torvalds Date: Wed, 29 Mar 2017 09:45:12 -0700 X-Google-Sender-Auth: xqQMM1ElqHSM9xyui9MlIoVLYwY Message-ID: Subject: Re: syscall_get_error() && TS_ checks To: Oleg Nesterov 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 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: 1051 Lines: 30 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. > 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. Linus