From patchwork Wed May 1 17:50:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13651047 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UvHbspfh" 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-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 Reviewed-by: Kees Cook --- 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;