From patchwork Fri May 11 19:06:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 10394899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 63A6760348 for ; Fri, 11 May 2018 19:08:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F74A28F54 for ; Fri, 11 May 2018 19:08:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4403128F8E; Fri, 11 May 2018 19:08:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76F9228F54 for ; Fri, 11 May 2018 19:08:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C126E6B0689; Fri, 11 May 2018 15:08:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BE9A86B068A; Fri, 11 May 2018 15:08:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB0DE6B068B; Fri, 11 May 2018 15:08:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot0-f197.google.com (mail-ot0-f197.google.com [74.125.82.197]) by kanga.kvack.org (Postfix) with ESMTP id 803726B0689 for ; Fri, 11 May 2018 15:08:28 -0400 (EDT) Received: by mail-ot0-f197.google.com with SMTP id l95-v6so4284280otl.17 for ; Fri, 11 May 2018 12:08:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=3xh7nz+yAinEZXsxNI9lkmVt4IQv95Vhhfn6VAbxqic=; b=sIvm/MRi8Dzgx4xF4WgR9P1VwXUBW8II4gmy/dBTpuk6brJelMD81uzn0NRWoBgf7r 34Yt193GVF7VFXN29iWNXbM/FwsG3zry3mgi1y3QcLOx4jef08dS9TwNMkQuYEoAUGh6 XzhSyH3afKcKUKXTDblFWSbmxghymKXfzN66rJZCcb6KxqPAszv2jimxtVqUe2utQOQ2 eR3f7Ypc6VQem8RK999DeWSxuR6IxJG06C1WTn3A9cWYwKYDsRimCzN10igX3i2C8PkR efNgt7BXxlJ1BowL5vJ0HMINCsjwSEBVqTHPuo+4TkPtAZPS82ff0CILyD3ZbfmQT3zS cSDw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jean-philippe.brucker@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=jean-philippe.brucker@arm.com X-Gm-Message-State: ALKqPwdNyEjfo44u/JnfZQ7Yzx7NNsMIr2Q5QBo2OSwQ0p9sFqif8cUX 4pnL40V9pxvYOPGgkWfUJFbdBC3Qy3crh2E0dbsI4q8QNOT8mwI2iCC0C5fn2wJQQHtRVzMQ6hU UI6FxZqZOJR9AmnlShr6pcQ7AMGWWqdPvlRm9LdQwVF5Gg/q9GlA9657LyeNhhQTeMg== X-Received: by 2002:a9d:518b:: with SMTP id y11-v6mr4963088otg.252.1526065708288; Fri, 11 May 2018 12:08:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrBBIfg9ywjUCPBkanVKGbjiWbL0KEVjOxLyXxfv7E0Jg/gJYPmj5qypmsNql+4zxDpHXSU X-Received: by 2002:a9d:518b:: with SMTP id y11-v6mr4963043otg.252.1526065707538; Fri, 11 May 2018 12:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526065707; cv=none; d=google.com; s=arc-20160816; b=IJ54oBpTRPEyKWWxkt9DgHCSrVxj1tYctm2MMV+j+yL6vKYeSKkM6iXl5L89+m36rX VPOF/LL5clGqcHVxgPsd4wBlmvZ9kVAcCRB5uuQGVMGkcB7tvPFpwItL3BKUyhkwEg5w TWaI+Ml5Qdqgg6hSVY43hs/QAjdC19Q1PERlG2PkIJ+Db0/bx+5xyQ3h5hYLh6PMOwV3 j9tYIqVAc+5mEprY2D+bjPkg06O7r13bqTVkYBevNpIz1X+dvFeZ4+S4JIeGci9aufAm NKksr5r9oS8I1qcLp05Apv1aUGVjcaPXPKyWZ+JxowbHP6dRmVRVULN1ZYVgEcsTMdz/ pezQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=3xh7nz+yAinEZXsxNI9lkmVt4IQv95Vhhfn6VAbxqic=; b=vnUVKHrqwUY6vx5tukv/E8ooNXCtdAf4+i4wtm/hIRYDIo5t4gc2LUOH6z/TXDk8Tr 11k+L4q40H7dKGUebZNvcvC1hnqmyQE3M657DgkBF9v9lwG3wHBzv8RFbs9o3ODO8XMy t1Q/wBxPhcPvkEa97gJN5A4Me9vJbLWK2mcYaqk+MTDkliRQJAXcfBYedPp9LZvhdb8h 2KVeUzhrkbP0l4E9gf/f9fbe6ASacgOnlQETEMH/lMKFgCOq4/84FAjPFz0vJCoYlqTw AqkwWKEdm40kLJr6D6Lo+BvUjVCGyzC5YeF76ukCezysKCEJhixGIOK72zWRKJ1fnflm ewgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jean-philippe.brucker@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=jean-philippe.brucker@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id d36-v6si1396392otd.318.2018.05.11.12.08.27 for ; Fri, 11 May 2018 12:08:27 -0700 (PDT) Received-SPF: pass (google.com: domain of jean-philippe.brucker@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jean-philippe.brucker@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=jean-philippe.brucker@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F9DE19E8; Fri, 11 May 2018 12:08:27 -0700 (PDT) Received: from ostrya.cambridge.arm.com (ostrya.cambridge.arm.com [10.1.210.33]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9F5283F23C; Fri, 11 May 2018 12:08:21 -0700 (PDT) From: Jean-Philippe Brucker To: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org Cc: joro@8bytes.org, will.deacon@arm.com, robin.murphy@arm.com, alex.williamson@redhat.com, tn@semihalf.com, liubo95@huawei.com, thunder.leizhen@huawei.com, xieyisheng1@huawei.com, xuzaibo@huawei.com, ilias.apalodimas@linaro.org, jonathan.cameron@huawei.com, liudongdong3@huawei.com, shunyong.yang@hxt-semitech.com, nwatters@codeaurora.org, okaya@codeaurora.org, jcrouse@codeaurora.org, rfranz@cavium.com, dwmw2@infradead.org, jacob.jun.pan@linux.intel.com, yi.l.liu@intel.com, ashok.raj@intel.com, kevin.tian@intel.com, baolu.lu@linux.intel.com, robdclark@gmail.com, christian.koenig@amd.com, bharatku@xilinx.com, rgummal@xilinx.com, felix.kuehling@amd.com, akpm@linux-foundation.org Subject: [PATCH v2 10/40] mm: export symbol mm_access Date: Fri, 11 May 2018 20:06:11 +0100 Message-Id: <20180511190641.23008-11-jean-philippe.brucker@arm.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511190641.23008-1-jean-philippe.brucker@arm.com> References: <20180511190641.23008-1-jean-philippe.brucker@arm.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP Some devices can access process address spaces directly. When creating such bond, to check that a process controlling the device is allowed to access the target address space, the device driver uses mm_access(). Since the drivers (in this case VFIO) can be built as a module, export the mm_access symbol. Cc: felix.kuehling@amd.com Cc: akpm@linux-foundation.org Signed-off-by: Jean-Philippe Brucker --- This patch was already sent last year for AMD KFD. I'm resending it for VFIO, trying to address Andrew Morton's request to comment the exported function: http://lkml.iu.edu/hypermail/linux/kernel/1705.2/06774.html --- kernel/fork.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kernel/fork.c b/kernel/fork.c index a5d21c42acfc..1062f7450e97 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1098,6 +1098,19 @@ struct mm_struct *get_task_mm(struct task_struct *task) } EXPORT_SYMBOL_GPL(get_task_mm); +/** + * mm_access - check access permission to a task and and acquire a reference to + * its mm. + * @task: target task + * @mode: selects type of access and caller credentials + * + * Return the task's mm on success, or %NULL if it cannot be accessed. + * + * Check if the caller is allowed to read or write the target task's pages. + * @mode describes the access mode and credentials using ptrace access flags. + * See ptrace_may_access() for more details. On success, a reference to the mm + * is taken. + */ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode) { struct mm_struct *mm; @@ -1117,6 +1130,7 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode) return mm; } +EXPORT_SYMBOL_GPL(mm_access); static void complete_vfork_done(struct task_struct *tsk) {