From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752220AbeDIGj3 (ORCPT ); Mon, 9 Apr 2018 02:39:29 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:40847 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925AbeDIGj0 (ORCPT ); Mon, 9 Apr 2018 02:39:26 -0400 X-Google-Smtp-Source: AIpwx4+xTiC1W42KqaK9BPHoXbJYZ1FJIkebwDALAKxi181Se8uOY68SL0V3nZ7srkWjHSKP1R1HnA== Date: Mon, 9 Apr 2018 08:39:21 +0200 From: Ingo Molnar To: Dominik Brodowski Cc: linux-kernel@vger.kernel.org, Al Viro , Andi Kleen , Andrew Morton , Andy Lutomirski , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" , Ingo Molnar , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , x86@kernel.org, Maninder Singh , Arnd Bergmann , linux-arch Subject: Re: [PATCH 0/3] syscalls: clean up stub naming convention Message-ID: <20180409063921.wkrqbnv4lzxb3isg@gmail.com> References: <20180407074651.29014-1-linux@dominikbrodowski.net> <20180408083550.32d65b6ra6yca5p7@gmail.com> <20180408091536.GA10120@light.dominikbrodowski.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180408091536.GA10120@light.dominikbrodowski.net> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Dominik Brodowski wrote: > > One more fundamental question: why do we have the __do_sys_waitid() and > > __inline_sys_waitid() distinction - aren't the function call signatures the same > > with no conversion done? > > > > I.e. couldn't we just do a single, static __do_sys_waitid(), where the compiler > > would decide to what extent inlining is justified? This would allow the compiler > > to inline all the intermediate code into the stubs themselves. > > > > Or is this a side effect of the error injection feature, which needs to add extra > > logic at this intermediate level? That too should be able to use the > > __do_sys_waitid() variant though. > > Error injection is unrelated. It seems to be for three reasons, if I read > the code (include/linux/syscalls.h) correctly: > > asmlinkage long __do_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) > > 1) This takes arguments of type long (to protect against CVE-2009-0029); > see https://lwn.net/Articles/604287/ : "Digging into the history of > this, it turns out that the long version ensures that 32-bit values > are correctly sign-extended for some 64-bit kernel platforms, > preventing a historical vulnerability." > > { > long ret = __in_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); > __MAP(x,__SC_TEST,__VA_ARGS__); I see - so it's _not_ the same function call signature, but a wrapper with a sign-extended version, which is fair and useful. So on architectures where this matters there's type conversion and active code generated. Thanks, Ingo