summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/bluez5
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2019-03-25 23:21:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-03-26 14:02:09 +0000
commit496a4f924d23df6beb9382b4e3bcdcf5c12a9cdf (patch)
tree646072bc3082db3290fc0a027a26c72ad8d75f2f /meta/recipes-connectivity/bluez5
parenta9ec38c65e1f0cafd4431a3cb017d60d17abdfdd (diff)
downloadpoky-496a4f924d23df6beb9382b4e3bcdcf5c12a9cdf.tar.gz
bluez5: fix CVE-2018-10910
Fix this CVE (Bluetooth discoverability may be enabled with no agents to handle requests) by backporting a number of patches from upstream. (From OE-Core rev: 7bdf9581e807b978b92f29e11ab2a9e69e08410f) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-connectivity/bluez5')
-rw-r--r--meta/recipes-connectivity/bluez5/bluez5.inc1
-rw-r--r--meta/recipes-connectivity/bluez5/bluez5/CVE-2018-10910.patch705
2 files changed, 706 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/bluez5/bluez5.inc b/meta/recipes-connectivity/bluez5/bluez5.inc
index 6d62f52459..aaf2af975d 100644
--- a/meta/recipes-connectivity/bluez5/bluez5.inc
+++ b/meta/recipes-connectivity/bluez5/bluez5.inc
@@ -53,6 +53,7 @@ SRC_URI = "\
53 file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \ 53 file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \
54 file://0001-test-gatt-Fix-hung-issue.patch \ 54 file://0001-test-gatt-Fix-hung-issue.patch \
55 file://0001-Makefile.am-Fix-a-race-issue-for-tools.patch \ 55 file://0001-Makefile.am-Fix-a-race-issue-for-tools.patch \
56 file://CVE-2018-10910.patch \
56" 57"
57S = "${WORKDIR}/bluez-${PV}" 58S = "${WORKDIR}/bluez-${PV}"
58 59
diff --git a/meta/recipes-connectivity/bluez5/bluez5/CVE-2018-10910.patch b/meta/recipes-connectivity/bluez5/bluez5/CVE-2018-10910.patch
new file mode 100644
index 0000000000..b4b1846c45
--- /dev/null
+++ b/meta/recipes-connectivity/bluez5/bluez5/CVE-2018-10910.patch
@@ -0,0 +1,705 @@
1A bug in Bluez may allow for the Bluetooth Discoverable state being set to on
2when no Bluetooth agent is registered with the system. This situation could
3lead to the unauthorized pairing of certain Bluetooth devices without any
4form of authentication.
5
6CVE: CVE-2018-10910
7Upstream-Status: Backport
8Signed-off-by: Ross Burton <ross.burton@intel.com>
9
10Subject: [PATCH BlueZ 1/4] client: Add discoverable-timeout command
11From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com>
12Date: 2018-07-25 10:20:32
13Message-ID: 20180725102035.19439-1-luiz.dentz () gmail ! com
14[Download RAW message or body]
15
16From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
17
18This adds discoverable-timeout command which can be used to get/set
19DiscoverableTimeout property:
20
21[bluetooth]# discoverable-timeout 180
22Changing discoverable-timeout 180 succeeded
23---
24 client/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++
25 1 file changed, 43 insertions(+)
26
27diff --git a/client/main.c b/client/main.c
28index 87323d8f7..59820c6d9 100644
29--- a/client/main.c
30+++ b/client/main.c
31@@ -1061,6 +1061,47 @@ static void cmd_discoverable(int argc, char *argv[])
32 return bt_shell_noninteractive_quit(EXIT_FAILURE);
33 }
34
35+static void cmd_discoverable_timeout(int argc, char *argv[])
36+{
37+ uint32_t value;
38+ char *endptr = NULL;
39+ char *str;
40+
41+ if (argc < 2) {
42+ DBusMessageIter iter;
43+
44+ if (!g_dbus_proxy_get_property(default_ctrl->proxy,
45+ "DiscoverableTimeout", &iter)) {
46+ bt_shell_printf("Unable to get DiscoverableTimeout\n");
47+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
48+ }
49+
50+ dbus_message_iter_get_basic(&iter, &value);
51+
52+ bt_shell_printf("DiscoverableTimeout: %d seconds\n", value);
53+
54+ return;
55+ }
56+
57+ value = strtol(argv[1], &endptr, 0);
58+ if (!endptr || *endptr != '\0' || value > UINT32_MAX) {
59+ bt_shell_printf("Invalid argument\n");
60+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
61+ }
62+
63+ str = g_strdup_printf("discoverable-timeout %d", value);
64+
65+ if (g_dbus_proxy_set_property_basic(default_ctrl->proxy,
66+ "DiscoverableTimeout",
67+ DBUS_TYPE_UINT32, &value,
68+ generic_callback, str, g_free))
69+ return;
70+
71+ g_free(str);
72+
73+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
74+}
75+
76 static void cmd_agent(int argc, char *argv[])
77 {
78 dbus_bool_t enable;
79@@ -2549,6 +2590,8 @@ static const struct bt_shell_menu main_menu = {
80 { "discoverable", "<on/off>", cmd_discoverable,
81 "Set controller discoverable mode",
82 NULL },
83+ { "discoverable-timeout", "[value]", cmd_discoverable_timeout,
84+ "Set discoverable timeout", NULL },
85 { "agent", "<on/off/capability>", cmd_agent,
86 "Enable/disable agent with given capability",
87 capability_generator},
88--
892.17.1
90
91Subject: [PATCH BlueZ 2/4] client: Make show command print DiscoverableTimeout
92From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com>
93Date: 2018-07-25 10:20:33
94Message-ID: 20180725102035.19439-2-luiz.dentz () gmail ! com
95[Download RAW message or body]
96
97From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
98
99Controller XX:XX:XX:XX:XX:XX (public)
100 Name: Vudentz's T460s
101 Alias: Intel-1
102 Class: 0x004c010c
103 Powered: yes
104 Discoverable: no
105 DiscoverableTimeout: 0x00000000
106 Pairable: yes
107 UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb)
108 UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
109 UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
110 UUID: SIM Access (0000112d-0000-1000-8000-00805f9b34fb)
111 UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
112 UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
113 UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
114 UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
115 UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb)
116 UUID: Headset (00001108-0000-1000-8000-00805f9b34fb)
117 Modalias: usb:v1D6Bp0246d0532
118 Discovering: no
119---
120 client/main.c | 1 +
121 1 file changed, 1 insertion(+)
122
123diff --git a/client/main.c b/client/main.c
124index 59820c6d9..6f472d050 100644
125--- a/client/main.c
126+++ b/client/main.c
127@@ -877,6 +877,7 @@ static void cmd_show(int argc, char *argv[])
128 print_property(proxy, "Class");
129 print_property(proxy, "Powered");
130 print_property(proxy, "Discoverable");
131+ print_property(proxy, "DiscoverableTimeout");
132 print_property(proxy, "Pairable");
133 print_uuids(proxy);
134 print_property(proxy, "Modalias");
135--
1362.17.1
137Subject: [PATCH BlueZ 3/4] adapter: Track pending settings
138From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com>
139Date: 2018-07-25 10:20:34
140Message-ID: 20180725102035.19439-3-luiz.dentz () gmail ! com
141[Download RAW message or body]
142
143From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
144
145This tracks settings being changed and in case the settings is already
146pending considered it to be done.
147---
148 src/adapter.c | 30 ++++++++++++++++++++++++++++--
149 1 file changed, 28 insertions(+), 2 deletions(-)
150
151diff --git a/src/adapter.c b/src/adapter.c
152index af340fd6e..20c20f9e9 100644
153--- a/src/adapter.c
154+++ b/src/adapter.c
155@@ -196,6 +196,7 @@ struct btd_adapter {
156 char *name; /* controller device name */
157 char *short_name; /* controller short name */
158 uint32_t supported_settings; /* controller supported settings */
159+ uint32_t pending_settings; /* pending controller settings */
160 uint32_t current_settings; /* current controller settings */
161
162 char *path; /* adapter object path */
163@@ -509,8 +510,10 @@ static void settings_changed(struct btd_adapter *adapter, uint32_t settings)
164 changed_mask = adapter->current_settings ^ settings;
165
166 adapter->current_settings = settings;
167+ adapter->pending_settings &= ~changed_mask;
168
169 DBG("Changed settings: 0x%08x", changed_mask);
170+ DBG("Pending settings: 0x%08x", adapter->pending_settings);
171
172 if (changed_mask & MGMT_SETTING_POWERED) {
173 g_dbus_emit_property_changed(dbus_conn, adapter->path,
174@@ -596,10 +599,31 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
175 uint8_t mode)
176 {
177 struct mgmt_mode cp;
178+ uint32_t setting = 0;
179
180 memset(&cp, 0, sizeof(cp));
181 cp.val = mode;
182
183+ switch (mode) {
184+ case MGMT_OP_SET_POWERED:
185+ setting = MGMT_SETTING_POWERED;
186+ break;
187+ case MGMT_OP_SET_CONNECTABLE:
188+ setting = MGMT_SETTING_CONNECTABLE;
189+ break;
190+ case MGMT_OP_SET_FAST_CONNECTABLE:
191+ setting = MGMT_SETTING_FAST_CONNECTABLE;
192+ break;
193+ case MGMT_OP_SET_DISCOVERABLE:
194+ setting = MGMT_SETTING_DISCOVERABLE;
195+ break;
196+ case MGMT_OP_SET_BONDABLE:
197+ setting = MGMT_SETTING_DISCOVERABLE;
198+ break;
199+ }
200+
201+ adapter->pending_settings |= setting;
202+
203 DBG("sending set mode command for index %u", adapter->dev_id);
204
205 if (mgmt_send(adapter->mgmt, opcode,
206@@ -2739,13 +2763,15 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
207 else
208 current_enable = FALSE;
209
210- if (enable == current_enable) {
211+ if (enable == current_enable || adapter->pending_settings & setting) {
212 g_dbus_pending_property_success(id);
213 return;
214 }
215
216 mode = (enable == TRUE) ? 0x01 : 0x00;
217
218+ adapter->pending_settings |= setting;
219+
220 switch (setting) {
221 case MGMT_SETTING_POWERED:
222 opcode = MGMT_OP_SET_POWERED;
223@@ -2798,7 +2824,7 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
224 data->id = id;
225
226 if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param,
227- property_set_mode_complete, data, g_free) > 0)
228+ property_set_mode_complete, data, g_free) > 0)
229 return;
230
231 g_free(data);
232--
2332.17.1
234Subject: [PATCH BlueZ 4/4] adapter: Check pending when setting DiscoverableTimeout
235From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com>
236Date: 2018-07-25 10:20:35
237Message-ID: 20180725102035.19439-4-luiz.dentz () gmail ! com
238[Download RAW message or body]
239
240From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
241
242This makes DiscoverableTimeout check if discoverable is already pending
243and don't attempt to set it once again which may cause discoverable to
244be re-enabled when in fact the application just want to set the timeout
245alone.
246---
247 src/adapter.c | 14 +++++++++++++-
248 1 file changed, 13 insertions(+), 1 deletion(-)
249
250diff --git a/src/adapter.c b/src/adapter.c
251index 20c20f9e9..f92c897c7 100644
252--- a/src/adapter.c
253+++ b/src/adapter.c
254@@ -2901,6 +2901,7 @@ static void property_set_discoverable_timeout(
255 GDBusPendingPropertySet id, void *user_data)
256 {
257 struct btd_adapter *adapter = user_data;
258+ bool enabled;
259 dbus_uint32_t value;
260
261 dbus_message_iter_get_basic(iter, &value);
262@@ -2914,8 +2915,19 @@ static void property_set_discoverable_timeout(
263 g_dbus_emit_property_changed(dbus_conn, adapter->path,
264 ADAPTER_INTERFACE, "DiscoverableTimeout");
265
266+ if (adapter->pending_settings & MGMT_SETTING_DISCOVERABLE) {
267+ if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE)
268+ enabled = false;
269+ else
270+ enabled = true;
271+ } else {
272+ if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE)
273+ enabled = true;
274+ else
275+ enabled = false;
276+ }
277
278- if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE)
279+ if (enabled)
280 set_discoverable(adapter, 0x01, adapter->discoverable_timeout);
281 }
282
283--
2842.17.1
285Subject: [PATCH BlueZ 1/5] doc/adapter-api: Add Discoverable option to SetDiscoveryFilter
286From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com>
287Date: 2018-07-26 14:17:19
288Message-ID: 20180726141723.20199-1-luiz.dentz () gmail ! com
289[Download RAW message or body]
290
291From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
292
293This enables the client to set its discoverable setting while
294discovering which is very typical situation as usually the setings
295application would allow incoming pairing request while scanning, so
296this would reduce the number of calls setting Discoverable and
297DiscoverableTimeout and restoring after done with discovery.
298---
299 doc/adapter-api.txt | 6 ++++++
300 1 file changed, 6 insertions(+)
301
302diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
303index d14d0ca50..4791af2c7 100644
304--- a/doc/adapter-api.txt
305+++ b/doc/adapter-api.txt
306@@ -113,6 +113,12 @@ Methods void StartDiscovery()
307 generated for either ManufacturerData and
308 ServiceData everytime they are discovered.
309
310+ bool Discoverable (Default: false)
311+
312+ Make adapter discoverable while discovering,
313+ if the adapter is already discoverable this
314+ setting this filter won't do anything.
315+
316 When discovery filter is set, Device objects will be
317 created as new devices with matching criteria are
318 discovered regardless of they are connectable or
319--
3202.17.1
321Subject: [PATCH BlueZ 2/5] adapter: Discovery filter discoverable
322From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com>
323Date: 2018-07-26 14:17:20
324Message-ID: 20180726141723.20199-2-luiz.dentz () gmail ! com
325[Download RAW message or body]
326
327From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
328
329This implements the discovery filter discoverable and tracks which
330clients had enabled it and restores the settings when the last client
331enabling it exits.
332---
333 src/adapter.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++--
334 1 file changed, 54 insertions(+), 2 deletions(-)
335
336diff --git a/src/adapter.c b/src/adapter.c
337index f92c897c7..bd9edddc6 100644
338--- a/src/adapter.c
339+++ b/src/adapter.c
340@@ -157,6 +157,7 @@ struct discovery_filter {
341 int16_t rssi;
342 GSList *uuids;
343 bool duplicate;
344+ bool discoverable;
345 };
346
347 struct watch_client {
348@@ -214,6 +215,7 @@ struct btd_adapter {
349
350 bool discovering; /* discovering property state */
351 bool filtered_discovery; /* we are doing filtered discovery */
352+ bool filtered_discoverable; /* we are doing filtered discovery */
353 bool no_scan_restart_delay; /* when this flag is set, restart scan
354 * without delay */
355 uint8_t discovery_type; /* current active discovery type */
356@@ -1842,6 +1844,16 @@ static void discovery_free(void *user_data)
357 g_free(client);
358 }
359
360+static bool set_filtered_discoverable(struct btd_adapter *adapter, bool enable)
361+{
362+ if (adapter->filtered_discoverable == enable)
363+ return true;
364+
365+ adapter->filtered_discoverable = enable;
366+
367+ return set_discoverable(adapter, enable, 0);
368+}
369+
370 static void discovery_remove(struct watch_client *client)
371 {
372 struct btd_adapter *adapter = client->adapter;
373@@ -1854,6 +1866,22 @@ static void discovery_remove(struct watch_client *client)
374 adapter->discovery_list = g_slist_remove(adapter->discovery_list,
375 client);
376
377+ if (adapter->filtered_discoverable &&
378+ client->discovery_filter->discoverable) {
379+ GSList *l;
380+
381+ for (l = adapter->discovery_list; l; l = g_slist_next(l)) {
382+ struct watch_client *client = l->data;
383+
384+ if (client->discovery_filter->discoverable)
385+ break;
386+ }
387+
388+ /* Disable filtered discoverable if there are no clients */
389+ if (!l)
390+ set_filtered_discoverable(adapter, false);
391+ }
392+
393 discovery_free(client);
394
395 /*
396@@ -2224,6 +2252,15 @@ static DBusMessage *start_discovery(DBusConnection *conn,
397 adapter->set_filter_list, client);
398 adapter->discovery_list = g_slist_prepend(
399 adapter->discovery_list, client);
400+
401+ /* Reset discoverable filter if already set */
402+ if (adapter->current_settings & MGMT_OP_SET_DISCOVERABLE)
403+ goto done;
404+
405+ /* Set discoverable if filter requires and it*/
406+ if (client->discovery_filter->discoverable)
407+ set_filtered_discoverable(adapter, true);
408+
409 goto done;
410 }
411
412@@ -2348,6 +2385,17 @@ static bool parse_duplicate_data(DBusMessageIter *value,
413 return true;
414 }
415
416+static bool parse_discoverable(DBusMessageIter *value,
417+ struct discovery_filter *filter)
418+{
419+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN)
420+ return false;
421+
422+ dbus_message_iter_get_basic(value, &filter->discoverable);
423+
424+ return true;
425+}
426+
427 struct filter_parser {
428 const char *name;
429 bool (*func)(DBusMessageIter *iter, struct discovery_filter *filter);
430@@ -2357,6 +2405,7 @@ struct filter_parser {
431 { "Pathloss", parse_pathloss },
432 { "Transport", parse_transport },
433 { "DuplicateData", parse_duplicate_data },
434+ { "Discoverable", parse_discoverable },
435 { }
436 };
437
438@@ -2396,6 +2445,7 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter,
439 (*filter)->rssi = DISTANCE_VAL_INVALID;
440 (*filter)->type = get_scan_type(adapter);
441 (*filter)->duplicate = false;
442+ (*filter)->discoverable = false;
443
444 dbus_message_iter_init(msg, &iter);
445 if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
446@@ -2441,8 +2491,10 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter,
447 goto invalid_args;
448
449 DBG("filtered discovery params: transport: %d rssi: %d pathloss: %d "
450- " duplicate data: %s ", (*filter)->type, (*filter)->rssi,
451- (*filter)->pathloss, (*filter)->duplicate ? "true" : "false");
452+ " duplicate data: %s discoverable %s", (*filter)->type,
453+ (*filter)->rssi, (*filter)->pathloss,
454+ (*filter)->duplicate ? "true" : "false",
455+ (*filter)->discoverable ? "true" : "false");
456
457 return true;
458
459--
4602.17.1
461Subject: [PATCH BlueZ 3/5] client: Add scan.discoverable command
462From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com>
463Date: 2018-07-26 14:17:21
464Message-ID: 20180726141723.20199-3-luiz.dentz () gmail ! com
465[Download RAW message or body]
466
467From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
468
469This adds discoverable command to scan menu which can be used to set
470if adapter should become discoverable while scanning:
471
472[bluetooth]# scan.discoverable on
473[bluetooth]# scan on
474SetDiscoveryFilter success
475[CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: yes
476Discovery started
477[CHG] Controller XX:XX:XX:XX:XX:XX Discovering: yes
478[bluetooth]# scan off
479Discovery stopped
480[CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: no
481---
482 client/main.c | 29 +++++++++++++++++++++++++++++
483 1 file changed, 29 insertions(+)
484
485diff --git a/client/main.c b/client/main.c
486index 6f472d050..6e6f6d2fb 100644
487--- a/client/main.c
488+++ b/client/main.c
489@@ -1166,6 +1166,7 @@ static struct set_discovery_filter_args {
490 char **uuids;
491 size_t uuids_len;
492 dbus_bool_t duplicate;
493+ dbus_bool_t discoverable;
494 bool set;
495 } filter = {
496 .rssi = DISTANCE_VAL_INVALID,
497@@ -1205,6 +1206,11 @@ static void set_discovery_filter_setup(DBusMessageIter *iter, void *user_data)
498 DBUS_TYPE_BOOLEAN,
499 &args->duplicate);
500
501+ if (args->discoverable)
502+ g_dbus_dict_append_entry(&dict, "Discoverable",
503+ DBUS_TYPE_BOOLEAN,
504+ &args->discoverable);
505+
506 dbus_message_iter_close_container(iter, &dict);
507 }
508
509@@ -1362,6 +1368,26 @@ static void cmd_scan_filter_duplicate_data(int argc, char *argv[])
510 filter.set = false;
511 }
512
513+static void cmd_scan_filter_discoverable(int argc, char *argv[])
514+{
515+ if (argc < 2 || !strlen(argv[1])) {
516+ bt_shell_printf("Discoverable: %s\n",
517+ filter.discoverable ? "on" : "off");
518+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
519+ }
520+
521+ if (!strcmp(argv[1], "on"))
522+ filter.discoverable = true;
523+ else if (!strcmp(argv[1], "off"))
524+ filter.discoverable = false;
525+ else {
526+ bt_shell_printf("Invalid option: %s\n", argv[1]);
527+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
528+ }
529+
530+ filter.set = false;
531+}
532+
533 static void filter_clear_uuids(void)
534 {
535 g_strfreev(filter.uuids);
536@@ -2510,6 +2536,9 @@ static const struct bt_shell_menu scan_menu = {
537 { "duplicate-data", "[on/off]", cmd_scan_filter_duplicate_data,
538 "Set/Get duplicate data filter",
539 NULL },
540+ { "discoverable", "[on/off]", cmd_scan_filter_discoverable,
541+ "Set/Get discoverable filter",
542+ NULL },
543 { "clear", "[uuids/rssi/pathloss/transport/duplicate-data]",
544 cmd_scan_filter_clear,
545 "Clears discovery filter.",
546--
5472.17.1
548Subject: [PATCH BlueZ 4/5] client: Add scan.clear discoverable
549From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com>
550Date: 2018-07-26 14:17:22
551Message-ID: 20180726141723.20199-4-luiz.dentz () gmail ! com
552[Download RAW message or body]
553
554From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
555
556This implements scan.clear for discoverable filter.
557---
558 client/main.c | 9 ++++++++-
559 1 file changed, 8 insertions(+), 1 deletion(-)
560
561diff --git a/client/main.c b/client/main.c
562index 6e6f6d2fb..1a66a3ab4 100644
563--- a/client/main.c
564+++ b/client/main.c
565@@ -1416,6 +1416,11 @@ static void filter_clear_duplicate(void)
566 filter.duplicate = false;
567 }
568
569+static void filter_clear_discoverable(void)
570+{
571+ filter.discoverable = false;
572+}
573+
574 struct clear_entry {
575 const char *name;
576 void (*clear) (void);
577@@ -1427,6 +1432,7 @@ static const struct clear_entry filter_clear[] = {
578 { "pathloss", filter_clear_pathloss },
579 { "transport", filter_clear_transport },
580 { "duplicate-data", filter_clear_duplicate },
581+ { "discoverable", filter_clear_discoverable },
582 {}
583 };
584
585@@ -2539,7 +2545,8 @@ static const struct bt_shell_menu scan_menu = {
586 { "discoverable", "[on/off]", cmd_scan_filter_discoverable,
587 "Set/Get discoverable filter",
588 NULL },
589- { "clear", "[uuids/rssi/pathloss/transport/duplicate-data]",
590+ { "clear",
591+ "[uuids/rssi/pathloss/transport/duplicate-data/discoverable]",
592 cmd_scan_filter_clear,
593 "Clears discovery filter.",
594 filter_clear_generator },
595--
5962.17.1
597Subject: [PATCH BlueZ 5/5] adapter: Fix not keeping discovery filters
598From: Luiz Augusto von Dentz <luiz.dentz () gmail ! com>
599Date: 2018-07-26 14:17:23
600Message-ID: 20180726141723.20199-5-luiz.dentz () gmail ! com
601[Download RAW message or body]
602
603From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
604
605If the discovery has been stopped and the client has set filters those
606should be put back into filter list since the client may still be
607interested in using them the next time it start a scanning.
608---
609 src/adapter.c | 25 ++++++++++++++++---------
610 1 file changed, 16 insertions(+), 9 deletions(-)
611
612diff --git a/src/adapter.c b/src/adapter.c
613index bd9edddc6..822bd3472 100644
614--- a/src/adapter.c
615+++ b/src/adapter.c
616@@ -1854,7 +1854,7 @@ static bool set_filtered_discoverable(struct btd_adapter *adapter, bool enable)
617 return set_discoverable(adapter, enable, 0);
618 }
619
620-static void discovery_remove(struct watch_client *client)
621+static void discovery_remove(struct watch_client *client, bool exit)
622 {
623 struct btd_adapter *adapter = client->adapter;
624
625@@ -1882,7 +1882,11 @@ static void discovery_remove(struct watch_client *client)
626 set_filtered_discoverable(adapter, false);
627 }
628
629- discovery_free(client);
630+ if (!exit && client->discovery_filter)
631+ adapter->set_filter_list = g_slist_prepend(
632+ adapter->set_filter_list, client);
633+ else
634+ discovery_free(client);
635
636 /*
637 * If there are other client discoveries in progress, then leave
638@@ -1911,8 +1915,11 @@ static void stop_discovery_complete(uint8_t status, uint16_t length,
639 goto done;
640 }
641
642- if (client->msg)
643+ if (client->msg) {
644 g_dbus_send_reply(dbus_conn, client->msg, DBUS_TYPE_INVALID);
645+ dbus_message_unref(client->msg);
646+ client->msg = NULL;
647+ }
648
649 adapter->discovery_type = 0x00;
650 adapter->discovery_enable = 0x00;
651@@ -1925,7 +1932,7 @@ static void stop_discovery_complete(uint8_t status, uint16_t length,
652 trigger_passive_scanning(adapter);
653
654 done:
655- discovery_remove(client);
656+ discovery_remove(client, false);
657 }
658
659 static int compare_sender(gconstpointer a, gconstpointer b)
660@@ -2146,14 +2153,14 @@ static int update_discovery_filter(struct btd_adapter *adapter)
661 return -EINPROGRESS;
662 }
663
664-static int discovery_stop(struct watch_client *client)
665+static int discovery_stop(struct watch_client *client, bool exit)
666 {
667 struct btd_adapter *adapter = client->adapter;
668 struct mgmt_cp_stop_discovery cp;
669
670 /* Check if there are more client discovering */
671 if (g_slist_next(adapter->discovery_list)) {
672- discovery_remove(client);
673+ discovery_remove(client, exit);
674 update_discovery_filter(adapter);
675 return 0;
676 }
677@@ -2163,7 +2170,7 @@ static int discovery_stop(struct watch_client *client)
678 * and so it is enough to send out the signal and just return.
679 */
680 if (adapter->discovery_enable == 0x00) {
681- discovery_remove(client);
682+ discovery_remove(client, exit);
683 adapter->discovering = false;
684 g_dbus_emit_property_changed(dbus_conn, adapter->path,
685 ADAPTER_INTERFACE, "Discovering");
686@@ -2188,7 +2195,7 @@ static void discovery_disconnect(DBusConnection *conn, void *user_data)
687
688 DBG("owner %s", client->owner);
689
690- discovery_stop(client);
691+ discovery_stop(client, true);
692 }
693
694 /*
695@@ -2586,7 +2593,7 @@ static DBusMessage *stop_discovery(DBusConnection *conn,
696 if (client->msg)
697 return btd_error_busy(msg);
698
699- err = discovery_stop(client);
700+ err = discovery_stop(client, false);
701 switch (err) {
702 case 0:
703 return dbus_message_new_method_return(msg);
704--
7052.17.1