Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp790325pxk; Thu, 1 Oct 2020 14:01:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT/GTaLJEeRAWzGbw8ziF/6nfs6HxJhUHOtLS0Kp4Y142fDFs6BG/qpJFGeDzLq6nAjEF5 X-Received: by 2002:a17:906:914b:: with SMTP id y11mr10395995ejw.145.1601586060617; Thu, 01 Oct 2020 14:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601586060; cv=none; d=google.com; s=arc-20160816; b=oNwm75vb2pCQd2LTUCPVZ9x4Xnb6HQ4VVOaqjiKDSbRt7gF24wzn8BRfP3r/m27mgc p+3wsKuUb5CuqptY+pqUS6y8GUx8oDSGuUGtm5LLwPAYzL8kDKWCRTmbpc3ZED0lufN6 Vj9OTS++GHy5q8+seX8fXWWc2WCHKCBwxTH9kvdAIegs8PT4kmOmkZmj/sbg90voBLSg uKYTdhjz6dxySMYKLEw+CWDYZfRM+Yq6/9zsLwMxJoEIj4uOxj2/fPPbCjnKXXAbnvO6 1ftXejLKptTURCJKl53hX8VlHq3+AkmFkvq1iCSOiq97d/KdwLVUGk6RLeq5W8TKEk0w GFrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=n1OCSfwtViHcgxLBj9kn4/XUweA+cQyu6/ma5J8aQps=; b=ZMUb+hZyyxQoJPJ46sgR2/OjQycuCwPxu0DQV4D9fUgHWHT6bn+CAZyx6Y9Ux6D50e lhZz0nSYD5jRcB9/pv1GQejruBCbw2T5C9VMvuTEVXvdPJp/4orNPmTe6WEV54ZYDjec DFhkXPUg3zy4rdryiSh9josZiZiySGPfeBisxwPebnR1NwIZq2HGWXxj201VEe4IOBmu +sfCcfmL7rSZCRnsFaegzDOgn9M63/jCkPYwQdqk2KMdtCj0xDZY4AovjltE4qB4d8Y2 K918FIFHS75laSN/65T9LS3yfIDy8zfpVMBqluOysgvbULNe7KxDidZKZ/ULP6mO+Ml0 ndRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt2si4206097ejc.630.2020.10.01.14.00.37; Thu, 01 Oct 2020 14:01:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732981AbgJAU7d (ORCPT + 99 others); Thu, 1 Oct 2020 16:59:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbgJAU7c (ORCPT ); Thu, 1 Oct 2020 16:59:32 -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 404D3C0613D0 for ; Thu, 1 Oct 2020 13:59:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id F18F829D106 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, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v2 2/9] x86: Simplify compat syscall userspace allocation Date: Thu, 1 Oct 2020 16:58:12 -0400 Message-Id: <20201001205819.27879-3-krisman@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001205819.27879-1-krisman@collabora.com> References: <20201001205819.27879-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