build: Add a few default configure options
PATCH 1/8 build: Add a few default configure options
Add 3 optional features that are currently used and distributed in the Fedora packages to the default build configuration.
The additional build time is minimal, and it ensures that the build gets maximum coverage.
--- bootstrap-configure | 3 +++ 1 file changed, 3 insertions(+)
bootstrap-configure +3 -0
@@ -26,4 +26,7 @@ fi --enable-mesh \ --enable-btpclient \ --enable-logger \ + --enable-pie \ + --enable-cups \ + --enable-library \ --disable-datafiles $*
Signature · 1 line
2.21.0
PATCH 2/8 build: Add warnings for non-literal strings
--- acinclude.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
acinclude.m4 +1 -1
@@ -21,7 +21,7 @@ AC_DEFUN([COMPILER_FLAGS], [ with_cflags="$with_cflags -Wredundant-decls" with_cflags="$with_cflags -Wcast-align" with_cflags="$with_cflags -Wswitch-enum" - with_cflags="$with_cflags -Wformat -Wformat-security" + with_cflags="$with_cflags -Wformat -Wformat-security -Wformat-nonliteral" with_cflags="$with_cflags -DG_DISABLE_DEPRECATED" with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28" with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32"
Signature · 1 line
2.21.0
PATCH 3/8 build: Enable BIND_NOW
In reply to Bastien NoceraFrom: Florian Weimer <[email protected]>
Partial RELRO means that the object is GNU_RELRO but not BIND_NOW. This reduces the effectiveness of RELRO. bluez triggers this because it enables PIE during the build, and rpmdiff takes this as an indicator that the best possible hardening is desired.
https://bugzilla.redhat.com/show_bug.cgi?id=983161
--- acinclude.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
acinclude.m4 +1 -1
@@ -50,7 +50,7 @@ AC_DEFUN([MISC_FLAGS], [ if (test "${enableval}" = "yes" && test "${ac_cv_prog_cc_pie}" = "yes"); then misc_cflags="$misc_cflags -fPIC" - misc_ldflags="$misc_ldflags -pie" + misc_ldflags="$misc_ldflags -pie -Wl,-z,now" fi ]) if (test "$enable_coverage" = "yes"); then
Signature · 1 line
2.21.0
PATCH 4/8 tools/csr_usb: Fix compilation failure
In reply to Bastien NoceraGCC's "format-nonliteral" security check is enabled as an error in recent versions of Fedora. Given the limited formats, pass a boolean to switch between the 2 different formats.
tools/csr_usb.c: In function 'read_value':tools/csr_usb.c:82:2: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
n = fscanf(file, format, &value);
^
--- tools/csr_usb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
tools/csr_usb.c +10 -6
@@ -32,6 +32,7 @@#include <fcntl.h> #include <unistd.h> #include <stdlib.h> +#include <stdbool.h> #include <string.h> #include <dirent.h> #include <limits.h>
@@ -68,7 +69,7 @@ struct usbfs_bulktransfer {#define USBFS_IOCTL_CLAIMINTF _IOR('U', 15, unsigned int)#define USBFS_IOCTL_RELEASEINTF _IOR('U', 16, unsigned int) -static int read_value (const char *name,const char *attr,const char *format) +static int read_value (const char *name,const char *attr,bool hex_number) {char path[PATH_MAX ];FILE *file;
@@ -80,7 +81,7 @@ static int read_value(const char *name, const char *attr, const char *format)if (!file)return -1 ; - n =fscanf (file, format, &value); + n =fscanf (file, hex_number ?"%d" :"%04x" , &value);if (n !=1 ) {fclose (file);return -1 ;
@@ -90,26 +91,29 @@ static int read_value(const char *name, const char *attr, const char *format)return value; } +#define read_hex_value (name, file) read_value((name), (file), true) +#define read_num_value (name, file) read_value((name), (file), false) +static char *check_device (const char *name) {char path[PATH_MAX ];int busnum, devnum, vendor, product; - busnum =read_value (name,"busnum" ,"%d" ); + busnum =read_num_value (name,"busnum" );if (busnum <0 )return NULL ; - devnum =read_value (name,"devnum" ,"%d" ); + devnum =read_num_value (name,"devnum" );if (devnum <0 )return NULL ;snprintf (path,sizeof (path),"/dev/bus/usb/%03u/%03u" , busnum, devnum); - vendor =read_value (name,"idVendor" ,"%04x" ); + vendor =read_hex_value (name,"idVendor" );if (vendor <0 )return NULL ; - product =read_value (name,"idProduct" ,"%04x" ); + product =read_hex_value (name,"idProduct" );if (product <0 )return NULL ;
Signature · 1 line
2.21.0
PATCH 5/8 obex: Work-around compilation failure
In reply to Bastien Noceraobexd/plugins/bluetooth.c: In function 'register_profile':obexd/plugins/bluetooth.c:310:7: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
profile->driver->port);
^~~~~~~
obexd/plugins/bluetooth.c:314:7: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
profile->driver->name);
^~~~~~~
---
obexd/plugins/bluetooth.c | 4 ++++
1 file changed, 4 insertions(+)obexd/plugins/bluetooth.c +4 -0
@@ -271,6 +271,9 @@ static int register_profile(struct bluetooth_profile *profile) &opt);g_dbus_dict_append_entry (&opt,"AutoConnect" ,DBUS_TYPE_BOOLEAN , &auto_connect); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral"if (profile->driver->record) {if (profile->driver->port !=0 ) xml = g_markup_printf_escaped(profile->driver->record,
@@ -281,6 +284,7 @@ static int register_profile(struct bluetooth_profile *profile) xml =g_markup_printf_escaped (profile->driver->record, profile->driver->channel, profile->driver->name); +#pragma GCC diagnostic popg_dbus_dict_append_entry (&opt,"ServiceRecord" ,DBUS_TYPE_STRING , &xml);g_free (xml);
Signature · 1 line
2.21.0
PATCH 6/8 android/avrcp-lib: Fix unaligned struct access
In reply to Bastien Noceraandroid/avrcp-lib.c: In function ‘get_element_attributes’:android/avrcp-lib.c:967:24: error: taking address of packed member of ‘struct get_element_attributes_req’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
967 | if (!parse_attributes(* (&req->attrs), params_len - sizeof(*req),
| ^~~~~~~~~~~~~~~ --- android/avrcp-lib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
android/avrcp-lib.c +5 -4
@@ -927,14 +927,15 @@ static ssize_t get_play_status(struct avrcp *session, uint8_t transaction, player->user_data); } -static bool parse_attributes (uint32_t *params,uint16_t params_len, -uint8_t number,uint32_t *attrs) +static bool parse_attributes (struct get_element_attributes_req *req, +uint16_t params_len,uint8_t number, +uint32_t *attrs) {int i;for (i =0 ; i < number && params_len >=sizeof (*attrs); i++, params_len -=sizeof (*attrs)) { - attrs[i] =be32_to_cpu (params[i]); + attrs[i] =be32_to_cpu (req->attrs[i]);if (attrs[i] ==AVRCP_MEDIA_ATTRIBUTE_ILLEGAL || attrs[i] >AVRCP_MEDIA_ATTRIBUTE_LAST )
@@ -964,7 +965,7 @@ static ssize_t get_element_attributes(struct avrcp *session,if (!params || params_len <sizeof (*req))return -EINVAL ; -if (!parse_attributes (req->attrs, params_len -sizeof (*req), +if (!parse_attributes (req, params_len -sizeof (*req), req->number, attrs))return -EINVAL ;
Signature · 1 line
2.21.0
PATCH 7/8 android/hal-bluetooth: Fix unaligned struct access
In reply to Bastien Noceraandroid/hal-bluetooth.c: In function ‘set_adapter_property’:android/hal-bluetooth.c:659:46: error: taking address of packed member of ‘struct hal_cmd_set_adapter_prop’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
659 | adapter_prop_from_hal(property, &cmd->type, &cmd->len, cmd->val);
| ^~~~~~~~~
--- android/hal-bluetooth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
android/hal-bluetooth.c +3 -1
@@ -649,6 +649,7 @@ static int set_adapter_property(const bt_property_t *property) {char buf[IPC_MTU ];struct hal_cmd_set_adapter_prop *cmd = (void *) buf; +uint16_t len_ret;size_t len;DBG ("prop: %s" ,btproperty2str (property));
@@ -656,8 +657,9 @@ static int set_adapter_property(const bt_property_t *property)if (!interface_ready ())return BT_STATUS_NOT_READY ; -adapter_prop_from_hal (property, &cmd->type, &cmd->len, cmd->val); +adapter_prop_from_hal (property, &cmd->type, &len_ret, cmd->val); + cmd->len = len_ret; len =sizeof (*cmd) + cmd->len; return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_SET_ADAPTER_PROP,
Signature · 1 line
2.21.0
PATCH 8/8 android/handsfree: Fix unaligned struct access
In reply to Bastien Noceraandroid/handsfree.c: In function ‘bt_sco_get_fd’:android/handsfree.c:2913:47: error: taking address of packed member of ‘struct sco_rsp_get_fd’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
2913 | if (!dev || !bt_sco_get_fd_and_mtu(sco, &fd, &rsp.mtu))
| ^~~~~~~~
--- android/handsfree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
android/handsfree.c +3 -1
@@ -2903,6 +2903,7 @@ static void bt_sco_get_fd(const void *buf, uint16_t len)struct sco_rsp_get_fd rsp;struct hf_device *dev;bdaddr_t bdaddr; +uint16_t mtu;int fd;DBG ("" );
@@ -2910,9 +2911,10 @@ static void bt_sco_get_fd(const void *buf, uint16_t len)android2bdaddr (cmd->bdaddr, &bdaddr); dev =find_device (&bdaddr); -if (!dev || !bt_sco_get_fd_and_mtu (sco, &fd, &rsp.mtu)) +if (!dev || !bt_sco_get_fd_and_mtu (sco, &fd, &mtu)) goto failed; + rsp.mtu = mtu;DBG ("fd %d mtu %u" , fd, rsp.mtu); ipc_send_rsp_full(sco_ipc, SCO_SERVICE_ID, SCO_OP_GET_FD,
Signature · 1 line
2.21.0
Hi Bastien,
Quoted 23 lines · Bastien Nocera
Add 3 optional features that are currently used and distributed in the Fedora packages to the default build configuration.
The additional build time is minimal, and it ensures that the build gets maximum coverage.
--- bootstrap-configure | 3 +++ 1 file changed, 3 insertions(+)bootstrap-configure +3
-1@@ -26,4 +26,7 @@ fi --enable-mesh \ --enable-btpclient \ --enable-logger \ + --enable-pie \ + --enable-cups \ + --enable-library \ --disable-datafiles $* --
Quoted 1 line
2.21.0
Applied, thanks. I skipped patches 2 and 5 since I want to check what can be done regarding of usage of pragma.
Signature · 1 line
Luiz Augusto von Dentz
Quoted 2 lines · Luiz Augusto von Dentz
Applied, thanks. I skipped patches 2 and 5 since I want to check what can be done regarding of usage of pragma.
Thanks for applying those.
Cheers