Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3414999ioo; Mon, 30 May 2022 01:14:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv0mnckxcoRl42BeL1+6PDtUnavD1oj15trmZJu8+2wONIW1nVA8V2S6dDNyXQVDIqP3u1 X-Received: by 2002:a17:90a:c682:b0:1df:c4a8:5db6 with SMTP id n2-20020a17090ac68200b001dfc4a85db6mr21619325pjt.43.1653898499587; Mon, 30 May 2022 01:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653898499; cv=none; d=google.com; s=arc-20160816; b=ak/XfVfIEGZB00kJvTqP29TAtPneKc5FQJXlOrMKDXQHAOf67RnZ3BCLqpU2O1yDzA xuTrelmNRZp81ruimYk+t3+115eA400tI1Tf160NV+1NzjodCyrAHVCjL4QrJRcAr2iV ovZxAXfjFDqeHIzegX/R9ljB6fwBHT6A+SthqX42w0IY3roCr4tLUWPpaog9bqJZvgPQ 3HBsE+j2V8bciI/ser+4BduyA0xH6hTC7/J1pmkHCANOrqsD7ywatLGyedSin40/7yAl ggTOJKwv4OdPG5fvtbaNrv/dC2MdiZypwbRuVrGUJ1qx6x3N7fRuA3IhrzceeRQAfc9U tMZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iE+/v3VZjWp3g0HlT9cTev6jOXoDSRpgw7DrnfWK9iE=; b=LPhXk4brRybgmokblcm5Nr8AeUCvbcNgedhhWlRoLyHnoDLzopszlx5i6OCi2/byxp /f4lYlDX+6uQlsZPrq9GegQOafKLNqujtLK2Ce567EFRp9QpVLQMAvv5hud9Pd+6UzOT MIEX6Am3MvLaNJLME+Bk81HeLEP+Out63scakSBPChSzD9Fl8MAVY9ojQEvS97bwjHv+ GDUHAsvQXRPGpCJRP7cUdf9RclIoqgh8iTVz+4awTuQIZqgIX6PtZoMCkUMU5rJ7PL3X 5paWDG3jAPAOHtmFp7Z47ejEbxQhQLT/8FCX2SH/sOFkyApgUJPMME9H/lvHdCSwn1qa NtCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k21-20020a056a00169500b0051898a7dc19si15833687pfc.186.2022.05.30.01.14.32; Mon, 30 May 2022 01:14:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233180AbiE3INH (ORCPT + 99 others); Mon, 30 May 2022 04:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233195AbiE3INB (ORCPT ); Mon, 30 May 2022 04:13:01 -0400 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA1EB37A02 for ; Mon, 30 May 2022 01:13:00 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-fxl7M77oPbG42cUxnaCIUA-1; Mon, 30 May 2022 04:12:58 -0400 X-MC-Unique: fxl7M77oPbG42cUxnaCIUA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CFB13802803; Mon, 30 May 2022 08:12:57 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.64.242.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACE7B1410F36; Mon, 30 May 2022 08:12:55 +0000 (UTC) From: Gopal Tiwari To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, gtiwari@redhat.com Subject: [Bluez 13/13] Fixing use_after_free in prov-db.c Date: Mon, 30 May 2022 13:42:09 +0530 Message-Id: <20220530081209.560465-14-gopalkrishna.tiwari@gmail.com> In-Reply-To: <20220530081209.560465-1-gopalkrishna.tiwari@gmail.com> References: <20220530081209.560465-1-gopalkrishna.tiwari@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_SOFTFAIL,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-bluetooth@vger.kernel.org From: Gopal Tiwari Following scenario happens when prov is false and we have double free as mentioned in the below bluez-5.64/tools/mesh-gatt/prov-db.c:847: freed_arg: "g_free" frees "in_str". bluez-5.64/tools/mesh-gatt/prov-db.c:867: double_free: Calling "g_free" frees pointer "in_str" which has already been freed. Signed-off-by: Gopal Tiwari --- tools/mesh-gatt/prov-db.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/mesh-gatt/prov-db.c b/tools/mesh-gatt/prov-db.c index 2fb08f799..a5b6997e0 100644 --- a/tools/mesh-gatt/prov-db.c +++ b/tools/mesh-gatt/prov-db.c @@ -859,7 +859,8 @@ bool prov_db_local_set_iv_index(uint32_t iv_index, bool update, bool prov) set_local_iv_index(jmain, iv_index, update); prov_file_write(jmain, false); - } + } else + return true; res = true; done: -- 2.26.2