diff mbox series

[BlueZ,v4,1/3] audio/avrcp: Guard SetAbsoluteVolume without target behind config value

Message ID 20241005214321.84250-2-marijn.suijten@somainline.org (mailing list archive)
State New
Headers show
Series audio/avrcp: Determine Absolute Volume support from feature category 2 | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch warning WARNING:UNKNOWN_COMMIT_ID: Unknown commit id '179ccb936', maybe rebased or not pulled? #60: Commit 179ccb936 ("avrcp: Set volume if volume changed event is WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #75: [1]: https://lore.kernel.org/linux-bluetooth/20211025210206.bkt5wovzmkmt6teg@SoMainline.org/ WARNING:LONG_LINE_COMMENT: line length of 88 exceeds 80 columns #103: FILE: profiles/audio/avrcp.c:4675: + /* If there is no target profile (we didn't create a controller for it), WARNING:LONG_LINE_COMMENT: line length of 85 exceeds 80 columns #104: FILE: profiles/audio/avrcp.c:4676: + * allow the call to pass through if the remote controller registered WARNING:LONG_LINE: line length of 82 exceeds 80 columns #111: FILE: profiles/audio/avrcp.c:4683: + if (!session->controller || session->controller->version < 0x0104) WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const #148: FILE: src/main.c:168: +static const char *avrcp_options[] = { /github/workspace/src/src/13823595.patch total: 0 errors, 6 warnings, 103 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13823595.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/GitLint fail WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 1: T1 Title exceeds max length (86>80): "[BlueZ,v4,1/3] audio/avrcp: Guard SetAbsoluteVolume without target behind config value" 18: B1 Line exceeds max length (92>80): "[1]: https://lore.kernel.org/linux-bluetooth/20211025210206.bkt5wovzmkmt6teg@SoMainline.org/"
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild warning ScanBuild: profiles/audio/avrcp.c:1954:2: warning: Value stored to 'operands' is never read operands += sizeof(*pdu); ^ ~~~~~~~~~~~~ 1 warning generated.

Commit Message

Marijn Suijten Oct. 5, 2024, 9:43 p.m. UTC
Commit 179ccb936 ("avrcp: Set volume if volume changed event is
registered") invented a workaround that allows SetAbsoluteVolume to be
sent to a remote device that does _not_ implement the AVRCP TG profile,
as long as it previously registered for the EVENT_VOLUME_CHANGED
notification.  This is strange as the TG role is required to be able to
send commands to the peer, but the commit must have been applied to the
tree for a reason.

We discussed in [1] that workarounds for dubious peers and software
stacks should be guarded behind a config entry in main.conf, so this
starts out by introducing a new [AVRCP] category that will later be
extended with other workarounds.  It guards the changed functionality
behind a `VolumeWithoutTarget = false` boolean to disallow this obscure
check.

[1]: https://lore.kernel.org/linux-bluetooth/20211025210206.bkt5wovzmkmt6teg@SoMainline.org/
---
 profiles/audio/avrcp.c | 16 +++++++++++++---
 src/btd.h              |  5 +++++
 src/main.c             | 16 ++++++++++++++++
 src/main.conf          |  6 ++++++
 4 files changed, 40 insertions(+), 3 deletions(-)

Comments

bluez.test.bot@gmail.com Oct. 6, 2024, 12:22 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=895898

---Test result---

Test Summary:
CheckPatch                    FAIL      1.71 seconds
GitLint                       FAIL      1.26 seconds
BuildEll                      PASS      24.02 seconds
BluezMake                     PASS      1510.99 seconds
MakeCheck                     PASS      13.50 seconds
MakeDistcheck                 PASS      175.94 seconds
CheckValgrind                 PASS      248.37 seconds
CheckSmatch                   PASS      348.81 seconds
bluezmakeextell               PASS      117.34 seconds
IncrementalBuild              PASS      4140.99 seconds
ScanBuild                     WARNING   1013.06 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v4,1/3] audio/avrcp: Guard SetAbsoluteVolume without target behind config value
WARNING:UNKNOWN_COMMIT_ID: Unknown commit id '179ccb936', maybe rebased or not pulled?
#60: 
Commit 179ccb936 ("avrcp: Set volume if volume changed event is

WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#75: 
[1]: https://lore.kernel.org/linux-bluetooth/20211025210206.bkt5wovzmkmt6teg@SoMainline.org/

WARNING:LONG_LINE_COMMENT: line length of 88 exceeds 80 columns
#103: FILE: profiles/audio/avrcp.c:4675:
+		/* If there is no target profile (we didn't create a controller for it),

WARNING:LONG_LINE_COMMENT: line length of 85 exceeds 80 columns
#104: FILE: profiles/audio/avrcp.c:4676:
+		 * allow the call to pass through if the remote controller registered

WARNING:LONG_LINE: line length of 82 exceeds 80 columns
#111: FILE: profiles/audio/avrcp.c:4683:
+		if (!session->controller || session->controller->version < 0x0104)

WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
#148: FILE: src/main.c:168:
+static const char *avrcp_options[] = {

/github/workspace/src/src/13823595.patch total: 0 errors, 6 warnings, 103 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13823595.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


[BlueZ,v4,2/3] audio/avrcp: Only allow absolute volume call/event on category-2 peers
WARNING:LONG_LINE_COMMENT: line length of 85 exceeds 80 columns
#83: FILE: profiles/audio/avrcp.c:1779:
+	 * The controller on the remote end is only allowed to call SetAbsoluteVolume

WARNING:LONG_LINE: line length of 118 exceeds 80 columns
#87: FILE: profiles/audio/avrcp.c:1783:
+			(btd_opts.avrcp.volume_category && !(session->target->features & AVRCP_FEATURE_CATEGORY_2))) {

WARNING:LONG_LINE_STRING: line length of 84 exceeds 80 columns
#88: FILE: profiles/audio/avrcp.c:1784:
+		error("Remote SetAbsoluteVolume rejected from non-category-2 peer");

WARNING:LONG_LINE_COMMENT: line length of 88 exceeds 80 columns
#100: FILE: profiles/audio/avrcp.c:3781:
+	 * The target on the remote end is only allowed to reply to EVENT_VOLUME_CHANGED

WARNING:LONG_LINE_COMMENT: line length of 82 exceeds 80 columns
#101: FILE: profiles/audio/avrcp.c:3782:
+	 * on our controller if it's at least version 1.4 and a category-2 device.

WARNING:LONG_LINE: line length of 122 exceeds 80 columns
#104: FILE: profiles/audio/avrcp.c:3785:
+			(btd_opts.avrcp.volume_category && !(session->controller->features & AVRCP_FEATURE_CATEGORY_2))) {

WARNING:LONG_LINE_STRING: line length of 87 exceeds 80 columns
#105: FILE: profiles/audio/avrcp.c:3786:
+		error("Remote EVENT_VOLUME_CHANGED rejected from non-category-2 peer");

WARNING:LONG_LINE: line length of 91 exceeds 80 columns
#125: FILE: profiles/audio/avrcp.c:4268:
+	if (!btd_opts.avrcp.volume_category || target->features & AVRCP_FEATURE_CATEGORY_2)

WARNING:LONG_LINE: line length of 126 exceeds 80 columns
#143: FILE: profiles/audio/avrcp.c:4692:
+				(btd_opts.avrcp.volume_category && !(session->target->features & AVRCP_FEATURE_CATEGORY_2))) {

WARNING:LONG_LINE_STRING: line length of 88 exceeds 80 columns
#144: FILE: profiles/audio/avrcp.c:4693:
+			error("Can't send EVENT_VOLUME_CHANGED to non-category-2 peer");

WARNING:LONG_LINE: line length of 84 exceeds 80 columns
#155: FILE: profiles/audio/avrcp.c:4709:
+		if (!session->controller || session->controller->version < 0x0104 ||

WARNING:LONG_LINE: line length of 130 exceeds 80 columns
#156: FILE: profiles/audio/avrcp.c:4710:
+				(btd_opts.avrcp.volume_category && !(session->controller->features & AVRCP_FEATURE_CATEGORY_2))) {

WARNING:LONG_LINE_STRING: line length of 85 exceeds 80 columns
#157: FILE: profiles/audio/avrcp.c:4711:
+			error("Can't send SetAbsoluteVolume to non-category-2 peer");

/github/workspace/src/src/13823593.patch total: 0 errors, 13 warnings, 120 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13823593.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


[BlueZ,v4,3/3] audio/avrcp: Determine Absolute Volume support from feature category 2
WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#85: 
[1]: https://android.googlesource.com/platform/system/bt/+/android-11.0.0_r28/bta/av/bta_av_main.cc#761

WARNING:PREFER_LORE_ARCHIVE: Use lore.kernel.org archive links when possible - see https://lore.kernel.org/lists.html
#86: 
[2]: https://marc.info/?l=linux-bluetooth&m=163463497503113&w=2

WARNING:LONG_LINE: line length of 95 exceeds 80 columns
#105: FILE: profiles/audio/avrcp.c:1783:
+			(btd_opts.avrcp.volume_version && session->target->version < 0x0104) ||

WARNING:LONG_LINE_STRING: line length of 101 exceeds 80 columns
#108: FILE: profiles/audio/avrcp.c:1785:
+		error("Remote SetAbsoluteVolume rejected from non-category-2 or non-AVRCP-1.4 peer");

WARNING:LONG_LINE: line length of 105 exceeds 80 columns
#122: FILE: profiles/audio/avrcp.c:4268:
+			(!btd_opts.avrcp.volume_category || target->features & AVRCP_FEATURE_CATEGORY_2))

WARNING:LONG_LINE: line length of 103 exceeds 80 columns
#138: FILE: profiles/audio/avrcp.c:4695:
+				(btd_opts.avrcp.volume_version && session->target->version < 0x0104) ||

WARNING:LONG_LINE_STRING: line length of 105 exceeds 80 columns
#141: FILE: profiles/audio/avrcp.c:4697:
+			error("Can't send EVENT_VOLUME_CHANGED to non-category-2 or non-AVRCP-1.4 peer");

/github/workspace/src/src/13823594.patch total: 0 errors, 7 warnings, 88 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13823594.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,v4,1/3] audio/avrcp: Guard SetAbsoluteVolume without target behind config value

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
1: T1 Title exceeds max length (86>80): "[BlueZ,v4,1/3] audio/avrcp: Guard SetAbsoluteVolume without target behind config value"
18: B1 Line exceeds max length (92>80): "[1]: https://lore.kernel.org/linux-bluetooth/20211025210206.bkt5wovzmkmt6teg@SoMainline.org/"
[BlueZ,v4,2/3] audio/avrcp: Only allow absolute volume call/event on category-2 peers

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
1: T1 Title exceeds max length (85>80): "[BlueZ,v4,2/3] audio/avrcp: Only allow absolute volume call/event on category-2 peers"
[BlueZ,v4,3/3] audio/avrcp: Determine Absolute Volume support from feature category 2

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
1: T1 Title exceeds max length (85>80): "[BlueZ,v4,3/3] audio/avrcp: Determine Absolute Volume support from feature category 2"
28: B1 Line exceeds max length (103>80): "[1]: https://android.googlesource.com/platform/system/bt/+/android-11.0.0_r28/bta/av/bta_av_main.cc#761"
30: B1 Line exceeds max length (103>80): "[3]: https://android.googlesource.com/platform/system/bt/+/android-11.0.0_r28/bta/av/bta_av_main.cc#755"
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
profiles/audio/avrcp.c:1954:2: warning: Value stored to 'operands' is never read
        operands += sizeof(*pdu);
        ^           ~~~~~~~~~~~~
1 warning generated.



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 1622734b3..553673b19 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -48,6 +48,7 @@ 
 #include "src/dbus-common.h"
 #include "src/shared/timeout.h"
 #include "src/shared/util.h"
+#include "src/btd.h"
 
 #include "avctp.h"
 #include "avrcp.h"
@@ -4670,9 +4671,18 @@  int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify)
 								&volume);
 	}
 
-	if (!session->controller && !avrcp_event_registered(session,
-					AVRCP_EVENT_VOLUME_CHANGED))
-		return -ENOTSUP;
+	if (btd_opts.avrcp.volume_without_target) {
+		/* If there is no target profile (we didn't create a controller for it),
+		 * allow the call to pass through if the remote controller registered
+		 * for a volume changed event.
+		 */
+		if (!session->controller && !avrcp_event_registered(session,
+						AVRCP_EVENT_VOLUME_CHANGED))
+			return -ENOTSUP;
+	} else {
+		if (!session->controller || session->controller->version < 0x0104)
+			return -ENOTSUP;
+	}
 
 	memset(buf, 0, sizeof(buf));
 
diff --git a/src/btd.h b/src/btd.h
index 383bd7c19..147b61f12 100644
--- a/src/btd.h
+++ b/src/btd.h
@@ -104,6 +104,10 @@  struct btd_avdtp_opts {
 	uint8_t  stream_mode;
 };
 
+struct btd_avrcp_opts {
+	bool		volume_without_target;
+};
+
 struct btd_advmon_opts {
 	uint8_t		rssi_sampling_period;
 };
@@ -145,6 +149,7 @@  struct btd_opts {
 	enum mps_mode_t	mps;
 
 	struct btd_avdtp_opts avdtp;
+	struct btd_avrcp_opts avrcp;
 
 	uint8_t		key_size;
 
diff --git a/src/main.c b/src/main.c
index 69ae1b1e3..5bd3a035d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -165,6 +165,11 @@  static const char *avdtp_options[] = {
 	NULL
 };
 
+static const char *avrcp_options[] = {
+	"VolumeWithoutTarget",
+	NULL
+};
+
 static const char *advmon_options[] = {
 	"RSSISamplingPeriod",
 	NULL
@@ -181,6 +186,7 @@  static const struct group_table {
 	{ "GATT",	gatt_options },
 	{ "CSIS",	csip_options },
 	{ "AVDTP",	avdtp_options },
+	{ "AVRCP",	avrcp_options },
 	{ "AdvMon",	advmon_options },
 	{ }
 };
@@ -1140,6 +1146,13 @@  static void parse_avdtp(GKeyFile *config)
 	parse_avdtp_stream_mode(config);
 }
 
+static void parse_avrcp(GKeyFile *config)
+{
+	parse_config_bool(config, "AVRCP",
+		"VolumeWithoutTarget",
+		&btd_opts.avrcp.volume_without_target);
+}
+
 static void parse_advmon(GKeyFile *config)
 {
 	parse_config_u8(config, "AdvMon", "RSSISamplingPeriod",
@@ -1163,6 +1176,7 @@  static void parse_config(GKeyFile *config)
 	parse_gatt(config);
 	parse_csis(config);
 	parse_avdtp(config);
+	parse_avrcp(config);
 	parse_advmon(config);
 }
 
@@ -1205,6 +1219,8 @@  static void init_defaults(void)
 	btd_opts.avdtp.session_mode = BT_IO_MODE_BASIC;
 	btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC;
 
+	btd_opts.avrcp.volume_without_target = false;
+
 	btd_opts.advmon.rssi_sampling_period = 0xFF;
 	btd_opts.csis.encrypt = true;
 }
diff --git a/src/main.conf b/src/main.conf
index 82040b3fa..5d206b9ec 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -305,6 +305,12 @@ 
 # streaming: Use L2CAP Streaming Mode
 #StreamMode = basic
 
+[AVRCP]
+# Allow SetAbsoluteVolume calls to a peer device that does not advertise the
+# AVRCP remote control target profile.  If it does advertise this profile, the
+# version is ignored.
+#VolumeWithoutTarget = false
+
 [Policy]
 #
 # The ReconnectUUIDs defines the set of remote services that should try