From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752634AbdJRNRy (ORCPT ); Wed, 18 Oct 2017 09:17:54 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:56421 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750782AbdJRNRv (ORCPT ); Wed, 18 Oct 2017 09:17:51 -0400 X-Google-Smtp-Source: ABhQp+Rh2lQczD5xNVIKDmXpa4pXhGye/An8hQKQgpBJqj/eHKCuk3+YIU6ugwQdUY70KKkNOqOz3w== Date: Wed, 18 Oct 2017 15:17:47 +0200 From: Ingo Molnar To: Dave Hansen Cc: linux-kernel@vger.kernel.org, x86@kernel.org, luto@kernel.org, brgerst@gmail.com Subject: Re: [PATCH] x86, syscalls: use SYSCALL_DEFINE() macros for sys_modify_ldt() Message-ID: <20171018131747.xwte4c3oc5gt7yc5@gmail.com> References: <20171017192231.72C327B4@viggo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171017192231.72C327B4@viggo.jf.intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Dave Hansen wrote: > > We do not have tracepoints for sys_modify_ldt() because we define > it directly instead of using the normal SYSCALL_DEFINEx() macros. > > However, there is a reason sys_modify_ldt() does not use the macros: > it has an 'int' return type instead of 'unsigned long'. This is > a bug, but it's a bug cemented in the ABI. > > What does this mean? If we return -EINVAL from a function that > returns 'int', we have 0x00000000ffffffea in %rax. But, if we > return -EINVAL from a function returning 'unsigned long', we end > up with 0xffffffffffffffea in %rax, which is wrong. > > To work around this and maintain the 'int' behavior while using > the SYSCALL_DEFINEx() macros, so we add a cast to 'unsigned int' > in both implementations of sys_modify_ldt(). > > Cc: x86@kernel.org > Cc: Andy Lutomirski > Cc: Brian Gerst I have added your: Signed-off-by: Dave Hansen let me know if that's OK. Thanks, Ingo