Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp637282ybk; Wed, 13 May 2020 09:07:05 -0700 (PDT) X-Google-Smtp-Source: APiQypLKjZ/BWbZFYr/PxnP6QCPNKjo/vvk11bj5U8QRz2cPCOpSdWz7Hiz4G+Hly8Ac1rC8O1zG X-Received: by 2002:a17:906:31d7:: with SMTP id f23mr22647279ejf.118.1589386025419; Wed, 13 May 2020 09:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589386025; cv=none; d=google.com; s=arc-20160816; b=Uv/ag53klFi6Jhme0L+Vwy9PRyTnjC3ve0abJeat31EmTKftxF3bvEhCMY46RfJryr lv52L7oiyBBPBokZQKzQRsU+f+xMqUqYoz3y7m2mmqso/kwnWnN3efI0ovajWN9D4xmL g1tIWWr+dTmdxoaESpW+KJxl1cBfWtsvIWH5fAxpj+l7+W4Db7U++z/LnjVqmCQeXWL3 IjUgnQ4VnmWkTddXZdCGw8guU33iQGb4h1ghDxvm7KOrsvcokqhEdNhJ8UaY/+G4E/fh HyhWQiwzm7zfn3Ky6LNUAwDOKB5VW/eX72gfvD9XkN3QaUu+uaDOtOuW3PQMaGrAmD9S qd3g== 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 :dkim-signature; bh=1V9FXGwvoUyADOJtECmZzXrzilRy7l0jj6styYqt0KU=; b=x6aaorFdtbtjm23adCPtjBkNGPffvBptC5hVAEu6Hmsxn2SUgAuMWyEqc2FFMLStLv rkAN4s4R/IN4VIIB56riB6uU9CAlHlZErcGV1pK0Lv+UzM1hxoS3/deCPe+EVfxICL8Y /8AGU2Vs8k26l/JV+VOQxG57xa1q+Rpj9/I4RX7dV83wmHhQTFGwz4BHirUfmYmkN5pv GRmIUEuk/7eL+280l+YBLAMGoU11KQrDktIlli2OWe7+jSgFbSogCW/Z+YJnbUuVc5xe ekygnMESXXlu7oomTDrT6GIBJRzxOP9QbWTqeaRXG8O98dJf9gC5KD651OvrOco7zTyI TBsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=tKor3Cj8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si8238eds.403.2020.05.13.09.06.41; Wed, 13 May 2020 09:07:05 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=tKor3Cj8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389620AbgEMQB5 (ORCPT + 99 others); Wed, 13 May 2020 12:01:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389529AbgEMQBW (ORCPT ); Wed, 13 May 2020 12:01:22 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F710C061A0E; Wed, 13 May 2020 09:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=1V9FXGwvoUyADOJtECmZzXrzilRy7l0jj6styYqt0KU=; b=tKor3Cj8X0w448ldbecYKjcLcO rEBZiIwDb8iBHi+e8Zj3GmAVgJ4eAPYD7OkxnNk7ExjrIO/MQHCGpj8UqyYoe3GC50VfbTOwfflHH OJVv1O2Q5GBa1SMeS/mocauWeVDCuR5Zo/vBfbV4CWMeodUXAn1y4NUM0PfDY7RF/I/SxR7DgcnA2 HRpIzKQux8h7EOGjHQewnkQkeSiHNy/sFfYXB+svuF9eDP4FdjQbJLg1P1mZXWSkEefQlwdi5R7u2 k+gy4VBHXHqnD/qRwkaOMESyDqX4cFkkpZU5y3kQrjY90A/HJ7pTuAtgIcHXzqbZx9d7McA3ikcFk R9jLdIuA==; Received: from [2001:4bb8:180:9d3f:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jYtou-00050Z-AS; Wed, 13 May 2020 16:01:20 +0000 From: Christoph Hellwig To: x86@kernel.org, Alexei Starovoitov , Daniel Borkmann , Masami Hiramatsu , Linus Torvalds , Andrew Morton Cc: linux-parisc@vger.kernel.org, linux-um@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/18] x86: use non-set_fs based maccess routines Date: Wed, 13 May 2020 18:00:35 +0200 Message-Id: <20200513160038.2482415-16-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200513160038.2482415-1-hch@lst.de> References: <20200513160038.2482415-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide arch_kernel_read and arch_kernel_write routines to implement the maccess routines without messing with set_fs and without stac/clac that opens up access to user space. Signed-off-by: Christoph Hellwig --- arch/x86/include/asm/uaccess.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index d8f283b9a569c..765e18417b3ba 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -523,5 +523,21 @@ do { \ unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label); \ } while (0) +#define HAVE_ARCH_PROBE_KERNEL + +#define arch_kernel_read(dst, src, type, err_label) \ +do { \ + int __kr_err; \ + \ + __get_user_size(*((type *)dst), (__force type __user *)src, \ + sizeof(type), __kr_err); \ + if (unlikely(__kr_err)) \ + goto err_label; \ +} while (0) + +#define arch_kernel_write(dst, src, type, err_label) \ + __put_user_size(*((type *)(src)), (__force type __user *)(dst), \ + sizeof(type), err_label) + #endif /* _ASM_X86_UACCESS_H */ -- 2.26.2