From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3659EC4727E for ; Sun, 4 Oct 2020 03:25:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01992206F8 for ; Sun, 4 Oct 2020 03:25:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726516AbgJDDZx (ORCPT ); Sat, 3 Oct 2020 23:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726226AbgJDDZw (ORCPT ); Sat, 3 Oct 2020 23:25:52 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987BCC0613D0 for ; Sat, 3 Oct 2020 20:25:52 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 51D7129AFF4 From: Gabriel Krisman Bertazi To: luto@kernel.org, tglx@linutronix.de Cc: hch@lst.de, hpa@zytor.com, bp@alien8.de, rric@kernel.org, peterz@infradead.org, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, sean.j.christopherson@intel.com, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v3 02/10] x86: Simplify compat syscall userspace allocation Date: Sat, 3 Oct 2020 23:25:28 -0400 Message-Id: <20201004032536.1229030-3-krisman@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201004032536.1229030-1-krisman@collabora.com> References: <20201004032536.1229030-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When allocating user memory space for a compat system call, don't consider whether the originating code is IA32 or X32, just allocate from a safe region for both, beyond the redzone. This should be safe for IA32, and has the benefit of avoiding TIF_IA32, which we want to drop. Suggested-by: Andy Lutomirski Cc: Christoph Hellwig Signed-off-by: Gabriel Krisman Bertazi --- arch/x86/include/asm/compat.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h index d4edf281fff4..a4b5126dff4e 100644 --- a/arch/x86/include/asm/compat.h +++ b/arch/x86/include/asm/compat.h @@ -179,14 +179,13 @@ typedef struct user_regs_struct compat_elf_gregset_t; static inline void __user *arch_compat_alloc_user_space(long len) { - compat_uptr_t sp; - - if (test_thread_flag(TIF_IA32)) { - sp = task_pt_regs(current)->sp; - } else { - /* -128 for the x32 ABI redzone */ - sp = task_pt_regs(current)->sp - 128; - } + compat_uptr_t sp = task_pt_regs(current)->sp; + + /* + * -128 for the x32 ABI redzone. For IA32, it is not strictly + * necessary, but not harmful. + */ + sp -= 128; return (void __user *)round_down(sp - len, 16); } -- 2.28.0