Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp500347ybl; Wed, 28 Aug 2019 00:52:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMoFzGvStDS3f5JCj0366emztPdGk9rSmGLaUFndLtWqS8k4J96YmclLDL8iiikf8lub6D X-Received: by 2002:a63:5811:: with SMTP id m17mr2299662pgb.237.1566978733955; Wed, 28 Aug 2019 00:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566978733; cv=none; d=google.com; s=arc-20160816; b=Thn+CeajMQS/hni7jOMFMh5abktESwOphbjU3q3RcQDowv0gDAh7KsnNsgdanMvne4 Do89+sHXZdKgrc3BUhLfkxHAOgujR6QK3EB06/h6GJquFqA61N5OrqDbYZ1RSn3Su8np 2bPsouDSWfXBvJcPG86tpYES/qdyJFGy3YYUTHIpK440P5XveR9fux1vmzxezIx/xJsA OGW//WcCvPxmv/uiX8d6cAloT6NDB8BP8p6HIvZ0Q+1XLHdCTefYNLnFRyAmgXbC0IWb ql4jxZwIIu+O1phHUaYgoZpYeJiUvaF72qMLMsIF8WjwzsszrjQ95An6gdJ3jgzaZL25 QISg== 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=IbA/cfJmEgj2/uah+03wQlbIw/RMKKPtS7QXkq4AsO0=; b=NOhUHUQ7TON7rsrHnsqm0tjYT+1sDNAJOUp6KS2iV/0f8IAgWIi8GijVmlC72domxd 3lPLh8Bi1qyJ2ZiQrbpK0odTqAz3d8TMMNX+Cywp+S1KAQMLKxCr21/dBYnbTIKfdVcS WxrMVlSWmK6OkMCnn9muPqZoPkPmjioNhkQTrCLrMKVosKY3BZf9K3NpQW5ZwNdarSBk dnEP8tgq7QLMZGJDtOscGndfYyeG/GFbbrp1+s0H7+vMhMCyHRBT8WsnC3wovaIprmCr wGI2epZcF0M0lfradoDosj/6MSWHkR1laXJq21qY9m5jBIt4KapBALuvB3wJfA8pKhVP uYTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ukBoEAhX; 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 q13si1598162pgq.317.2019.08.28.00.51.57; Wed, 28 Aug 2019 00:52:13 -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=ukBoEAhX; 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 S1726399AbfH1Huu (ORCPT + 99 others); Wed, 28 Aug 2019 03:50:50 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:32768 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbfH1Huu (ORCPT ); Wed, 28 Aug 2019 03:50:50 -0400 Received: by mail-wm1-f67.google.com with SMTP id r17so1110135wme.0 for ; Wed, 28 Aug 2019 00:50:49 -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=IbA/cfJmEgj2/uah+03wQlbIw/RMKKPtS7QXkq4AsO0=; b=ukBoEAhXjR5VGvNcxa2/RYqZbueOgkhitDp4eiseaig2Blmwk+E45yJuZcm5gFGZvH HktQvDSxBG5HtjDrzV2DT13s2fINftzz65jlIKrLSLtRdE8O5x/AtkeJlQR/T3k0NafD MUgcPzKPzzUAudbTsYksWYQ7JVUSLTkleAK41OnoTCQ73+gM9Qq4sZVpNDqoEULAZiGg u52/oWoEzhHtreqGfEqQvnjbdcI3UnVYj0Ho07IpX3Cud0d7EHdoS8/Cq9/rV75zHFHN KmUBp8KmL/dUsIklVjOfUff14sh/O3HGAY7k5MYUHvVWtKPWUlqMz2T/bTOy5Z9KsaWD c/hw== 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=IbA/cfJmEgj2/uah+03wQlbIw/RMKKPtS7QXkq4AsO0=; b=oX71XGL6XvTxB4Go3JQGpMxo3rZUPCHmfGHgz1EtCNbi8gy1uR59d3dBz/lt+Q8t3t zwfTHsc4biWB6nkXk4DuO8AoqQ1vRfnal61ekfnStKPzuX+NZ3qIfs5c647km7fPqLsF PMUCgk/zUa6vC/UICeuZqM2Ujhchvigo3OM6w2Tno9J4nkA/tvStClrBn4U5y1c9SVdS 8RcV29LHpkOH9kORkxMnrJd9SCl2g8scqEPXDwDr88mdviLyBm8mzIRJCbOTB7AunY8R LHDrJD/shtizMSITAC31s+D4Px6P3ZtOzeyBTSO8eE45RLVNBkFdSWv1GCTXCwdt7ocW sN0A== X-Gm-Message-State: APjAAAWo1n/P3I4a1rxxZ5USmutlbLApxql3YJ3+Zb2usMZxXNV/DEXy fnyQxH1urXnJlkyuWrAf5/PTAtcrmbM= X-Received: by 2002:a7b:c632:: with SMTP id p18mr3163278wmk.114.1566978648329; Wed, 28 Aug 2019 00:50:48 -0700 (PDT) Received: from [192.168.1.6] (124.red-83-36-179.dynamicip.rima-tde.net. [83.36.179.124]) by smtp.gmail.com with ESMTPSA id d207sm1695375wmd.0.2019.08.28.00.50.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Aug 2019 00:50:47 -0700 (PDT) Subject: Re: [PATCH 4/5] misc: fastrpc: fix double refcounting on dmabuf To: Srinivas Kandagatla 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: Jorge Ramirez Message-ID: Date: Wed, 28 Aug 2019 09:50:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 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 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. but my point was that there is not a huge gap in efforts between doing one or the other. > > 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) > > > --srini