Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1504326ybk; Thu, 21 May 2020 08:25:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCwtbFAQG6P2E60M+W3nQkQkZIl3TH6MiT0NclEe1/u5vtHK0OjYBi7V56drWiQT8oV5B4 X-Received: by 2002:a17:906:2bc1:: with SMTP id n1mr3954666ejg.34.1590074710871; Thu, 21 May 2020 08:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590074710; cv=none; d=google.com; s=arc-20160816; b=MZKCc8vqxN3Qt0cmAiLoWWEokp2+z/pMJZ26eU60D1QYXZmMwIORsy5PK8mgh6cCOq JOmA0iCK8e+UIC/5VklbmeMdnlHDnti4dyx/bvL75JcH+sQqXLgw0qLY8I2Xbw/FuzCz bg5B2MvL1Slmmh3QQtQPobLPAyOdnVmXM9lXYJ5xT/fUF/vjNUvwNzDjm+fRJ7t6LCtI dmo2Chi0DrwZz7/nTtayJ98BejQji2Ws+aPHS3iwfsja1WCj3iVJzlDs+QJ1M1602sb7 Fhgzb9ufvuGIIiw0ZnAn23wVAqJkZ3fHZ86FLnPyUhsv/80qocrTUGbJYtzaspTRbQd3 ePuQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=YqSSwt2eEcfdPvUAJEANUMpS+LY40r0n4Vfg5+OG7wQ=; b=n9A/cH82C/attdlL6kvusnqHxXqMt0sh5qVIsM5sEHTU0LhUQUBN7AsMFoJFdjGK9q Dn2xWbQ7MRhZtr+6DGxa44kjLP5Ov+gct+P3qnoTL1KVoQXrWEPDHarwrmtOEDcDd/dW 8YTVVHmTxHizcf4iNLDuwmqMnxsff6gsomtYsS7F8MbRVVplGXoZKcYr3SEPX3WbGDLl 6Mi57BnodLDG7uZu1DePOCIo7NxVaYh5/mbpMjEqOQ37g7m4ZdvAE3yTgrQbJZc7ZmyB 3bv0Sd5ftnmEcLxsg5/HN+IdKMmsvdhuPGZPhE6elhJWL1VNN+TsCn2ADCMKbSPziB03 +OZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EEJCEnoh; 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 u10si3390535ejg.377.2020.05.21.08.24.47; Thu, 21 May 2020 08:25:10 -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=EEJCEnoh; 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 S1729988AbgEUPXL (ORCPT + 99 others); Thu, 21 May 2020 11:23:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727898AbgEUPXL (ORCPT ); Thu, 21 May 2020 11:23:11 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21EAEC061A0E; Thu, 21 May 2020 08:23:11 -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:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=YqSSwt2eEcfdPvUAJEANUMpS+LY40r0n4Vfg5+OG7wQ=; b=EEJCEnohLFlkeBK40BapbvBN8B STzhDvoXDi6tKlY0y9EJyn9cirSq8jAFNVOnAudZkOqwZw1AmD7q/TODvpr9c9vXbt/wp1uyiKDrL JnXNH0f/a2eGVzzMvif5JYp9g8Q2nIkTHG0J0DaB/RdnLYlUTkNMv3wfnys2TXfQoGngUeetWOBh2 49EjI/2ECxzLrR6L3IN6772XB/UeBe7cuoKvQGFoXmoftQ0OU4m9M+BN7p1LZLHCWYJebf2w/GMB9 oOZWBeR82AWRsWyIILbr0CtUMwxyV8pzt+lJchXXL6fCPVBtyGnXT7GEMCYvYogWI0/8PbRZUTy+t ZFUTdkOQ==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbn2F-0003xo-7d; Thu, 21 May 2020 15:23:03 +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: clean up and streamline probe_kernel_* and friends v4 Date: Thu, 21 May 2020 17:22:38 +0200 Message-Id: <20200521152301.2587579-1-hch@lst.de> X-Mailer: git-send-email 2.26.2 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 Hi all, this series start cleaning up the safe kernel and user memory probing helpers in mm/maccess.c, and then allows architectures to implement the kernel probing without overriding the address space limit and temporarily allowing access to user memory. It then switches x86 over to this new mechanism by reusing the unsafe_* uaccess logic. This version also switches to the saner copy_{from,to}_kernel_nofault naming suggested by Linus. I kept the x86 helpers as-is without calling unsage_{get,put}_user as that avoids a number of hard to trace casts, and it will still work with the asm-goto based version easily. Changes since v3: - cleanup how bpf and trace_kprobe perform the TASK_SIZE checks - remove the unused dst argument to probe_kernel_read_allowed - document the -ERANGE return value Changes since v2: - rebased on 5.7-rc6 with the bpf trace format string changes - rename arch_kernel_read to __get_kernel_nofault and arch_kernel_write to __put_kernel_nofault - clean up the tracers to only allowd "mixed" reads when the kernel has non-overlapping address spaces