Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6554157iob; Tue, 10 May 2022 23:24:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHdJBmvIyVVfvkoayxx4uVVz2V/xB+xiVblTBz6L9V1hBL6Il+94k9nhIzOpeHVe1HqoAu X-Received: by 2002:a17:907:6e21:b0:6f5:15bc:d782 with SMTP id sd33-20020a1709076e2100b006f515bcd782mr23033396ejc.690.1652250276491; Tue, 10 May 2022 23:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652250276; cv=none; d=google.com; s=arc-20160816; b=R5GhcC0lmowCPNSqkVhZooHL9OvJ8om9wQK97yzg0c7i7NDMQmen8yvn0FLMxwr+6u hzqLT93dW1aTzkX+EBMpF5wqrFevWSTiyTYAezq3ItD47tC4RuUvZP2MhOdwc6xMQHQo +eA6sBrXKO/W82VkZkqfndFP0IGNNj+ZFZgPAtpWrgpKdDKxIkoCDLdL47ttpo/qetG+ nS/HwY2rSczuuJ7MlIUQ9474qQJ/P744kS+p2rRp/mUs2iCIEUHd+ZJoztPnPyc09iGm nve43xxkkwy0YYKtLRsEt6R5Dzx/rDdxwroydxnYBzyzcouMMqmBVfSBg7lkzgAi3+wY xT7w== 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 :dkim-signature; bh=wZRVVpDDoEfy0N8OKi2s5WnMom9UK9xz65STwi2LWrs=; b=ttH+4PLWIHzqrxmBN/z9zxFO8qOLraEmiHtA+zKVpr3QKCWRSdwk1IZfiStm/F1J32 hrB9yFo5vJl3pFG9XM2e6RpBVcTXlKx1oxdeXxstdYWzgJ2+5nsst81J3JRJJ8ENT5jQ 5pm/srv6fCiXbloV83y8QmpAW2mKMzWV1vgNME/YwUA4p39Tg2pDVSgiPHmGtOB6RToC WLPNQ4pDAwucjr/h7puxy3bT0TUbbIYxPx9pRKWEn3v5vNDXOwqq9DLfBfh/4sqZtJaU 8VmY9JslMwifofYgYQjpzn5pc+NbO4R+9CtEMwZ0s0pOpYn2iKvrTJ/++gg0HHWmoJze v2Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E032CCyW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga32-20020a1709070c2000b006f38bf1700fsi1778771ejc.585.2022.05.10.23.24.10; Tue, 10 May 2022 23:24:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E032CCyW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241366AbiEKCau (ORCPT + 99 others); Tue, 10 May 2022 22:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241267AbiEKC3p (ORCPT ); Tue, 10 May 2022 22:29:45 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DDD721AABC for ; Tue, 10 May 2022 19:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652236184; x=1683772184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tVhiT6aKeF/Rpr/dJksjmlkONreh2kMGvoLBNiaVHv4=; b=E032CCyWLsZ6zZQXqH4b94PYGQ8IAR13GteQ5ZPd6vKWxRzzWi997eZT 7BICAZUNV/bSZlngp/luXJ9CUKzTmJa8u8WZFiuVOuJnM2Tmt8CSikFFU J+OFxIbUvrWD/wYoTrFQLMpMpUPfoqtlR9pffeoNkT2x3cnF0o9vkJk9g Sd73qGk0Xkunfm8XVuCKdtgqKC1eJsE7Uw09b6sblXuvKSnGxfXujNrLz qE9TKqLZD17/syHM/xxH+jKQOUPN7pH7ljDdhj6lX+SaNaNV/dGSQF9oc nWbw1xOriSAZLnpD6XKSPBgt9vwvx6MwMAg2K9gyflaG2+m0p2Bfe8bQi A==; X-IronPort-AV: E=McAfee;i="6400,9594,10343"; a="294798606" X-IronPort-AV: E=Sophos;i="5.91,215,1647327600"; d="scan'208";a="294798606" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.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-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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