Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1300776rwb; Fri, 7 Oct 2022 10:34:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ntwtVC/1m1p743GqIVuIO0cvPfsjnNN6pN8m6N1YV9T2ALg/jdB90V/WSr8yoL3ppEgZZ X-Received: by 2002:a17:907:7fa3:b0:782:3034:cbc5 with SMTP id qk35-20020a1709077fa300b007823034cbc5mr4922521ejc.96.1665164068013; Fri, 07 Oct 2022 10:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665164068; cv=none; d=google.com; s=arc-20160816; b=XJLG6BVEhG4cEocbhSUCo3Oi+fiBaYU7EiFh/ZSDdeemyaF5LBOGdwV2GwoypJCS3t qjjHP155IGVVDneQ4+xW/aBpoIGpEYVpH1yb8MB0PG23/qHR2d2mO9aD/Z3FVmQOfzeF ioJJ91NYfB2OK0FEQjURDVy8WSgW0j8heE4qvb+FPCdtvyKsPl0ohU8a5dy9P1mjyidh ixvHanCb8gaIBzUQ+aIlpvLdOBLr6oF9aJBjU4SlVdQ7Uvy8nH/gs4A0v3+1U3HgJwMk oexXvVdqBG2J47tBAYew1gaGIdUYLfzo+p6YeiZmJsvQJxLdcjEI+/c//yW5BYAfV9BI CZPA== 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 :dkim-signature; bh=qTI8G1DBmfSXRe5I/pK54Tf2OOPvQU1FO+2DI8JYNTU=; b=OmsE0QJ/OZGtJ/iWa5lnmatGDiFb3Oi0Xm7Gh8B/M36kHfrLQaQQbkwk+1ocdWRIrQ dnVfvmYThdazuDUlHYIwpFeHB1H1pB+Xgi5EBCgoDWsq8dBdxzJGFfom+RmdTAYABEyb 2Ke6wQFsi4+X+1RM+MjTFFpfkAIkfjM0+MAt23UJqmmcww46kqTV47RuNQBpAeet6q6C eqfIG7lNk8t3JChrjXSLFntLfEa4v+LVp8HgQgqaHl4u5B5GCtXbAOWPk5o48Mp3Je8F yWhfWPNhKq8JGYCN6StBvO4yDTRODlNvgG5lPqqPktlst99g+CpuN/Psfn/6BhupAzdd M52Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T5v5ksFa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs35-20020a1709073ea300b00780a882d337si2714702ejc.480.2022.10.07.10.34.00; Fri, 07 Oct 2022 10:34:28 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=T5v5ksFa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229693AbiJGR11 (ORCPT + 99 others); Fri, 7 Oct 2022 13:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbiJGR10 (ORCPT ); Fri, 7 Oct 2022 13:27:26 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 289463B711 for ; Fri, 7 Oct 2022 10:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665163646; x=1696699646; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jwd0dT8DgPzOyvb0ouzJt1hKZ4xUfTiNsDMLr0rJhNk=; b=T5v5ksFa0vBHQMI3N5ZeiC1dlRINUOAi1PV0+0E/XSRWRVebDVUz28nr +PfFF4liDd3yD/S7iEYdDaBj51I4vOKfmioeWfSb/ER1dvSAafPARA8JM d45sTXTyNBjDgnlSBiBOZ1ycQZWZjFOvGgqsYHpl2qjIJFOBVXzmyfWNu bx7BCRU2A/NuAoFKbLofgKrJ7dszBONbjqrlYs0ZizpfUW9WzITwb4xs4 lmGkFEIzodIjsKPZcYoXboheJmbO9TnYmZV3906B6XKa6armmmXst9FvV RMD+zCXoyKjUUplBNy+tnpYMfCEamh4Y6L42Y+JfPjXG2ZEnQEeuAzlxp Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10493"; a="301388894" X-IronPort-AV: E=Sophos;i="5.95,167,1661842800"; d="scan'208";a="301388894" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2022 10:27:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10493"; a="658410299" X-IronPort-AV: E=Sophos;i="5.95,167,1661842800"; d="scan'208";a="658410299" Received: from tester-latitude-7480.iind.intel.com ([10.224.186.120]) by orsmga001.jf.intel.com with ESMTP; 07 Oct 2022 10:27:16 -0700 From: Abhay Maheta To: linux-bluetooth@vger.kernel.org Cc: Abhay Maheta Subject: [PATCH BlueZ v2 1/1] shared/bap: Fixing memory overwrite during ASE Enable Operation Date: Fri, 7 Oct 2022 23:15:17 +0530 Message-Id: <20221007174516.22335-3-abhay.maheshbhai.maheta@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221007174516.22335-1-abhay.maheshbhai.maheta@intel.com> References: <20221007174516.22335-1-abhay.maheshbhai.maheta@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 This fixes memory overwrite during ASE Enable operation handling. It avoids crashing of bluetoothd if metadata of more than sizeo of size_t is received. This also fixes storing metadata to stream structure. --- src/shared/bap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 178407387..c3c0d596f 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -958,10 +958,14 @@ static void stream_notify_metadata(struct bt_bap_stream *stream) struct bt_ascs_ase_status *status; struct bt_ascs_ase_status_metadata *meta; size_t len; + size_t meta_len = 0; DBG(stream->bap, "stream %p", stream); - len = sizeof(*status) + sizeof(*meta) + sizeof(stream->meta->iov_len); + if (stream->meta) + meta_len = stream->meta->iov_len; + + len = sizeof(*status) + sizeof(*meta) + meta_len; status = malloc(len); memset(status, 0, len); @@ -1743,7 +1747,7 @@ static uint8_t ep_enable(struct bt_bap_endpoint *ep, struct bt_bap *bap, return 0; } - return stream_enable(ep->stream, iov, rsp); + return stream_enable(ep->stream, &meta, rsp); } static uint8_t ascs_enable(struct bt_ascs *ascs, struct bt_bap *bap, -- 2.25.1