Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1297813rwb; Fri, 7 Oct 2022 10:31:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7g2Al/MKDrYRfla04wJnZyQc+o3JMKssyfJEJiO3UX7c8QOVy7T44JRmrvhQFX7wUTxEax X-Received: by 2002:a17:906:9bc3:b0:78d:816f:3743 with SMTP id de3-20020a1709069bc300b0078d816f3743mr2838887ejc.380.1665163917549; Fri, 07 Oct 2022 10:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665163917; cv=none; d=google.com; s=arc-20160816; b=zRDZX2U8Vge1MxSjvShlgvoqP4NGipVICTyeh8RL2hqSq03Dw22t8SehbTedPIAep8 8O5w/8VJi5VS5HvDJyr4KPjV+Sx3n1Q8x3NCll/92HvbucAWZNhPV1n+39WhFKwKKIeH gfp0Y1vDAjyGzl4wKzTEPmC7/jegliuqjpNeyI4+5Uu3s0s0d9AkiIGzfc80WKs/Br09 3sGlIDsLhMrC1qMFuinGrnD99XGNYDPNJ9bZv0gniYLD6CmyQnFZvHRoqNED6mKOdCXn Yqb7xZ9KiFRzUwTCggmuHYA0WWIpfkBTA+Ixolc0QEdySqBJ8jPlyiZEGrDneTyWhL0V d9Sg== 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=sEdrDwipYdZYbueV1ldCMKP6X0iw3YBwCZEccNUMVPQaQYpJqXFOK9dAi9nq9nE/dv /NTMVj754lTLR1CVcZeqykiaXcNrZ2Xj8TLI8sBzFgL3VoTbMM39b7GEyHv5QmaOUB5A rOgSm9tuZxjb2ulA204tQbSrl3epUyKNaxgb8CBrR99SJ8aivzSs3wVpFGNDiGxruE97 24MAoQAURYI7+wNMYnGhyOu5/dmp2TopY6FSGNYpcvMSyuUPAIS3pglSsriv6/uVwndo QOZ5OccDTO4FDUY1Q294KNnPOdfxY4M2tICAMOAFGdVAqvqr+XFU/l9vqM83B03VyKr7 3JJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=URtXsXcJ; 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.31.30; Fri, 07 Oct 2022 10:31:57 -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=URtXsXcJ; 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 S229592AbiJGR1R (ORCPT + 99 others); Fri, 7 Oct 2022 13:27:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbiJGR1Q (ORCPT ); Fri, 7 Oct 2022 13:27:16 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2ED5CC838 for ; Fri, 7 Oct 2022 10:27:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665163635; x=1696699635; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jwd0dT8DgPzOyvb0ouzJt1hKZ4xUfTiNsDMLr0rJhNk=; b=URtXsXcJ19UGnV3zDceCsYmfHcH0hz6VYHzxbFNctq/j5IP3GOldAg6U VNsINJXJhMmb1122bh48k5WeQ9RlUAcnQ4oj0cCEURx3eQL7wjYWV+WfW AuHqVvKrFnxFp/EGH4mS9jvMdNiGTVGXxi+lG5TcNeCkMkGO32kBX42yX LgTbWb7TL28ElVB9ONdTLXpU7SAPT6G5DP4yC30PgKzBD+c84b58bvr6L Pj6H0hN0xrM20yiWmDWYsFUZulL5S4EvWxLFeVMYZtmVbgaE/azN6dmLV aA439bFdxa3TuJ11pAodyoAUfY19A1TS6laYFCEjlexC2Ihymw7qDkS3J w==; X-IronPort-AV: E=McAfee;i="6500,9779,10493"; a="301388888" X-IronPort-AV: E=Sophos;i="5.95,167,1661842800"; d="scan'208";a="301388888" 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:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10493"; a="658410268" X-IronPort-AV: E=Sophos;i="5.95,167,1661842800"; d="scan'208";a="658410268" Received: from tester-latitude-7480.iind.intel.com ([10.224.186.120]) by orsmga001.jf.intel.com with ESMTP; 07 Oct 2022 10:27:13 -0700 From: Abhay Maheta To: linux-bluetooth@vger.kernel.org Cc: Abhay Maheta Subject: [PATCH BlueZ 1/1] shared/bap: Fix handling memory overwrite during ASE Enable Operation Date: Fri, 7 Oct 2022 23:15:16 +0530 Message-Id: <20221007174516.22335-2-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