Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp501053ybt; Wed, 17 Jun 2020 06:45:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybJIH2pMaxkHNcpEBJMa3bTsoCbDCtvRDKW0j7rm+gwXyEb+Darzj1IQZd53HaIEjookLI X-Received: by 2002:aa7:c4c7:: with SMTP id p7mr7626879edr.271.1592401549560; Wed, 17 Jun 2020 06:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592401549; cv=none; d=google.com; s=arc-20160816; b=sNdsq3ZJj5ZzgFJ4a6q+svTG+M7i/NFQ8PsFFkQVxOJCuuIQEifJp+daZ4RogBD9D/ OT1tmFAYzPs5EiZiA6sW3Y8rMvKylfrty8zD1YdaOKMhtl7dMImt6J1PtLPmVV/7BezO zXkdDGLALwmsuOCBhzuxHO0VLjZ6JawKYcVItsR7LGhrV90gCc7NY/JlhdaryClU4h+Z KqbsFqBrRW9heHybXWtKJHEY8a6ulWthUpSrZ+6C3SvRjEkZnDtDCDwfxBeNAlfQwHol 6r1oN2EXHIgII0kLHIiTbm7Dq3cNMOe93gK5ik9woEKZXRQvbJgBNLN+6wUq1iPd+erY +uTg== 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:dmarc-filter :dkim-signature; bh=0rJg/220vt9zUyvHiVMMZNyLy4HIJD5Z/P1Mdz9z7JQ=; b=hwBXg3vE913gmsVPQ88DowMGikZrW92QfqQm7kVidcrsUIGmREQgaXaf3k47Sea3Ix PBXMCkE6O+IHn//WkHRqu0UghpZALIVSJ8eKjG7MZ8KdyEVScmYlmqjlN2gZ2BXUGPLv kWzmIVDQOJMV5RroapyxwOXeygAsU13JAtlKPKM1x4mmEcjStFT2LupYiRMhC9lqPXU/ Lj+RghKiiNRzfocsMHl5aV1lxTMTZt84busr0+8X+yVC8MP4JMK0ymMX/ZNjDpZiYFm4 JQKts0myMVHWaucWoVW/KXe75xRaG6j9XsYWfBS7C6E4I9iRuJEpoTKHYaINiNh5MAKt PrEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=ot3VBFHm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p20si13515564ejg.263.2020.06.17.06.45.25; Wed, 17 Jun 2020 06:45:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=ot3VBFHm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbgFQNnT (ORCPT + 99 others); Wed, 17 Jun 2020 09:43:19 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:52375 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbgFQNnT (ORCPT ); Wed, 17 Jun 2020 09:43:19 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1592401399; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=0rJg/220vt9zUyvHiVMMZNyLy4HIJD5Z/P1Mdz9z7JQ=; b=ot3VBFHm0iKIrNSknpdCk6y+sgyhkqeci8I75isB+1RSYCtoRy1A9qMSMJXFjlhOLBAN9Zm4 iMRGxvAzI+Rh/o/1rFDLPNKla8namPp05pPgdj59H4UhgA3QLStdNUIrkeOA2qhKxfLdsxmC MtAV+YK0NJIAEnHhHYawwCL68gQ= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n13.prod.us-west-2.postgun.com with SMTP id 5eea1df6e144dd511574ddf9 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 17 Jun 2020 13:43:18 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 9BA25C4339C; Wed, 17 Jun 2020 13:43:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.1.102] (unknown [183.83.143.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: charante) by smtp.codeaurora.org (Postfix) with ESMTPSA id 625E8C433C8; Wed, 17 Jun 2020 13:43:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 625E8C433C8 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=charante@codeaurora.org Subject: Re: [PATCH] dmabuf: use spinlock to access dmabuf->name To: David Laight , "Ruhl, Michael J" , Sumit Semwal , "open list:DMA BUFFER SHARING FRAMEWORK" , DRI mailing list Cc: Linaro MM SIG , "vinmenon@codeaurora.org" , LKML , "stable@vger.kernel.org" References: <316a5cf9-ca71-6506-bf8b-e79ded9055b2@codeaurora.org> <14063C7AD467DE4B82DEDB5C278E8663010F365EF5@fmsmsx107.amr.corp.intel.com> <14063C7AD467DE4B82DEDB5C278E8663010F365F7D@fmsmsx107.amr.corp.intel.com> <5b960c9a-ef9d-b43d-716d-113efc793fe5@codeaurora.org> From: Charan Teja Kalla Message-ID: Date: Wed, 17 Jun 2020 19:13:12 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/17/2020 1:51 PM, David Laight wrote: > From: Charan Teja Kalla >> Sent: 17 June 2020 07:29 > ... >>>> If name is freed you will copy garbage, but the only way >>>> for that to happen is that _set_name or _release have to be called >>>> at just the right time. >>>> >>>> And the above would probably only be an issue if the set_name >>>> was called, so you will get NULL or a real name. >> >> And there exists a use-after-free to avoid which requires the lock. Say >> that memcpy() in dmabuffs_dname is in progress and in parallel _set_name >> will free the same buffer that memcpy is operating on. > > If the name is being looked at while the item is being freed > you almost certainly have much bigger problems that just > the name being a 'junk' pointer. True, thus needs the lock. > > David. > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project