From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728135AbgJGXVV (ORCPT ); Wed, 7 Oct 2020 19:21:21 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08307C0613D3 for ; Wed, 7 Oct 2020 16:21:19 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id h12so2023303qtu.1 for ; Wed, 07 Oct 2020 16:21:19 -0700 (PDT) Date: Wed, 7 Oct 2020 20:21:17 -0300 From: Jason Gunthorpe Subject: Re: [PATCH 07/13] mm: close race in generic_access_phys Message-ID: <20201007232117.GB5177@ziepe.ca> References: <20201007164426.1812530-1-daniel.vetter@ffwll.ch> <20201007164426.1812530-8-daniel.vetter@ffwll.ch> <20201007172746.GU5177@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-ID: To: Daniel Vetter Cc: DRI Development , LKML , kvm@vger.kernel.org, Linux MM , Linux ARM , linux-samsung-soc , "open list:DMA BUFFER SHARING FRAMEWORK" , linux-s390@vger.kernel.org, Dan Williams , Kees Cook , Rik van Riel , Benjamin Herrensmidt , Dave Airlie , Hugh Dickins , Andrew Morton , John Hubbard , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Jan Kara , Daniel Vetter On Wed, Oct 07, 2020 at 08:01:42PM +0200, Daniel Vetter wrote: > I think it'd fix the bug, until someone wires ->access up for > drivers/gpu, or the next subsystem. This is also just for ptrace, so > we really don't care when we stall the vm badly and other silly > things. So I figured the somewhat ugly, but full generic solution is > the better one, so that people who want to be able to ptrace > read/write their iomem mmaps can just sprinkle this wherever they feel > like. > > But yeah if we go with most minimal fix, i.e. only trying to fix the > current users, then your thing should work and is simpler. But it > leaves the door open for future problems. The only other idea I had was to fully make the 'vma of __iomem memory' some generic utility, completely take over the vm_ops. We did something like this in RDMA, what I found was even just implementing mmap() using the kernel helpers turned out to be pretty tricky, many drivers did it wrong in small ways. Jason