* [PATCH v2 2/4] build: Fix build when sanitizer are enabled
2021-12-21 20:50 [PATCH v2 1/4] build: Add sanitizer options Luiz Augusto von Dentz
@ 2021-12-21 20:50 ` Luiz Augusto von Dentz
2021-12-21 20:50 ` [PATCH v2 3/4] bootstrap-configure: Enable sanitizer options Luiz Augusto von Dentz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-12-21 20:50 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes various issues found when sanitizers are enabled.
---
Makefile.tools | 2 ++
monitor/packet.c | 3 ++-
peripheral/main.c | 2 +-
profiles/audio/a2dp.c | 5 ++++-
profiles/network/bnep.c | 4 ++--
src/shared/gatt-server.c | 2 --
tools/mesh-gatt/util.c | 11 ++++++++---
tools/test-runner.c | 2 +-
8 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/Makefile.tools b/Makefile.tools
index c7bdff83f..12879859f 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -121,6 +121,8 @@ tools_mgmt_tester_SOURCES = tools/mgmt-tester.c monitor/bt.h \
emulator/smp.c
tools_mgmt_tester_LDADD = lib/libbluetooth-internal.la \
src/libshared-glib.la $(GLIB_LIBS)
+tools_mgmt_tester_LDFLAGS = $(AM_LDFLAGS) -fno-var-tracking-assignments
+tools_mgmt_tester_CFLAGS = $(AM_CFLAGS) -fno-var-tracking-assignments
tools_l2cap_tester_SOURCES = tools/l2cap-tester.c monitor/bt.h \
emulator/hciemu.h emulator/hciemu.c \
diff --git a/monitor/packet.c b/monitor/packet.c
index 71f711dc5..397000644 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -330,7 +330,8 @@ static void print_packet(struct timeval *tv, struct ucred *cred, char ident,
if ((filter_mask & PACKET_FILTER_SHOW_INDEX) &&
index != HCI_DEV_NONE) {
if (use_color()) {
- n = sprintf(ts_str + ts_pos, "%s", COLOR_INDEX_LABEL);
+ n = snprintf(ts_str + ts_pos, sizeof(ts_str) - ts_pos,
+ "%s", COLOR_INDEX_LABEL);
if (n > 0)
ts_pos += n;
}
diff --git a/peripheral/main.c b/peripheral/main.c
index 0f5210403..91adb45fc 100644
--- a/peripheral/main.c
+++ b/peripheral/main.c
@@ -73,7 +73,7 @@ static void prepare_filesystem(void)
if (!is_init)
return;
- for (i = 0; mount_table[i].fstype; i++) {
+ for (i = 0; mount_table[i].fstype && mount_table[i].target; i++) {
struct stat st;
if (lstat(mount_table[i].target, &st) < 0) {
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index eba2f9822..d0808c77a 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1338,9 +1338,12 @@ static gboolean a2dp_reconfigure(gpointer data)
if (setup->rsep) {
cap = avdtp_get_codec(setup->rsep->sep);
rsep_codec = (struct avdtp_media_codec_capability *) cap->data;
+ /* Check that codec really match after closing */
+ if (sep->codec != rsep_codec->media_codec_type)
+ setup->rsep = NULL;
}
- if (!setup->rsep || sep->codec != rsep_codec->media_codec_type)
+ if (!setup->rsep)
setup->rsep = find_remote_sep(setup->chan, sep);
if (!setup->rsep) {
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index f94f1da8a..54b950058 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -108,7 +108,7 @@ static int bnep_connadd(int sk, uint16_t role, char *dev)
struct bnep_connadd_req req;
memset(&req, 0, sizeof(req));
- strncpy(req.device, dev, 16);
+ strncpy(req.device, dev, 15);
req.device[15] = '\0';
req.sock = sk;
@@ -345,7 +345,7 @@ struct bnep *bnep_new(int sk, uint16_t local_role, uint16_t remote_role,
session->io = g_io_channel_unix_new(dup_fd);
session->src = local_role;
session->dst = remote_role;
- strncpy(session->iface, iface, 16);
+ strncpy(session->iface, iface, 15);
session->iface[15] = '\0';
g_io_channel_set_close_on_unref(session->io, TRUE);
diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
index 9beec44be..776e5ce2b 100644
--- a/src/shared/gatt-server.c
+++ b/src/shared/gatt-server.c
@@ -1119,8 +1119,6 @@ static void read_multiple_cb(struct bt_att_chan *chan, uint8_t opcode,
}
data = read_mult_data_new(server, chan, opcode, length / 2);
- if (!data)
- goto error;
for (i = 0; i < data->num_handles; i++)
data->handles[i] = get_le16(pdu + i * 2);
diff --git a/tools/mesh-gatt/util.c b/tools/mesh-gatt/util.c
index e845c4112..eb8b8eb29 100644
--- a/tools/mesh-gatt/util.c
+++ b/tools/mesh-gatt/util.c
@@ -41,9 +41,14 @@ void print_byte_array(const char *prefix, const void *ptr, int len)
char *line, *bytes;
int i;
- line = g_malloc(strlen(prefix) + (16 * 3) + 2);
- sprintf(line, "%s ", prefix);
- bytes = line + strlen(prefix) + 1;
+ if (prefix) {
+ line = g_malloc(strlen(prefix) + (16 * 3) + 2);
+ sprintf(line, "%s ", prefix);
+ bytes = line + strlen(prefix) + 1;
+ } else {
+ line = g_malloc((16 * 3) + 2);
+ bytes = line + 1;
+ }
for (i = 0; i < len; ++i) {
sprintf(bytes, "%2.2x ", data[i]);
diff --git a/tools/test-runner.c b/tools/test-runner.c
index eac120f4a..71cc0d2df 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -136,7 +136,7 @@ static void prepare_sandbox(void)
{
int i;
- for (i = 0; mount_table[i].fstype; i++) {
+ for (i = 0; mount_table[i].fstype && mount_table[i].target; i++) {
struct stat st;
if (lstat(mount_table[i].target, &st) < 0) {
--
2.33.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/4] bootstrap-configure: Enable sanitizer options
2021-12-21 20:50 [PATCH v2 1/4] build: Add sanitizer options Luiz Augusto von Dentz
2021-12-21 20:50 ` [PATCH v2 2/4] build: Fix build when sanitizer are enabled Luiz Augusto von Dentz
@ 2021-12-21 20:50 ` Luiz Augusto von Dentz
2021-12-21 20:50 ` [PATCH v2 4/4] gattrib: Fix passing NULL to memcpy Luiz Augusto von Dentz
2021-12-21 22:40 ` [v2,1/4] build: Add sanitizer options bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-12-21 20:50 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes bootstrap-configure enables all sanitizers.
---
bootstrap-configure | 3 +++
1 file changed, 3 insertions(+)
diff --git a/bootstrap-configure b/bootstrap-configure
index a34be8320..8172840d5 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -28,6 +28,9 @@ fi
--enable-btpclient \
--enable-logger \
--enable-pie \
+ --enable-asan \
+ --enable-lsan \
+ --enable-ubsan \
--enable-cups \
--enable-library \
--enable-admin \
--
2.33.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 4/4] gattrib: Fix passing NULL to memcpy
2021-12-21 20:50 [PATCH v2 1/4] build: Add sanitizer options Luiz Augusto von Dentz
2021-12-21 20:50 ` [PATCH v2 2/4] build: Fix build when sanitizer are enabled Luiz Augusto von Dentz
2021-12-21 20:50 ` [PATCH v2 3/4] bootstrap-configure: Enable sanitizer options Luiz Augusto von Dentz
@ 2021-12-21 20:50 ` Luiz Augusto von Dentz
2021-12-21 22:40 ` [v2,1/4] build: Add sanitizer options bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-12-21 20:50 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes the following runtime error:
attrib/gattrib.c:198:2: runtime error: null pointer passed as
argument 2, which is declared to never be null
---
attrib/gattrib.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 270a37ebe..041b9d289 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -195,7 +195,9 @@ static uint8_t *construct_full_pdu(uint8_t opcode, const void *pdu,
return NULL;
buf[0] = opcode;
- memcpy(buf + 1, pdu, length);
+
+ if (pdu && length)
+ memcpy(buf + 1, pdu, length);
return buf;
}
--
2.33.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [v2,1/4] build: Add sanitizer options
2021-12-21 20:50 [PATCH v2 1/4] build: Add sanitizer options Luiz Augusto von Dentz
` (2 preceding siblings ...)
2021-12-21 20:50 ` [PATCH v2 4/4] gattrib: Fix passing NULL to memcpy Luiz Augusto von Dentz
@ 2021-12-21 22:40 ` bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2021-12-21 22:40 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 6004 bytes --]
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=599015
---Test result---
Test Summary:
CheckPatch PASS 5.59 seconds
GitLint PASS 3.78 seconds
Prep - Setup ELL PASS 43.63 seconds
Build - Prep PASS 0.59 seconds
Build - Configure PASS 8.64 seconds
Build - Make FAIL 1360.64 seconds
Make Check FAIL 2.26 seconds
Make Distcheck PASS 233.67 seconds
Build w/ext ELL - Configure PASS 8.74 seconds
Build w/ext ELL - Make FAIL 1351.65 seconds
Incremental Build with patchesFAIL 1629.34 seconds
Details
##############################
Test: Build - Make - FAIL
Desc: Build the BlueZ source tree
Output:
unit/test-avdtp.c: In function ‘main’:
unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
766 | int main(int argc, char *argv[])
| ^~~~
unit/test-avrcp.c: In function ‘main’:
unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
989 | int main(int argc, char *argv[])
| ^~~~
In file included from /usr/include/string.h:495,
from /usr/include/glib-2.0/glib/gtestutils.h:30,
from /usr/include/glib-2.0/glib.h:85,
from profiles/audio/avctp.c:30:
In function ‘strncpy’,
inlined from ‘uinput_create.constprop’ at profiles/audio/avctp.c:1180:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 80 equals destination size [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:9530: profiles/audio/bluetoothd-avctp.o] Error 1
make: *** [Makefile:4316: all] Error 2
##############################
Test: Make Check - FAIL
Desc: Run 'make check'
Output:
In file included from /usr/include/string.h:495,
from /usr/include/glib-2.0/glib/gtestutils.h:30,
from /usr/include/glib-2.0/glib.h:85,
from profiles/audio/avctp.c:30:
In function ‘strncpy’,
inlined from ‘uinput_create.constprop’ at profiles/audio/avctp.c:1180:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 80 equals destination size [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:9530: profiles/audio/bluetoothd-avctp.o] Error 1
make: *** [Makefile:11419: check] Error 2
##############################
Test: Build w/ext ELL - Make - FAIL
Desc: Build BlueZ source with '--enable-external-ell' configuration
Output:
unit/test-avdtp.c: In function ‘main’:
unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
766 | int main(int argc, char *argv[])
| ^~~~
unit/test-avrcp.c: In function ‘main’:
unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
989 | int main(int argc, char *argv[])
| ^~~~
In file included from /usr/include/string.h:495,
from /usr/include/glib-2.0/glib/gtestutils.h:30,
from /usr/include/glib-2.0/glib.h:85,
from profiles/audio/avctp.c:30:
In function ‘strncpy’,
inlined from ‘uinput_create.constprop’ at profiles/audio/avctp.c:1180:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 80 equals destination size [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:9530: profiles/audio/bluetoothd-avctp.o] Error 1
make: *** [Makefile:4316: all] Error 2
##############################
Test: Incremental Build with patches - FAIL
Desc: Incremental build per patch in the series
Output:
unit/test-avdtp.c: In function ‘main’:
unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
766 | int main(int argc, char *argv[])
| ^~~~
unit/test-avrcp.c: In function ‘main’:
unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
989 | int main(int argc, char *argv[])
| ^~~~
In file included from /usr/include/string.h:495,
from /usr/include/glib-2.0/glib/gtestutils.h:30,
from /usr/include/glib-2.0/glib.h:85,
from profiles/audio/avctp.c:30:
In function ‘strncpy’,
inlined from ‘uinput_create.constprop’ at profiles/audio/avctp.c:1180:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 80 equals destination size [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:9530: profiles/audio/bluetoothd-avctp.o] Error 1
make: *** [Makefile:4316: all] Error 2
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 5+ messages in thread