From patchwork Wed Dec 22 23:42:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 527222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B7E9C433EF for ; Wed, 22 Dec 2021 23:42:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241033AbhLVXmH (ORCPT ); Wed, 22 Dec 2021 18:42:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbhLVXmH (ORCPT ); Wed, 22 Dec 2021 18:42:07 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 143C0C061574 for ; Wed, 22 Dec 2021 15:42:07 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id 205so3716427pfu.0 for ; Wed, 22 Dec 2021 15:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=t8oC9xYdCyKFmFG3FG69bNAWwzuoyCTQ4q3t0DlzqUk=; b=JQdCywv9gwXQN5Vpfl10TxbCp+7fCWtsifVk1VFgjUK97DJn3KbYmjj0kjjGdLprZZ Xkzah5s/yvGFDiZMZYiv7DdwlvxIoyqXAiQ3Wv0HpiN6XXcOPKx1qcW8h6E+LNBMnZ3F jIob97AMmDsg5yeKeABwDVIt2zfTJrknSykbwJUtvuCeahPHLvlnsAx3Mm2uJK1E19px BdQs/y/Fj6U2eL74hNj2z9L9ONXjodnNxnjxidzjtrFH+h7Zl0ZIdk7Y2Iur6powlWeF fGpTwuP2OEua2FYFkEt0HUQOHpBg9Ew2MfkXI8ya0ZP1BVkk9KFjQwJx39/QvwYfVF5x N7hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=t8oC9xYdCyKFmFG3FG69bNAWwzuoyCTQ4q3t0DlzqUk=; b=I5Zlz61LDTd/3Z9+gAcsU0HxqhrVBJS/4Id+yf4vxkb/+7wApPylV+z0D0J3zrGMHE H9q6+TU1wlxFZCyxwltHL155HgKUZrPq/MfBwhhJl8vpiWr268RbxHlVT+wSLEhzMaYl GMgiw8PjJI8LcYn9ad+TNXZn/FH3pv8piDVU+Fwn26VRe0q9XyoeVh3aHLAsu+lvJPcI 7Ck1RCeeNHQPeMTxxnhGleqleBv0IvV6HiE24Sdf7PgIi2KGhBYTrcqLmzsE1LMpd1MH fiCm8QCTwpH0qUQY1DLzXaCph70AaJ2cMARgTptrXaEvjc7l5oPumixjNh60KSIrX/rl 8nXg== X-Gm-Message-State: AOAM531IE1mVlTz7+yxfRu/aHvFcuVDjGWl+ExkSEUPuj/Rgr+kcJCRK 4zIiYeAdfjPyqQ/lJxGpcHSawqgWgWY= X-Google-Smtp-Source: ABdhPJx11cGrmcat/yLpUlav+JzDK8SZov/Bypoe4MIYR9tDsHNUgAEaxM95J9wiQ1Hkpovm7Yi0LQ== X-Received: by 2002:a63:1349:: with SMTP id 9mr4562489pgt.379.1640216526169; Wed, 22 Dec 2021 15:42:06 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id r10sm3563666pff.120.2021.12.22.15.42.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 15:42:05 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v3 1/4] build: Add sanitizer options Date: Wed, 22 Dec 2021 15:42:01 -0800 Message-Id: <20211222234204.1455901-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz Build using Address Sanitizer (asan), Leak Sanitizer (lsan), or Undefined Behavior Sanitizer (ubsan) by using one of these options for the configure script: --enable-asan --enable-lsan --enable-ubsan For each of these to work, the compiler must support the requested sanitizer and the requisite libraries must be installed (libasan, liblsan, libubsan). --- v2: Attempt to fix CI findings v3: Yet again attempt to fix CI findings, disable running tests with valgrind if either asan or lsan are enabled are they are likely going to conflict. Makefile.am | 8 +++++- acinclude.m4 | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 7 ++++- 3 files changed, 90 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 993168f00..308f13c50 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ pkgincludedir = $(includedir)/bluetooth pkginclude_HEADERS = -AM_CFLAGS = $(WARNING_CFLAGS) $(MISC_CFLAGS) $(UDEV_CFLAGS) $(LIBEBOOK_CFLAGS) \ +AM_CFLAGS = $(MISC_CFLAGS) $(WARNING_CFLAGS) $(UDEV_CFLAGS) $(LIBEBOOK_CFLAGS) \ $(LIBEDATASERVER_CFLAGS) $(ell_cflags) AM_LDFLAGS = $(MISC_LDFLAGS) @@ -243,6 +243,8 @@ src_libshared_glib_la_SOURCES = $(shared_sources) \ src/shared/mainloop-notify.h \ src/shared/mainloop-notify.c \ src/shared/tester.c +src_libshared_glib_la_LDFLAGS = $(AM_LDFLAGS) +src_libshared_glib_la_CFLAGS = $(AM_CFLAGS) src_libshared_mainloop_la_SOURCES = $(shared_sources) \ src/shared/io-mainloop.c \ @@ -250,6 +252,8 @@ src_libshared_mainloop_la_SOURCES = $(shared_sources) \ src/shared/mainloop.h src/shared/mainloop.c \ src/shared/mainloop-notify.h \ src/shared/mainloop-notify.c +src_libshared_mainloop_la_LDFLAGS = $(AM_LDFLAGS) +src_libshared_mainloop_la_CFLAGS = $(AM_CFLAGS) if LIBSHARED_ELL src_libshared_ell_la_SOURCES = $(shared_sources) \ @@ -257,6 +261,8 @@ src_libshared_ell_la_SOURCES = $(shared_sources) \ src/shared/timeout-ell.c \ src/shared/mainloop.h \ src/shared/mainloop-ell.c +src_libshared_ell_la_LDFLAGS = $(AM_LDFLAGS) +src_libshared_ell_la_CFLAGS = $(AM_CFLAGS) endif attrib_sources = attrib/att.h attrib/att-database.h attrib/att.c \ diff --git a/acinclude.m4 b/acinclude.m4 index 529848357..b388dfc11 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -10,6 +10,45 @@ AC_DEFUN([AC_PROG_CC_PIE], [ ]) ]) +AC_DEFUN([AC_PROG_CC_ASAN], [ + AC_CACHE_CHECK([whether ${CC-cc} accepts -fsanitize=address], + ac_cv_prog_cc_asan, [ + echo 'void f(){}' > asan.c + if test -z "`${CC-cc} -fsanitize=address -c asan.c 2>&1`"; then + ac_cv_prog_cc_asan=yes + else + ac_cv_prog_cc_asan=no + fi + rm -rf asan* + ]) +]) + +AC_DEFUN([AC_PROG_CC_LSAN], [ + AC_CACHE_CHECK([whether ${CC-cc} accepts -fsanitize=leak], + ac_cv_prog_cc_lsan, [ + echo 'void f(){}' > lsan.c + if test -z "`${CC-cc} -fsanitize=leak -c lsan.c 2>&1`"; then + ac_cv_prog_cc_lsan=yes + else + ac_cv_prog_cc_lsan=no + fi + rm -rf lsan* + ]) +]) + +AC_DEFUN([AC_PROG_CC_UBSAN], [ + AC_CACHE_CHECK([whether ${CC-cc} accepts -fsanitize=undefined], + ac_cv_prog_cc_ubsan, [ + echo 'void f(){}' > ubsan.c + if test -z "`${CC-cc} -fsanitize=undefined -c ubsan.c 2>&1`"; then + ac_cv_prog_cc_ubsan=yes + else + ac_cv_prog_cc_ubsan=no + fi + rm -rf ubsan* + ]) +]) + AC_DEFUN([COMPILER_FLAGS], [ with_cflags="" if (test "$USE_MAINTAINER_MODE" = "yes"); then @@ -38,6 +77,44 @@ AC_DEFUN([MISC_FLAGS], [ misc_cflags="$misc_cflags -O0" fi ]) + AC_ARG_ENABLE(asan, AC_HELP_STRING([--enable-asan], + [enable linking with address sanitizer]), [ + save_LIBS=$LIBS + AC_CHECK_LIB(asan, _init) + LIBS=$save_LIBS + if (test "${enableval}" = "yes" && + test "${ac_cv_lib_asan__init}" = "yes" && + test "${ac_cv_prog_cc_asan}" = "yes"); then + misc_cflags="$misc_cflags -fsanitize=address"; + misc_ldflags="$misc_ldflags -fsanitize=address" + AC_SUBST([ASAN_LIB], ${ac_cv_lib_asan__init}) + fi + ]) + AC_ARG_ENABLE(lsan, AC_HELP_STRING([--enable-lsan], + [enable linking with address sanitizer]), [ + save_LIBS=$LIBS + AC_CHECK_LIB(lsan, _init) + LIBS=$save_LIBS + if (test "${enableval}" = "yes" && + test "${ac_cv_lib_lsan__init}" = "yes" && + test "${ac_cv_prog_cc_lsan}" = "yes"); then + misc_cflags="$misc_cflags -fsanitize=leak"; + misc_ldflags="$misc_ldflags -fsanitize=leak" + AC_SUBST([ASAN_LIB], ${ac_cv_lib_lsan__init}) + fi + ]) + AC_ARG_ENABLE(ubsan, AC_HELP_STRING([--enable-ubsan], + [enable linking with address sanitizer]), [ + save_LIBS=$LIBS + AC_CHECK_LIB(ubsan, _init) + LIBS=$save_LIBS + if (test "${enableval}" = "yes" && + test "${ac_cv_lib_ubsan__init}" = "yes" && + test "${ac_cv_prog_cc_ubsan}" = "yes"); then + misc_cflags="$misc_cflags -fsanitize=undefined"; + misc_ldflags="$misc_ldflags -fsanitize=undefined"; + fi + ]) AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [ if (test "${enableval}" = "yes" && diff --git a/configure.ac b/configure.ac index 2674e30d3..849e1db46 100644 --- a/configure.ac +++ b/configure.ac @@ -23,6 +23,9 @@ AC_C_RESTRICT AC_PROG_CC AM_PROG_CC_C_O AC_PROG_CC_PIE +AC_PROG_CC_ASAN +AC_PROG_CC_LSAN +AC_PROG_CC_UBSAN AC_PROG_INSTALL AC_PROG_MKDIR_P @@ -40,10 +43,12 @@ if (test "$USE_MAINTAINER_MODE" = "yes"); then fi AM_CONDITIONAL(COVERAGE, test "${enable_coverage}" = "yes") AM_CONDITIONAL(DBUS_RUN_SESSION, test "${enable_dbus_run_session}" = "yes") -AM_CONDITIONAL(VALGRIND, test "${enable_valgrind}" = "yes") MISC_FLAGS +AM_CONDITIONAL(VALGRIND, test "${enable_valgrind}" = "yes" && + test "$ASAN_LIB" != "yes" && test "LSAN_LIB" != "yes") + AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads], [enable threading support]), [enable_threads=${enableval}]) From patchwork Wed Dec 22 23:42:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 527748 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE9A5C433FE for ; Wed, 22 Dec 2021 23:42:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242162AbhLVXmI (ORCPT ); Wed, 22 Dec 2021 18:42:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241962AbhLVXmH (ORCPT ); Wed, 22 Dec 2021 18:42:07 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 978F0C061574 for ; Wed, 22 Dec 2021 15:42:07 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id 200so3351556pgg.3 for ; Wed, 22 Dec 2021 15:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cDHiNrmydCfr5T91Wwz5jua8SYnbjMFMmQ++gdgbbME=; b=clpGgErrXDzluJ86U5tQEbXfszMJyJNwPbQ8C3fX3N4DWC6SHbNPp+GRrChdGs7U/f X4+gMVNgIdYIPJ0QhysiOFAlV5smFx+01NxYvsPYtZPwQ2LXjFd78gNIQbhJJIRQv/7E B1TFAcqF6mPLmKoHNF4Wsx+fkDFuVSfgHwU+PHx0cMsRZoOtI7OqbkKT9IoDkj7VaQn7 lGsQGhgvFL7K9WOR9sse9nyGU71IN+tEu8JoQBqmnbWBxrUnGdQiO7UatFJsfxtvbVtl VaTfp6e/KQBTdYP0b4hBflj++MfzWLiNsXF9bEGj5lUSSHMmgYCrA5L3pVk3RWfp6Z4/ OwuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cDHiNrmydCfr5T91Wwz5jua8SYnbjMFMmQ++gdgbbME=; b=CzGjO5s4iRuU6xA3hjcWH8wojo0F5bdatKjb2xwUy1hOG9I2NHOjJoPN0ycaCTM42M aTVivXq8IiUuBDOa2e5fFzfYYkvjc12Hcz2qrGvGQKsGkGVExUPCBNEVAKKLziYY6ZQf t9bM0zQeA9can7bY2UFMH8gXtvpvydbHWCwaOH9e2jOD4vRZTRHiAAn48ZDemv0178nH iJslHV6WqfpVz18HgOjrQBeUSPAU+nwb32g/Zqouu+/zQnKBqXH2V9AoU/MvOqXjJIN1 GzzM/a7Y52g/jG4jrbyTkeCPjjkzo6sdP9uUK46fx0dt3WAwmpbbCh/bQrKRUf6IzHPv Gvzg== X-Gm-Message-State: AOAM530r7x0zDaInVqTb0FNAQt2c42gC4Uqe94Ss7or1TS+Avwn1xIxG jSMTggI0WbUgeFUUR2pEmvnjePNy1+s= X-Google-Smtp-Source: ABdhPJwQPcsyElhAysps+mYNeEXRHVuh+5L7P4cx4pViRKy2NHnGOS0Q07IVTvsxVxNuzy0drXshWQ== X-Received: by 2002:a63:a18:: with SMTP id 24mr195pgk.100.1640216526712; Wed, 22 Dec 2021 15:42:06 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id r10sm3563666pff.120.2021.12.22.15.42.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 15:42:06 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v3 2/4] build: Fix build when sanitizer are enabled Date: Wed, 22 Dec 2021 15:42:02 -0800 Message-Id: <20211222234204.1455901-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211222234204.1455901-1-luiz.dentz@gmail.com> References: <20211222234204.1455901-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This fixes various issues found when sanitizers are enabled. --- 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 +- 7 files changed, 18 insertions(+), 11 deletions(-) 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) { From patchwork Wed Dec 22 23:42:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 527221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52DD9C433EF for ; Wed, 22 Dec 2021 23:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242195AbhLVXmI (ORCPT ); Wed, 22 Dec 2021 18:42:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242144AbhLVXmI (ORCPT ); Wed, 22 Dec 2021 18:42:08 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 129D1C061574 for ; Wed, 22 Dec 2021 15:42:08 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id s1so1833207pga.5 for ; Wed, 22 Dec 2021 15:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Y1ismcWgDnFFXISLA/l57y2B3Rq2xdUkaw18gPCSGm0=; b=VdxdZY6Blb+D9pW0gK499pQatucPQ4XRfDwrOtVK8UNY5feWJfixrx0YQaIW8ZRHjI aMGztpWyi4Wlf5LNwvx6kniHLjaGe/LoKkItLkKqUEFUZjKoIhKnWE+YAh+tqQ3xQWqQ UzOTHMB8Z9Jja741gxxaRFpSmzmlGfe62ihekBytb7BgUFYa6pbFCzb6ONIZZ4Hk+XgR fU7EvlgKYNPK+UCHQGFADpZ33r6RcgNM+hH/kzv+hbPk3AsPPL8zaXpDfQhVDLksAvR6 1lEFtkxUCLu4T3zBfnFjHeqER2eJeDuYs1wDNX9ebau8Z3Zs9eAGjw8N1F3H7H03izeQ Bfmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y1ismcWgDnFFXISLA/l57y2B3Rq2xdUkaw18gPCSGm0=; b=t1gircMHrXokY+5acNvC5i4/TrFSXupJJpengxc7O8yl9qRUKdnSdJZ5Wl/NYdNKPD e/EAVk3DlBIvrQUTvn37V6aluL9ldZ0ZYFXM1IZAcskunKWOqVfMGcpi+Pdgh77qzA4b 403ZkatcwySRe9DYzczfeAQDg5bjSnZh3FJtAuPL2wpVIOUCJNixtu6qbgl2Wb8mKThB aI84lBf9YNfqMwjaUAGKZUXnLu7MS6Vj+fzGSz2Z5zQ/TvH0QfJrcAMJSpnVwnxDZuib ommuFKCGRcasWAnvxoTL7HsSjqJHK/ys/fEnUhCtSHFVUbXe0ypbMhOxSCpyYUsJGfLD Z6dA== X-Gm-Message-State: AOAM531dCbeE7rcoCQycL9yiL6grA9cu432knjZLBpY+xC+NTDJ8rm1X 2MdwFQEZkkX95Jz2shh9Psual3Z1geM= X-Google-Smtp-Source: ABdhPJyqNOkwy5kaljekYpyX2ZbEwlSklR1aZrySR/Ndb9PbV6tGg9h960F83fWMB0ZzHHOvRWI4SA== X-Received: by 2002:a05:6a00:174a:b0:4ba:7a99:e789 with SMTP id j10-20020a056a00174a00b004ba7a99e789mr5152709pfc.76.1640216527283; Wed, 22 Dec 2021 15:42:07 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id r10sm3563666pff.120.2021.12.22.15.42.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 15:42:07 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v3 3/4] bootstrap-configure: Enable sanitizer options Date: Wed, 22 Dec 2021 15:42:03 -0800 Message-Id: <20211222234204.1455901-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211222234204.1455901-1-luiz.dentz@gmail.com> References: <20211222234204.1455901-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz 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 \ From patchwork Wed Dec 22 23:42:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 527747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EDBBC433F5 for ; Wed, 22 Dec 2021 23:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243694AbhLVXmK (ORCPT ); Wed, 22 Dec 2021 18:42:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242243AbhLVXmI (ORCPT ); Wed, 22 Dec 2021 18:42:08 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B26F8C061574 for ; Wed, 22 Dec 2021 15:42:08 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id n15-20020a17090a160f00b001a75089daa3so7228833pja.1 for ; Wed, 22 Dec 2021 15:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9ihzvmfL1JKR63zuErQK+qR+qt0qyup6+/MlQjMaiNo=; b=P1QlfCSX5AcBXjtTliZSJB8ctd1GrYz+lKTkTttkXwC0br+td/TD14+9s2clZfP7oZ lPDboM+L41TeKOCLLpcBPSTZjAiIMLjrP5ydBtiMd8TWBhhJghlgbYeehJIqfSXEUe9v LtP81YwLw4eb3IWYWbRd+r+VIpkI6GI9BZm/jt9bCwaaUkKmUafPyxs689fUp1eODb51 fZK/wrUBM3PuGCngIUId3WedP9mUpgxFDA6dRIWNX3JGAp/NbVp/HgAE/LaHHqeadinJ /kDvs7YcOp7kHDfnPjucVB0PjeJhpvV3l1ZNF80+V2+4UKxubuKjPSGy6TCvq6Vrwqvm Ow7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ihzvmfL1JKR63zuErQK+qR+qt0qyup6+/MlQjMaiNo=; b=1dLgdUVOHu+FhsXS1OmIY4GLAxuMnjA0SErtIQClQragxjNSECNLqxJo+eiwd6bHN5 h2+RO9CbYi5fbTTuz22Oi+/as4AJx2YCipaDjerAdCLSp78XfyiA9eUwj5l/bXWpZbY6 3EzOakMCDgfPDKMjq27h6yDyea7IVPyA8z10jyumASgz3pLoR1hP0J1eDHut6LzKK5pt oD+HZzuBjm5EOZnTWQSmlS00cRfAtv+GzkK71h0/O+cGFCGLaFmQ0Q3LjHbiy+Y8gou7 VKHBYtu9hOW7CjZ6XRKyWwbZdkB6iDEiXLEHgrN6xBqixB2kUdsLe99LK7oQJvp+gXt2 ZOtA== X-Gm-Message-State: AOAM533ElxKz6Iz5FeeRiIIv2qNmBgpGEL50qD+b1BlhLPFth/JW8OTR THU8JJp5hgCu4+VX0XcgjTMB1PkfLgU= X-Google-Smtp-Source: ABdhPJz2fhrKyVQLM7++COhvMBC+Hjdd0fujoJ2qLn8yjvU9i2jCs13V1IUgV/hxDkEwLl0EqvLFUQ== X-Received: by 2002:a17:90a:eb08:: with SMTP id j8mr157167pjz.68.1640216528033; Wed, 22 Dec 2021 15:42:08 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id r10sm3563666pff.120.2021.12.22.15.42.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 15:42:07 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v3 4/4] gattrib: Fix passing NULL to memcpy Date: Wed, 22 Dec 2021 15:42:04 -0800 Message-Id: <20211222234204.1455901-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211222234204.1455901-1-luiz.dentz@gmail.com> References: <20211222234204.1455901-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz 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; }