Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp799371pxk; Sat, 12 Sep 2020 00:10:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBNDvxDamKfoWH7bBhOfs01k6UU8YCkxZ7MzB6kOkmNxxTME/LHgIPt4A0RFsBV1yM6mCw X-Received: by 2002:a17:906:33ca:: with SMTP id w10mr5429891eja.438.1599894656655; Sat, 12 Sep 2020 00:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599894656; cv=none; d=google.com; s=arc-20160816; b=qL7+26c+lGbeE10i03Upu9Kc0vo3Wda+f5qSrWd6Ljcsl9roi2790eg5+na2EtimZd RWrhJb2zfmHqD4zZodhMex8vaFT2aHt3e/ER/SNl6f6NRa4+bA5Ce5PiWAqH1Qup5ZfT fiTfaiJRGLCvVP0dMrwjU7hjRas+trUJW5aumxMdT7nyHNG17BBm6chARP5MzHSj/iub M09fyNBULpOFAE9/HOahZEDbHSkmCTeiieo9yTy/4qrsY8GxS/gBQdZOuzr4PhY879Ss XyR5WUo/X8izE4VThjFCjdPnggQnYI6AvE8POq7piwOAZubScMIuwfQpbj8LMBGiEKpq wa8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=n1OCSfwtViHcgxLBj9kn4/XUweA+cQyu6/ma5J8aQps=; b=Gsqk+DDQhOxRBv/AwAm3CPm5v9ZOVuD6y5agKimbNWBiFxy0QZp0C5ZWM9kglO8hf3 rM09xS3rRzzmQZ0BPIQ6Dx+45HxPemOXTEE3io2YtIatdVsaTZchZdjmt5s/hwFdgpYz aTF8IX8WRHDNnA4B+XRgN7UnAJrsZC8vmm20M3y/Xos/tSopM3lt/vHAWjwhKjNA/obC nwJiGbVOqKB2tn1UN3ZWcQi++BeGCpiWU1sTg99Zd9Ba7wDJfuhevg8RLX2Lcr1Hr7x0 ypBNTeVaQexGIPCZWgJkJSk5XFjtjtqMwBj/2yvPfnT+UUHWLigVKEbwusBrmogI+Xlx UGXA== 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 p17si2787343ejo.270.2020.09.12.00.10.34; Sat, 12 Sep 2020 00:10:56 -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 S1725892AbgILHGP (ORCPT + 99 others); Sat, 12 Sep 2020 03:06:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgILHGL (ORCPT ); Sat, 12 Sep 2020 03:06:11 -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 201ABC061573 for ; Sat, 12 Sep 2020 00:06:10 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 2AFC929C413 From: Gabriel Krisman Bertazi To: luto@kernel.org, tglx@linutronix.de Cc: hpa@zytor.com, bp@alien8.de, rric@kernel.org, peterz@infradead.org, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com, Christoph Hellwig Subject: [PATCH 2/6] x86: Simplify compat syscall userspace allocation Date: Sat, 12 Sep 2020 03:05:49 -0400 Message-Id: <20200912070553.330622-3-krisman@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200912070553.330622-1-krisman@collabora.com> References: <20200912070553.330622-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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