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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C55DC433F5 for ; Wed, 11 May 2022 02:29:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6617A8D0007; Tue, 10 May 2022 22:29:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 613EE8D0006; Tue, 10 May 2022 22:29:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E08C8D0007; Tue, 10 May 2022 22:29:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F05F18D0005 for ; Tue, 10 May 2022 22:29:45 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D2F9D31B92 for ; Wed, 11 May 2022 02:29:45 +0000 (UTC) X-FDA: 79451881530.21.6899294 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf24.hostedemail.com (Postfix) with ESMTP id 0B3021800C5 for ; Wed, 11 May 2022 02:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652236185; x=1683772185; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tVhiT6aKeF/Rpr/dJksjmlkONreh2kMGvoLBNiaVHv4=; b=inUG4Fo9T8n2IXNzWhSN42BEKMes4XD1McmJGvVQhDu89f5nyCnYy7G3 ivPOzUq0Fag1USTbrZvv0zq8EBfxRxrtTQ6y0Kg+aSSEuubGoSCbS9l9m wFGuhZJln56ozksF+3AvXXkvi1BwEC8XAkrYn1lIXfiqJBG8mGeKqAMrE XpGZUEHq1/EU3ZaLDnb9q1qATnMVIfFYNxE+KRNUcZ/3sVm7SWAbQKHFp h/WXUFwoZL5g8ZbPJzEMIod/KVO5KDJbjr7hw8O4rsMXc6otHSYT28S+5 TGw9n/XozBOGOln9ROPZJrpOnHoe2tsttlseP+Y9yvWS4VTpTsCv0uFod A==; X-IronPort-AV: E=McAfee;i="6400,9594,10343"; a="251610749" X-IronPort-AV: E=Sophos;i="5.91,215,1647327600"; d="scan'208";a="251610749" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 19:29:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,215,1647327600"; d="scan'208";a="553112425" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 10 May 2022 19:29:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 495565C1; Wed, 11 May 2022 05:28:01 +0300 (EEST) From: "Kirill A. Shutemov" To: Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: x86@kernel.org, Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [RFCv2 06/10] x86/uaccess: Remove tags from the address before checking Date: Wed, 11 May 2022 05:27:47 +0300 Message-Id: <20220511022751.65540-8-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220511022751.65540-1-kirill.shutemov@linux.intel.com> References: <20220511022751.65540-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0B3021800C5 X-Stat-Signature: amj6zo945i7chsyw7oyn43ratfjrajaz X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=inUG4Fo9; spf=none (imf24.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.126) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com X-HE-Tag: 1652236176-991342 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The tags must not be included into check whether it's okay to access the userspace address. Strip tags in access_ok(). get_user() and put_user() don't use access_ok(), but check access against TASK_SIZE directly in assembly. Strip tags, before calling into the assembly helper. Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/uaccess.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index f78e2b3501a1..0f5bf7db4ec9 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -40,7 +40,7 @@ static inline bool pagefault_disabled(void); #define access_ok(addr, size) \ ({ \ WARN_ON_IN_IRQ(); \ - likely(__access_ok(addr, size)); \ + likely(__access_ok(untagged_addr(addr), size)); \ }) #include @@ -125,7 +125,12 @@ extern int __get_user_bad(void); * Return: zero on success, or -EFAULT on error. * On error, the variable @x is set to zero. */ -#define get_user(x,ptr) ({ might_fault(); do_get_user_call(get_user,x,ptr); }) +#define get_user(x,ptr) \ +({ \ + __typeof__(*(ptr)) __user *__ptr_clean = untagged_ptr(ptr); \ + might_fault(); \ + do_get_user_call(get_user,x,__ptr_clean); \ +}) /** * __get_user - Get a simple variable from user space, with less checking. @@ -222,7 +227,11 @@ extern void __put_user_nocheck_8(void); * * Return: zero on success, or -EFAULT on error. */ -#define put_user(x, ptr) ({ might_fault(); do_put_user_call(put_user,x,ptr); }) +#define put_user(x, ptr) ({ \ + __typeof__(*(ptr)) __user *__ptr_clean = untagged_ptr(ptr); \ + might_fault(); \ + do_put_user_call(put_user,x,__ptr_clean); \ +}) /** * __put_user - Write a simple value into user space, with less checking. -- 2.35.1