From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8026AC433E7 for ; Fri, 9 Oct 2020 12:12:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C50DD2226B for ; Fri, 9 Oct 2020 12:12:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="QZHZihMb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C50DD2226B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C734A6B0062; Fri, 9 Oct 2020 08:12:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C49208E0001; Fri, 9 Oct 2020 08:12:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B107F6B006C; Fri, 9 Oct 2020 08:12:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 830F26B0062 for ; Fri, 9 Oct 2020 08:12:24 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 165A4181AE867 for ; Fri, 9 Oct 2020 12:12:24 +0000 (UTC) X-FDA: 77352274608.27.park73_6113f0d271e0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id C40133D66B for ; Fri, 9 Oct 2020 12:12:23 +0000 (UTC) X-HE-Tag: park73_6113f0d271e0 X-Filterd-Recvd-Size: 4344 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 9 Oct 2020 12:12:23 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id a23so10208010qkg.13 for ; Fri, 09 Oct 2020 05:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CDbjI7PI2DVtcti/K71bQwrAiX/e3WO6iYhXq1xpE8k=; b=QZHZihMbJ0+6cO/RXFdRTnbjHZMdsMwMdoZ9ofxIbLiL7huuUpUScZKwWV84kB55Bx Uj0tRXkYKOAM75Zw3mq9huJb+sXq21viOZihFZp7lRXmxRJ1cFf8BtITIb1t2tYeDMCa txj96jZKuDfh/KqtvpNSOfhj3rLyTVUnAr0oXGalYRsnEuMdnS5jRpZrZBYvWtLxhF/R 8KJwS/cHgY0rK/bg+oGMABqazzprmcMisElyCeHlYguGApZ1AR8/+MXPoqVhnTd0VCNc 25kstyMGbbGfaTeeP9LQeGTP2F+aZXhWaayqadeXvcUq6gtI3AMZT8PIqYCcvUwK2WBG 1Xkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CDbjI7PI2DVtcti/K71bQwrAiX/e3WO6iYhXq1xpE8k=; b=ZzgDDgEaqXVN4ApjNHkWi5FfUicxUZLYyuFJgNG9zITWW7JGYhsw+x/EYLx1sA2lYP kkMDr2Xcj4OXDkgk98a2B8vm99URqxPh81DdQSyI4d5MASKkN8rqaOwY0D9OGCvJeDHf v2Ip0RktKngtdLzOXLmRQcZTRlUytaF7Dy14z+55y5Cb4Kpa1atuNfi7QpMFxNPUqrTF rmr0zfVwhVZJRANGLTgGlMoyk5AIdIJgs5vrD8sMRUeY/GV/K6nLrYP3ZL7dhW3qe7ph hbajZB9Kurp8QbfsXgqAO4TYAsNzZAYxOCOjE0kjs4/pb9atm62yveYp2oxxcIatxPSv 7Tlg== X-Gm-Message-State: AOAM532ibajBV4rREDQzVD6lXwZFUz9a77qIpkJqxW2DWIRlOYTZVJw0 RFrmS26WFO9RNUgkF5dtccBX3g== X-Google-Smtp-Source: ABdhPJxEdEoxk4QkWTG/LbIw5wa4/oJkAIU0dpDguLktaDqFHaLdn7sPQWVl5NbgF//Vvgox/Hv3PQ== X-Received: by 2002:a05:620a:62b:: with SMTP id 11mr11556303qkv.229.1602245542390; Fri, 09 Oct 2020 05:12:22 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id g19sm5882365qkm.64.2020.10.09.05.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 05:12:21 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kQrG0-001xcJ-L2; Fri, 09 Oct 2020 09:12:20 -0300 Date: Fri, 9 Oct 2020 09:12:20 -0300 From: Jason Gunthorpe To: christian.koenig@amd.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, chris@chris-wilson.co.uk, airlied@redhat.com, akpm@linux-foundation.org, sumit.semwal@linaro.org Subject: Re: [PATCH 1/4] mm: introduce vma_set_file function v2 Message-ID: <20201009121220.GM5177@ziepe.ca> References: <20201008112342.9394-1-christian.koenig@amd.com> <20201008141211.GG438822@phenom.ffwll.local> <8fc28dfa-4bae-bee1-5aca-4e3c6e88b994@gmail.com> <20201009073900.GL438822@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201009073900.GL438822@phenom.ffwll.local> 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: On Fri, Oct 09, 2020 at 09:39:00AM +0200, Daniel Vetter wrote: > I just noticed this here in the patch because everyone else does not do > this. But looking at the mmap_region() code in mmap.c we seem to indeed > have this problem for the error path: > > unmap_and_free_vma: > vma->vm_file = NULL; > fput(file); > > Note that the success path does things correctly (a bit above): > > file = vma->vm_file; > out: > > So it indeed looks like dma-buf is the only one that does this fully > correctly. So maybe we should do a follow-up patch to change the > mmap_region exit code to pick up whatever vma->vm_file was set instead, > and fput that? Given that this new vma_set_file() should be the only way to manipulate vm_file from the mmap op, I think this reflects a bug in mm/mmap.c.. Should be: unmap_and_free_vma: fput(vma->vm_file); vma->vm_file = NULL; Then everything works the way you'd expect without tricky error handling Jason