Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp553974ybl; Wed, 28 Aug 2019 01:50:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMNDz8v8BrIN8+yvbs9zopGN9Um22K/AW9LXJEt5bLWH51Deo+nmszy0+Y3kdpW4PkOyYX X-Received: by 2002:a05:6a00:cd:: with SMTP id e13mr3468434pfj.202.1566982240158; Wed, 28 Aug 2019 01:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566982240; cv=none; d=google.com; s=arc-20160816; b=QSDBwQGC5jE8rpWbG/dN4q/8p2fk+Kuiy6Sba0PM3Xb8Lwq8uxenJ9MSg6edtCA4hB LCGWaSm+bMS1XniBt4tbNM5rJDGzzzjHH2+Qz4HHwvhGPKS5VtM4LnbRdaIKDpwi/6nA tRz8ItvyipM0qaeXjmACAPG6K88DTumMXtWIRTeZynfDCzrd/PDvGkix1dIczhBxOeda 9aHd7qyra3gTwq0LBkE6Wa9mUDhdQpmBaHgMxzzRcdCWhLcbsa+b2ArO0Yqt7Vam1UYd uGBAQ7hFQXlvn8418z7VXe81+bnxFaeBtEZpYbBrc9hM3ksgFJCUohP2RYf9maSAVtTh Lj2g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Lh087UDN3bHwxNKU9oXqXSmgDMXMIewzXIKR9m+6i0E=; b=OiaSkDcANxYRJrVxvA57fladR+CB1lBYmkmLKeR2HVMxEczZLkkiAx+IzZs2eCafFe /p/A+MT1VxDBXgql4gX42BDuyTFrA5Fr0dfqCTcMmiFRoNvLdoGhD7MUtc9amr9Bi5aL eVTaDEz6AcKkbuG2ekWeo2yyMvCggEfWzaqDkuB5o+pQzFTzi2oZMlRwYyP4YmxjEeVU hSgLHD57RI8WQrxX2uB8HcBq4yw+RU+LNx7gyZL1s0it01leCIrINqHJrLqgtaxFEGDz CCHVRV2oOyeA3uSPDANuKqbGPZR9Sb46DhDaEipInrvSdw0YFU5bZ78IOLL/pYTLrc5k +FdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8Wo5R1g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5si1643069pgp.299.2019.08.28.01.50.23; Wed, 28 Aug 2019 01:50:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8Wo5R1g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726428AbfH1IsI (ORCPT + 99 others); Wed, 28 Aug 2019 04:48:08 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42634 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbfH1IsI (ORCPT ); Wed, 28 Aug 2019 04:48:08 -0400 Received: by mail-wr1-f65.google.com with SMTP id b16so1593906wrq.9 for ; Wed, 28 Aug 2019 01:48:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Lh087UDN3bHwxNKU9oXqXSmgDMXMIewzXIKR9m+6i0E=; b=V8Wo5R1gkblbmEBDK8foSh7C8UDtmz4d0IduZExmjWX/5IB95wO3kIXkuEoGhrZfEH L4H0pBBEJbHaUC8rJ9oAlPItBkDc137JyPrs4bGEaDbmUcknCxqVixzEYbiGA0tnaS4L NYkXtgo3FO3XYNGTGrJisbxOoQDaE0Qzs20m0+fEo2BCdhg5vj5TWvOuR4qaUeToYlC9 vjsbILLTw5rhfyHlSFy6LHBIMVv9idAS0aptNCnv5kyuoRFbJju58nUWXVsAo01L+JPu aNbsuPL8QbptuLmqEQ9Tbp9m3YoE0oHfBiBCorWXxDVeN1QNsdVPKrOnGQvXSe9tGYD9 w22w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Lh087UDN3bHwxNKU9oXqXSmgDMXMIewzXIKR9m+6i0E=; b=Fbmzqbgx75sRoRrDIumvvBv64lTx5dKbYgiMNk7hGDuq+916ApDakx2UCLztQR2gZM WlR11FPLFGQgYU8BGg7bN5WQxlwdhXZd2pkm9pUf7/Ad6551Z0a9mBrZBsREYZThmYU9 k5Zxw32sIoJ8ncj1a04pbyjIlDGc9ttS5+l9BN3TIR7uMW457tHmosc5uly//iNleFEa PVX2G88BerNVowhF/sZtUDIyhD+JEEbDoeR3v27ogDb4l7ogzg6DLYHMNtozLM7VEm+r TsHIg+d72zoLBXnhHgjvdSnEm/N+caA5Y63z6uFluzbPdHmeJ00pbO80+7Ky+58B6Zpq IkmA== X-Gm-Message-State: APjAAAXIw3sgpv1OJv/piZoXkEOLc0zmZYHXgMfNdbg2KhdneuxqCZQx EigzrDhnuOq9LQ8++7DMpTiW3IygMmg= X-Received: by 2002:adf:ce8d:: with SMTP id r13mr3127105wrn.37.1566982085434; Wed, 28 Aug 2019 01:48:05 -0700 (PDT) Received: from [192.168.86.34] (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.googlemail.com with ESMTPSA id u6sm1488731wmm.26.2019.08.28.01.48.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Aug 2019 01:48:04 -0700 (PDT) Subject: Re: [PATCH 4/5] misc: fastrpc: fix double refcounting on dmabuf To: Jorge Ramirez Cc: Greg KH , arnd@arndb.de, linux-arm-msm , Linux Kernel Mailing List , Mayank Chopra References: <20190823100622.3892-1-srinivas.kandagatla@linaro.org> <20190823100622.3892-5-srinivas.kandagatla@linaro.org> From: Srinivas Kandagatla Message-ID: <6a34823b-4a1d-c7de-a4c7-87587705708b@linaro.org> Date: Wed, 28 Aug 2019 09:48:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/08/2019 08:50, Jorge Ramirez wrote: > On 8/27/19 23:45, Srinivas Kandagatla wrote: >> On 23/08/2019 16:23, Jorge Ramirez-Ortiz wrote: >>> can you add me as a co-author to this patch please? >> No problem I can do that if you feel so! > yes please. thanks! > >>> since I spent about a day doing the analysis, sent you  a fix that >>> maintained the API used by the library and explained you how to >>> reproduce the issue I think it is just fair. > the  fact that the api >>> could be be modified and the fix be done a bit >>> differently- free dma buf ioctl removed- seems just a minor >>> implementation detail to me. >> No, that's not true, this is a clear fastrpc design issue. > IMO the ioctls defines the contract with userspace and the contract > establishes that userspace must call deallocate. the kernel wrongly > implemented to that contract since it doesn't handle the cases where > userspace can't send the release calls which leads to memory leaks. this > is what I meant by and implementation issue. > > if we had many fastrpc users, rolling out the design change that you > propose - removing an ioctl- would definitively have an impact. But > since that is not yet the case, there is not doubt that your patch makes > more sense. Exactly before it make a way into other projects! > > but my point was that there is not a huge gap in efforts between doing > one or the other. Thats not the point, point is about right fix! > >> Userspace is already doing a refcount via mmap/unmap on that dmabuf fd, >> having an additional api adds another level of refcount which is totally >> redundant and is the root cause for this leak. > yes it is redundant but is not the root cause for this leak. the root > cause is that the driver doesnt handle the case where userspace didnt or > was not able to call release (and that is no more than adding allocated > buffers to a list and clean on exit) I don't agree with you on that. We should not take an extra refcount in first place in driver. let me explain it one more time! dmabuf has to be mmaped in userspace app before it is used, and "Memory mappings that were created in the process shall be unmapped before the process is destroyed" so the refcount is taken care by mmap/unmap automatically. --srini >