Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp102545rwd; Fri, 19 May 2023 16:11:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5m9YxYN5q8gGrH+NHzqFlKxaDnIQCC3v32Nsz1evBd14CG6RVQjDAFsksTrhCzBzpZr/9t X-Received: by 2002:a05:6a00:2195:b0:64d:42ca:a4c4 with SMTP id h21-20020a056a00219500b0064d42caa4c4mr1189166pfi.31.1684537900787; Fri, 19 May 2023 16:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684537900; cv=none; d=google.com; s=arc-20160816; b=Z459w9QzL45isi2yZoqrn3vEEehUYnFudqO05NApqglgMGgdRQRgJV8Zol3IKPgoOH IEFSoDIoZnY4K3plcF8A+A+TO/ydVLzWP8V8Mb9cmFP5UnERCzxjCsUGmYaZvHMRUKm/ H/mEOOIiYCWqUcSmuWql/SW+fVEEdFnluTGio3kZiVODbWuy85Nd2lKhplAAvQu4WCLX zAw4h3K02KZTDcY6aokCd5eV9AcetXNVea7Ucp6yg+RCwk5gGQV1ylmcV4nGOW0qGgV/ 9Xn4jXmuBIoNxqrOOahHRk+1SrPrXTlFirN9SEPu3dA21gCG2AA/IKgtF8rIJ9Bmv8TI Xizw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=lT3nVX8BOP6xdFUAxxsGq0VwKjJtQEdxnV8AqojOVvE=; b=WWQTw3cxhRR4mVn65jTr+6RtVPt6FAc7tlWRJ9xGHS5/O/wXQ2P1qow9Cwik2g+Jc4 gltu1baSsfUIRAJOUx0ApCP/09DRtBCACNSvYqB0egGQTGr78Um1QSzdCpDMdcDvZRV+ dVgp85hkpjQFO6zOLSJ1Eogt+gd+iXKfhkRLBa9FZj2mFKAlQsi0JIhAeTVVwuwNFjf8 CQ9FAj/NuxWZljsh6q8etfazgTFPJEdMQpV1v/SgsNpznsWoCuboGErGRAw0vm5yyQTi 7Ty3fuHvLQe7tjo38ek0Mmchs/FZXAaSrJI1xhPQzmDHkcBGMpvI72qjQ9k9ySGRnB0Y lrvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f66-20020a625145000000b0064d295ca592si385812pfb.69.2023.05.19.16.11.28; Fri, 19 May 2023 16:11:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229566AbjESW6O (ORCPT + 99 others); Fri, 19 May 2023 18:58:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjESW6M (ORCPT ); Fri, 19 May 2023 18:58:12 -0400 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF9B1E46; Fri, 19 May 2023 15:58:02 -0700 (PDT) Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-64d247a023aso1663259b3a.2; Fri, 19 May 2023 15:58:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684537082; x=1687129082; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lT3nVX8BOP6xdFUAxxsGq0VwKjJtQEdxnV8AqojOVvE=; b=G4zQo875H6QgGCt/ELHZWPc5M13RsMIMJUenfmaNPxgrTdnvpli3cJ5sKr1qpgurNx f/Frs0t8etXo5EjkBgXJsuB5loRA4uqRsQEqh+4GHlurCVCCSMFXLct0mS3vP18ylg3i ykpedVuBytPy1c7+dxGr4+TWeif95YpsQigav/oDY7utpu4WDx/YtadLsL/OuiQfj9AP aSzfW2QtZDhnKIfODzqZLacTKkd1ydOuPNN+DTbMNvsAAErHY3D3KTXqw0VMqHu3k5j6 1d216j+6xkRxWHfmMJmlLle07TUZ3Gi6ZmCwMnkn7KC21XHU90OAbQTPs45L3759Ng6C hhzw== X-Gm-Message-State: AC+VfDzLTWFRrQRAkOB4W1I1oA0HFbBeULZMq5NVd9Ilgw1GU0SAlH2D eVVocdfxZuWf/63bwV891kc= X-Received: by 2002:a05:6a00:1914:b0:648:b185:efd9 with SMTP id y20-20020a056a00191400b00648b185efd9mr4424120pfi.11.1684537081838; Fri, 19 May 2023 15:58:01 -0700 (PDT) Received: from dev-linux.lan (cpe-70-95-21-110.san.res.rr.com. [70.95.21.110]) by smtp.gmail.com with ESMTPSA id e24-20020a62aa18000000b0064d3a9def35sm166486pff.188.2023.05.19.15.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 15:58:01 -0700 (PDT) Date: Fri, 19 May 2023 15:57:59 -0700 From: Sukrut Bellary To: Srinivas Kandagatla Cc: Dan Carpenter , Abel Vesa , Amol Maheshwari , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Shuah Khan Subject: Re: [PATCH] misc: fastrpc: Fix double free of 'buf' in error path Message-ID: References: <20230518100829.515143-1-sukrut.bellary@linux.com> <9194ebdf-f335-4cd6-bf89-bb4f86a57784@kili.mountain> <4aa42c38-e0e2-4d2d-bfe2-15bc151f7117@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4aa42c38-e0e2-4d2d-bfe2-15bc151f7117@linaro.org> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 19, 2023 at 11:39:59AM +0100, Srinivas Kandagatla wrote: > > > On 19/05/2023 11:22, Dan Carpenter wrote: > > > ----------------------->cut<--------------------------- > > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > > > index f60bbf99485c..3fdd326e1ae8 100644 > > > --- a/drivers/misc/fastrpc.c > > > +++ b/drivers/misc/fastrpc.c > > > @@ -1891,7 +1891,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, > > > char __user *argp) > > > &args[0]); > > > if (err) { > > > dev_err(dev, "mmap error (len 0x%08llx)\n", buf->size); > > > - goto err_invoke; > > > + fastrpc_buf_free(buf); > > > + return err; > > > } > > > > > > /* update the buffer to be able to deallocate the memory on the DSP > > > */ > > > @@ -1930,11 +1931,7 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, > > > char __user *argp) > > > return 0; > > > > > > err_assign: > > > - fastrpc_req_munmap_impl(fl, buf); > > > -err_invoke: > > > - fastrpc_buf_free(buf); > > > - > > > - return err; > > > + return fastrpc_req_munmap_impl(fl, buf); > > > > This will return success if copy_to_user() fails. > > > that is true, using return value of fastrpc_req_munmap_impl does not really > make sense here we should just return err in either case to the user. > Thanks, Srini and Dan, for reviewing the patch and suggestions. I will add this in v2. Regards, Sukrut Bellary > --srini > > > regards, > > dan carpenter > >