Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp634450lqm; Wed, 1 May 2024 10:50:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXoRNuXMKwZm2966E318EjLdQQ646P2Jjs5y/N5nBF+Enwctn1fGii5j0MUH4Xi9OkCjVZRbudmxHHC0aRdz6EzYJn5cJLMnD56l7hx3w== X-Google-Smtp-Source: AGHT+IFyUp/TnwdbQWzXPxPZYVC7xL/ffa/T9fhR2I3rhnaazKkLzrPcmpDRbSS7FG7V+y1YIWYR X-Received: by 2002:a54:468c:0:b0:3c7:3106:e2e1 with SMTP id k12-20020a54468c000000b003c73106e2e1mr3617264oic.8.1714585815508; Wed, 01 May 2024 10:50:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714585815; cv=pass; d=google.com; s=arc-20160816; b=AAM694f/mdZn4xBvty66rcbt88ZzmCPYUMIXZaY6pGwYTrXPJzvEHlXo+AfWtfDV+N uK/edPHdCNTnPc98VoVgd+Yn2wIRLEf0O9Iibeo2MtexBwjcpO8JE9KplpeQfe4CtWHB y6bsDnu2kgV9A8qqmYAosWxfQWjx23B9fzHnLUYwBT2mmvm7M0ZH1r5WeFz24ptSYVIy S8mR2BEfawr8UJXkvjxDWqp0+hpmRVe4aJXXatSw9lIXb9hncogS/HgmX5scLLXCCJHR 4zWzJ0RVCPhUYkuOUTX/C+5LfSy9TC2WBKCvXkRQqLV3Bc5nC/ccuvJtuie+jWshpzVo TExQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=qGBZJbcJC2IvIMGqJreKu4KHJBQqAh48/vS0akP7hFA=; fh=MVqpKOw+NtjYG0l66aid4cIhcUSIRPBPnvP9NzWMTso=; b=tBeIqLjiaQKzD01bwoQE1fZV0x3+i9OpKRjx/ZWPM6ANNPrPy1MTaTYFT8X2cBdspe 7jnDXPUXmZoeziQa5KZ7ZDBrcbubAE2KUkMc/OJzaO3FhIHnkFsvza69BtiSmzTyoJYL hicLUqmwSGcJ16IglUALh+EXGPnPPrS0xAUBeINMjpFCWDNHDEJEYF9LB/snFj3akZNV TFLrajdKtxJdSMfjFG4EWksBp0i13H8wDtGZ8BrGyM+5APDgpdqXpJRhMEgXsgCdSbDW VxB9wG5SZABhjT6qnW9GndzSBu10YR3barrpQP7FK3X0YzTRoDi1342FphBBWLgJ4oPZ 7H1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UvHbspfh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4234-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id wh13-20020a05620a56cd00b00790f6c6a1b7si6851752qkn.772.2024.05.01.10.50.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 10:50:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4234-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UvHbspfh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4234-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E924D1C210EA for ; Wed, 1 May 2024 17:50:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C761913BAFF; Wed, 1 May 2024 17:50:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UvHbspfh" X-Original-To: linux-bluetooth@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2509C8495; Wed, 1 May 2024 17:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714585806; cv=none; b=JjdLgaUeMV6dxH4c56syWz1l6kbMiWw6f1Kp+QjXhAPV0hePrBV6519ElqDlvZKVERxHgOD8VLqKIPQoxUGdQqGGkb1nPt/S68AfJ0VhWWN8EUJTcZUqXKUiyW060MvM5qzRPxWE4xLG1Aj3ywV2QXXaIKJrfZZ78y2iGw+C6Cw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714585806; c=relaxed/simple; bh=0EfiIpBtBr+YNfU8vUQr6lF5Q/I+R3DuRMpwVvzyS1U=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=f+Y3hsIb+BAWjzqG3q3RThkTqszDiE2iLDWvBKCybpGOe6vA8ogh8S+EMBjYOxcs6whxR/1kJoJ1WN6soWXPSPqowmkr0ko/tWCuQlNjjMyP6nmRMqcYIJLnd+9BkruMHhfnTtrX3RNW1vzCvyZhHGfsUhJ4HInySJV3nTRAfxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UvHbspfh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26DF4C072AA; Wed, 1 May 2024 17:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714585805; bh=0EfiIpBtBr+YNfU8vUQr6lF5Q/I+R3DuRMpwVvzyS1U=; h=Date:From:To:Cc:Subject:From; b=UvHbspfhwkjrYE8ShOvmOjDearA7qNJ62V8tFnnD5d1M4r6ixWfEhLqWPxKp585Jm x1e/1tgQmNBMwDHBOGmeaR6Slwm5dDpL4EJzmf8nv7hmBBmBF/H1hchgd6NqjpNCLF k69IJdkM+XQx0sSFEFjPe8jXQW8cGsOgy/LEZwiyZXA2ng3EVWgq/XCl/8adThmRgz QP5y35+Fo7ulvTlCklQBL9Ek1g8iHgtYZVCtAFWFfABESNV2YaoXBJ2WfEjipZ7IdB A5mb7Tfvuwr2+OIqC48b4TXUTBueg6dqsyhA2N7hgzbqi93JDZ9C7dwZMFSvXJMYy8 zRiok0vPJOvCA== Date: Wed, 1 May 2024 11:50:02 -0600 From: "Gustavo A. R. Silva" To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] Bluetooth: hci_sync: Use cmd->num_cis instead of magic number Message-ID: Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline At the moment of the check, `cmd->num_cis` holds the value of 0x1f, which is the max number of elements in the `cmd->cis[]` array at declaration, which is 0x1f. So, avoid using 0x1f directly, and instead use `cmd->num_cis`. Similarly to this other patch[1]. Link: https://lore.kernel.org/linux-hardening/ZivaHUQyDDK9fXEk@neat/ [1] Signed-off-by: Gustavo A. R. Silva --- net/bluetooth/hci_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 6e15594d3565..af9513f3c451 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -6559,7 +6559,7 @@ int hci_le_create_cis_sync(struct hci_dev *hdev) cis->cis_handle = cpu_to_le16(conn->handle); aux_num_cis++; - if (aux_num_cis >= 0x1f) + if (aux_num_cis >= cmd->num_cis) break; } cmd->num_cis = aux_num_cis; -- 2.34.1