Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:Update
bluez.25542
HID-accepts-bonded-device-connections-only.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File HID-accepts-bonded-device-connections-only.patch of Package bluez.25542
From 3cccdbab2324086588df4ccf5f892fb3ce1f1787 Mon Sep 17 00:00:00 2001 From: Alain Michaud <alainm@chromium.org> Date: Tue Mar 10 02:35:16 2020 +0000 Subject: [PATCH 2/2] HID accepts bonded device connections only. This change adds a configuration for platforms to choose a more secure posture for the HID profile. While some older mice are known to not support pairing or encryption, some platform may choose a more secure posture by requiring the device to be bonded and require the connection to be encrypted when bonding is required. Reference: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00352.html --- profiles/input/device.c | 24 +++++++++++++++++++++++- profiles/input/device.h | 1 + profiles/input/input.conf | 8 ++++++++ profiles/input/manager.c | 11 +++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) Index: bluez-5.13/profiles/input/device.c =================================================================== --- bluez-5.13.orig/profiles/input/device.c +++ bluez-5.13/profiles/input/device.c @@ -86,12 +86,18 @@ struct input_device { }; static int idle_timeout = 0; +static bool classic_bonded_only = false; void input_set_idle_timeout(int timeout) { idle_timeout = timeout; } +void input_set_classic_bonded_only(bool state) +{ + classic_bonded_only = state; +} + static void input_device_enter_reconnect_mode(struct input_device *idev); static void input_device_free(struct input_device *idev) @@ -424,8 +430,19 @@ static int hidp_add_connection(struct in if (idev->name) strncpy(req->name, idev->name, sizeof(req->name) - 1); + /* Make sure the device is bonded if required */ + if (classic_bonded_only && (!device_is_bonded(idev->device) || + !btd_device_is_connected(idev->device))) { + error("Rejected connection from !bonded device %s", dst_addr); + + goto cleanup; + } + /* Encryption is mandatory for keyboards */ - if (req->subclass & 0x40) { + /* Some platforms may choose to require encryption for all devices */ + /* Note that this only matters for pre 2.1 devices as otherwise the */ + /* device is encrypted by default by the lower layers */ + if (classic_bonded_only || req->subclass & 0x40) { if (!bt_io_set(idev->intr_io, &gerr, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM, BT_IO_OPT_INVALID)) { @@ -704,6 +721,11 @@ static void input_device_enter_reconnect DBG("path=%s reconnect_mode=%s", idev->path, reconnect_mode_to_string(idev->reconnect_mode)); + /* Make sure the device is bonded if required */ + if (classic_bonded_only && (!device_is_bonded(idev->device) || + !btd_device_is_connected(idev->device))) + return; + /* Only attempt an auto-reconnect when the device is required to accept * reconnections from the host. */ if (idev->reconnect_mode != RECONNECT_ANY && Index: bluez-5.13/profiles/input/device.h =================================================================== --- bluez-5.13.orig/profiles/input/device.h +++ bluez-5.13/profiles/input/device.h @@ -28,6 +28,7 @@ struct input_device; struct input_conn; void input_set_idle_timeout(int timeout); +void input_set_classic_bonded_only(bool state); int input_device_register(struct btd_service *service); void input_device_unregister(struct btd_service *service); Index: bluez-5.13/profiles/input/input.conf =================================================================== --- bluez-5.13.orig/profiles/input/input.conf +++ bluez-5.13/profiles/input/input.conf @@ -7,3 +7,11 @@ # Set idle timeout (in minutes) before the connection will # be disconnect (defaults to 0 for no timeout) #IdleTimeout=30 + +# Limit HID connections to bonded devices +# The HID Profile does not specify that devices must be bonded, however some +# platforms may want to make sure that input connections only come from bonded +# device connections. Several older mice have been known for not supporting +# pairing/encryption. +# Defaults to false to maximize device compatibility. +#ClassicBondedOnly=true Index: bluez-5.13/profiles/input/manager.c =================================================================== --- bluez-5.13.orig/profiles/input/manager.c +++ bluez-5.13/profiles/input/manager.c @@ -97,6 +97,7 @@ static int input_init(void) config = load_config_file(CONFIGDIR "/input.conf"); if (config) { int idle_timeout; + gboolean uhid_enabled, classic_bonded_only; idle_timeout = g_key_file_get_integer(config, "General", "IdleTimeout", &err); @@ -106,6 +107,16 @@ static int input_init(void) } input_set_idle_timeout(idle_timeout * 60); + + classic_bonded_only = g_key_file_get_boolean(config, "General", + "ClassicBondedOnly", &err); + if (!err) { + DBG("input.conf: ClassicBondedOnly=%s", + classic_bonded_only ? "true" : "false"); + input_set_classic_bonded_only(classic_bonded_only); + } else + g_clear_error(&err); + } btd_profile_register(&input_profile);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor