Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2395483pxk; Sat, 3 Oct 2020 20:27:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbqHtv4AH4G9EuXaFtG4rguhZWbjGKXxDGtdkIDoveWEDZ2Kw6Z1NK/Lw+aZNeCp/1DcnL X-Received: by 2002:a17:906:390d:: with SMTP id f13mr8795020eje.86.1601782041852; Sat, 03 Oct 2020 20:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601782041; cv=none; d=google.com; s=arc-20160816; b=yNHwPUWF40+940kAJEynVGX6q1iElMqO1h8m7plu9hqE8odym2GyEhTu26AYIrCFVm hRsl123noJMFCa/jfTgzwhKZ1n45qb3cny/87IOk7ptRMiKX5fAdcWrX5jXfFIIzhoaH IPsAT8iV+u3AQPNFJTxGE3V7xPW7S/VJ+hL20LV6wwffuAvHT5mytIsMVkshTiNxVTnN t6Haed+wfk5s6LHSAFQW6CkjeVnqh2TTM51uBywW1GUFpwZoGWKg/tmcv/+xHu67iVq2 paUsBnFY/MoQLER0VoWhYcb5fPIpRUPrtrUyj+MhHu7PFNP8Izo9dF/1MK2iaDX6Q/jr C9lQ== 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=dRGktv1zQl38wNUH5XWMLeiZBsFdO2gwx3A28RQNRXvjEoV7jxkWwdA1VQEcoBns2i yZYlZfpYBM8eiC1D96ZSx4C8wI7MOEDydnYev1dDvNQKc457ncFvLQpRkG+nib4pRKW+ 5eoMeenQzcqsPQerqqp7fURsAKHuGmKeW4hC1V3FvTIfiQSJHy9n06sgyv30oyaB35SU HJ3Y5OY3I/bqkenoUpO/JrtkGWRIpw7ihDEFhN4QGfHaTFVleoMPsOSfa7bXFG2DR4wm 3WxzW097HS9VIagrkUn813iwOG2yyR3WmQH9xoPLgGH+T8jXm1ICoWF9sJF0gX+uM0D+ rk2Q== 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 p16si1846431ejw.561.2020.10.03.20.26.59; Sat, 03 Oct 2020 20:27:21 -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 S1726476AbgJDDZx (ORCPT + 99 others); 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