Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp162108rdb; Thu, 25 Jan 2024 11:08:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IERl+dovO5co/PGMw6b7/bhZzU9DIDf6fUx0SXGGBLOUdgBzjRvDkyO3lhG/bp906htF++w X-Received: by 2002:ac8:746:0:b0:42a:74bc:5b1d with SMTP id k6-20020ac80746000000b0042a74bc5b1dmr29753qth.2.1706209720217; Thu, 25 Jan 2024 11:08:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706209720; cv=pass; d=google.com; s=arc-20160816; b=D0ycbjx8leaYEGfXGyNdF1vBX01HU27pkC8cFVKDSytnWrYf6gnx5+azOdiOJp0DW6 AJjCaXNBg0Wq/cj7Sm7S4chnIL7AqrJ3tk8OwayWWowzAjUGB65PARXcChxua+fQyBj6 +V4elKZV5U6CT8WEUG3DcVyEgWRHJlD+EoecP8aTzuP4tt9ytFBu60aVElFo3xMOyFBn CobOWZkYeY/bdvikwLOB1lQjqpvEsR8g6cMQOZErEtNEIT1r4Wgcpt1Un3hfGH5V4ZZw PsRW4LFWbJ7m/GTF497KrsI5hhJ/4iuYi1MfuIsMWuHQRWmy5xUUmEIfPyRT+bTvgCJ6 pCdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=GrwLzwCUpBKmvFZOPxUCXNHgcs3d11GxQCGFjjVWUD8=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=gfP82HiUu3tgXG0PSJGT7ZX3XeqjY1UqrqAaEE8OiA4+lE7XwosH9BEDUfblHbYoUf REdWeK9QcwSb4jDbuo5Mk88G8JXHioIBOP4GivzJQj5LOBA+aUzNa3nWzgG06Bw+vPl+ NEyVBJiH/8cm6rKM3vy9mEQ+l/j/rt5ZHT3Zmwex8zGF6NJh5ijIEumtRXcM4z0xHxB0 0+PCT3OJpAqit/QF29RgUKMGHV1aG0SvjChJzOQpdVOUC2D7UeDWYEB/6FPHOJyvqFMQ f2Kaz+9kmf5gawy1ZuKiauLZ0rGEjno9FHeptW02rH1Vx+YArCNtI/CnXup+0obvP4wF Y0vA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Ty1aywMT; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-bluetooth+bounces-1380-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e18-20020ac85dd2000000b0042a3387f252si12135759qtx.727.2024.01.25.11.08.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:08:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-1380-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=@collabora.com header.s=mail header.b=Ty1aywMT; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-bluetooth+bounces-1380-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com 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 EC12D1C21BC0 for ; Thu, 25 Jan 2024 19:08:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DA251350F2; Thu, 25 Jan 2024 19:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="Ty1aywMT" X-Original-To: linux-bluetooth@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 25B8A130E25 for ; Thu, 25 Jan 2024 19:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706209698; cv=none; b=RJhKV2Hc9VfuD91lEzdbGo9IybIsJlEIy35QiJ+4Oa/ZECR4DGAv21yp0gFz/Ehv5UNatGCqMXNntYSGouJ9ZQvn+8KUjUjTia0C5k06kRJW0ivlkODBZCyT4UbzHNBG8COjzuw9J1nOvzansgx/HqNrSunaIvO7M86Ti7RFoyY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706209698; c=relaxed/simple; bh=WdBUdqcKOux8RTVoIpwaJ5u983v55MMB+x+pK+1qM9Q=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ZAl5WDRIXr67OCDMK9AQvB1qF/EiJLv9C6x4vdhUrTnUC/sfNRNRgmZEktT+bCqGowDe6iZKosvbupPkyyUWKSkW27m7jocs99EvLpbez4DfIcdj6OyzcihSpe/FlMz39QowSzlaf3TCWB4SGBYKBZX224zfMZ7P1hHdbgOHuv8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=Ty1aywMT; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706209694; bh=WdBUdqcKOux8RTVoIpwaJ5u983v55MMB+x+pK+1qM9Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ty1aywMThFWY7HxOozT3KwxYr/ohfW679OoejYdvFNdCS7gxIwjUsqAzbOiL8u9OA koPTOofyx+kZfOCo4W5qZXLO0CiwUPJ6gw8f1a8NTENEqK0kNbSk/MG1rEJcMjn5nF L92WvXkxM3KFcuXO38Q24M0pPVVaZ3P2itOljbdbSvkygdyD3WFt1R1WXGYcWXmeNR n4v/i9wKjohOclFZhf0pHRPuh5dKHWux43NjB6FAKjlxXrGpD7FIezRdh/Q7RrnXDQ GwSiaiJ9Nrgh5Ux3NfvDCopKMxaBMTnYwuLd45Uu/6m057p82zradFj/x3810Fi9g9 +mkIgzbsP4sAA== Received: from fdanis-XPS-13-9370.. (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fdanis) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 4FCCB3781F89 for ; Thu, 25 Jan 2024 19:08:14 +0000 (UTC) From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 1/5] shared/gatt: Prevent security level change for PTS GATT tests Date: Thu, 25 Jan 2024 20:08:01 +0100 Message-Id: <20240125190805.1244787-2-frederic.danis@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240125190805.1244787-1-frederic.danis@collabora.com> References: <20240125190805.1244787-1-frederic.danis@collabora.com> 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="utf-8" Content-Transfer-Encoding: 8bit Some PTS GATT tests like GATT/CL/GAR/BI-04-C request to be able to get the security error and do not try to change the security level. This commit adds the ability to prevent to change the security level for an operation. --- src/shared/att.c | 26 ++++++++++++++++++++++++++ src/shared/att.h | 1 + src/shared/gatt-client.c | 19 +++++++++++++++++++ src/shared/gatt-client.h | 3 +++ 4 files changed, 49 insertions(+) diff --git a/src/shared/att.c b/src/shared/att.c index 62c884b65..485ef071b 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -2042,3 +2042,29 @@ bool bt_att_has_crypto(struct bt_att *att) return att->crypto ? true : false; } + +bool bt_att_set_retry(struct bt_att *att, unsigned int id, bool retry) +{ + struct att_send_op *op; + + if (!id) + return false; + + op = queue_find(att->req_queue, match_op_id, UINT_TO_PTR(id)); + if (op) + goto done; + + op = queue_find(att->ind_queue, match_op_id, UINT_TO_PTR(id)); + if (op) + goto done; + + op = queue_find(att->write_queue, match_op_id, UINT_TO_PTR(id)); + +done: + if (!op) + return false; + + op->retry = !retry; + + return true; +} diff --git a/src/shared/att.h b/src/shared/att.h index 4aa3de87b..6fd78636e 100644 --- a/src/shared/att.h +++ b/src/shared/att.h @@ -110,3 +110,4 @@ bool bt_att_set_local_key(struct bt_att *att, uint8_t sign_key[16], bool bt_att_set_remote_key(struct bt_att *att, uint8_t sign_key[16], bt_att_counter_func_t func, void *user_data); bool bt_att_has_crypto(struct bt_att *att); +bool bt_att_set_retry(struct bt_att *att, unsigned int id, bool retry); diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index 5de679c9b..6340bcd85 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -3818,3 +3818,22 @@ bool bt_gatt_client_idle_unregister(struct bt_gatt_client *client, return false; } + +bool bt_gatt_client_set_retry(struct bt_gatt_client *client, + unsigned int id, + bool retry) +{ + struct request *req; + + if (!client || !id) + return false; + + req = queue_find(client->pending_requests, match_req_id, + UINT_TO_PTR(id)); + if (!req) + return false; + + bt_att_set_retry(client->att, req->att_id, retry); + + return true; +} diff --git a/src/shared/gatt-client.h b/src/shared/gatt-client.h index bccd04a62..63cf99500 100644 --- a/src/shared/gatt-client.h +++ b/src/shared/gatt-client.h @@ -134,3 +134,6 @@ unsigned int bt_gatt_client_idle_register(struct bt_gatt_client *client, bt_gatt_client_destroy_func_t destroy); bool bt_gatt_client_idle_unregister(struct bt_gatt_client *client, unsigned int id); +bool bt_gatt_client_set_retry(struct bt_gatt_client *client, + unsigned int id, + bool retry); -- 2.34.1