From patchwork Tue Dec 21 20:50:16 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: 526657 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 683C1C433F5 for ; Tue, 21 Dec 2021 20:50:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235054AbhLUUuX (ORCPT ); Tue, 21 Dec 2021 15:50:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233546AbhLUUuW (ORCPT ); Tue, 21 Dec 2021 15:50:22 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 657A1C061574 for ; Tue, 21 Dec 2021 12:50:22 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id v13-20020a17090a088d00b001b0e3a74cf7so2731602pjc.1 for ; Tue, 21 Dec 2021 12:50:22 -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=9gioiTWwalIa5OF/HF4UybI9NBTE5c0RS3SWUdaQliA=; b=DUS1D4Baan9L9V5HmbgM2rhzbePEd9kVTVqfpDPtrZ87EH2mrdsSkFw61kOSejhIfU XpyjB7whcUzjxcB4s20S4Xfp14srUNIVET1kevLMbl5vl4Svxj7sbZaKKqUVb82bSo+P iOlpvtXpgONQse5d4WCa5sK/TfSxXZV5bCdv/7GBt3n9/k5XzzeqIAptGENvPVCLtV50 4wWS1vAAw3S/ilL46yO2l/mhSv4p64ORQg8+blUBLAmloSgAmgIcArLtH2Br+/dJ81Zy ug2s2xWpEysrbx59cDaQTBCPUQBtcHpAb3wgjOy7K/y0Sv1Qgc/ve4wdDOahrbiNXI7Q 4J/g== 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=9gioiTWwalIa5OF/HF4UybI9NBTE5c0RS3SWUdaQliA=; b=rt4jq0SusTTOozd+M3H1oFYVa8AkCkpKHrtlnrS+GBvuY/oBW3b+u6frfBbHZ3n54D jxNPH97+MKtgf9lsG0JaKQLNH0DNtx0obPw2sfdtdbEwPNKGDuXy0dkEosPfHaoFkPFt lBtVGYPq28hnCbCfyMm3J2ZOK9d7bQv0bwaIloQvOtrbj1wxw8PaoZo5NEEFDbH47hN6 GzsN1rbnSm5Dv0j3DiOZP2ioSVCLZJroBfhSQZu1+K9eeCPOgFOeyENP9kQZy+zW/971 6b4KJKGjJS3ZLbPnJTYg7OTy53f/KgTlja6kEu+7kbM4aY/R1qfrQZDoSPOu7gmLKXwj G7iA== X-Gm-Message-State: AOAM531PYvoD7b7R7zHR/T0DAX5C9K4PKf4sCH/OZrxB8G+yAZ61L6YN 6MJvr757lVwL/HTp1sfowHJXncgtS80= X-Google-Smtp-Source: ABdhPJxPGgckSlGpGkOkpXBI/9cXextL2JrJ3zk7bmB83fF6XuRSd6z4spqO+bHNaB6ttviuCyKeYQ== X-Received: by 2002:a17:90b:3e82:: with SMTP id rj2mr249804pjb.172.1640119821501; Tue, 21 Dec 2021 12:50:21 -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 72sm3973pfu.70.2021.12.21.12.50.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 12:50:21 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 1/4] build: Add sanitizer options Date: Tue, 21 Dec 2021 12:50:16 -0800 Message-Id: <20211221205019.654432-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). --- Makefile.am | 6 +++++ acinclude.m4 | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 3 +++ 3 files changed, 84 insertions(+) diff --git a/Makefile.am b/Makefile.am index 993168f00..36ff19340 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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..cf9ede408 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 @@ -53,6 +92,42 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie -Wl,-z,now" 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" + 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" + 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 + ]) if (test "$enable_coverage" = "yes"); then misc_cflags="$misc_cflags --coverage" misc_ldflags="$misc_ldflags --coverage" diff --git a/configure.ac b/configure.ac index 2674e30d3..c9a7f40a9 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 From patchwork Tue Dec 21 20:50:17 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: 527758 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 5BF05C433EF for ; Tue, 21 Dec 2021 20:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235067AbhLUUuY (ORCPT ); Tue, 21 Dec 2021 15:50:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233546AbhLUUuX (ORCPT ); Tue, 21 Dec 2021 15:50:23 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E3B0C061574 for ; Tue, 21 Dec 2021 12:50:23 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id lr15-20020a17090b4b8f00b001b19671cbebso413650pjb.1 for ; Tue, 21 Dec 2021 12:50:23 -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=MmnY8I+w/jkgNmE6nCbTocoxK22UiRXsyy7Z4QQoM3M=; b=Dr3qcxVZTV0p4vp4seiGQjbwiakRNuUve8pi8HOsqXpqI65h45krtm31WT7YFUL0EZ TRpjnTOrUhMoMJv6xjrXE5cCzIo7bKtlZyhN9sQkvjqtybXxguaBb2pkwHxsSEYaeJ4C etqCb8JKuJvtbWiwU6qi9Zbj0WkjXH3CPzzZLQ9UTgwtJwdqaH60QDZkrJnePXWBWvzO 1Zy++pf5XMS44mJp+00OG7cydkdU1WXM7+NFuc2bjdVtHLbrgPaa35yPc7b2Fr2en2qp P8vTm0IgVsKZhBOmkpsfb51633i/asNE51ubSuWBoLStkWQlJHD1BSXIgrtgVsuEfKnu dxsQ== 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=MmnY8I+w/jkgNmE6nCbTocoxK22UiRXsyy7Z4QQoM3M=; b=UJZUJTe6bWznoQf+YOWah1r2RuUIQoLGcaEOL9DFBGCxwyCtoUD/U/0Cwjv6i7FpTf Q8sntzY+hiARWb2rGYwpQ3THS/celwoVEK35LbQkVqjstBIZSiun3m9FkNhswUYPqpKM W4YH64Dv0ykrrOagwxrUpmI3hBSg+R7wRxtib5De3EpTlzMWbqd7LOJGcIVl1udUCDyi IOHToV5J2LjEV+m7cX0b9Fz4d162UoigHVADyfzJMXLWdXZjjIrRxEIyrp6fyqDH9S77 TkY/jPG5SocxLRDfmb83PyVNrOyydZCQZMwdVVkoxdOPqPEumKG3zq70Vce7I11UUEga o9gA== X-Gm-Message-State: AOAM531SsFIOqftLgoyuFgUY0Lv6tETEjXu1AiTOv3xZT1czuZ0lSSim 50BLkJ0Q5Acm9f7tYwUuuTuglBKTbt8= X-Google-Smtp-Source: ABdhPJyu+SvIHgM+snFiC6C0ftcjEBhaVjn99gLA6XEltTRZLnziBPZKKxAEuWlfEplky/yMp/qnQw== X-Received: by 2002:a17:90b:3d6:: with SMTP id go22mr35939pjb.221.1640119822781; Tue, 21 Dec 2021 12:50:22 -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 72sm3973pfu.70.2021.12.21.12.50.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 12:50:22 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 2/4] build: Fix build when sanitizer are enabled Date: Tue, 21 Dec 2021 12:50:17 -0800 Message-Id: <20211221205019.654432-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211221205019.654432-1-luiz.dentz@gmail.com> References: <20211221205019.654432-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. --- 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) { From patchwork Tue Dec 21 20:50:18 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: 526656 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 9823BC433F5 for ; Tue, 21 Dec 2021 20:50:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235096AbhLUUuZ (ORCPT ); Tue, 21 Dec 2021 15:50:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233546AbhLUUuY (ORCPT ); Tue, 21 Dec 2021 15:50:24 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 827C9C061574 for ; Tue, 21 Dec 2021 12:50:24 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id x1-20020a17090a2b0100b001b103e48cfaso2757753pjc.0 for ; Tue, 21 Dec 2021 12:50:24 -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=VVixS75Im7AU6TSyn4M5NPbuJGTpke17jfBlWzRZT9uin4xLu1wWlovzDfFWmm7Wos 3r38kz7frvZg8CrSKy52vyx3XSH3xS26BSVX3clwx4f4r+w8LlN+EoxJx/B3OSRPA6fD 91yzZgBD+YcsqK6Ur2Iy+624Ds4L41guNOoW76vXfZqFsz5sZ5Syb/v6VkXX3VveM2JZ fgFpDtfpNb5jnGTKkbxDmTMiAwMoSyvqaIpmi1Z4gS9hhCgURlAdf5f8V2CEksnp+1Zy lqxZyuF0+0BqeMNH2cj5y7oFLu4UtK/DWVKgzfMbJ73/ad9mMMkYzgIPSAQk8CyFWjhU aTrw== 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=Wx8E1npHfcav1UrBwwERLZIk3nWb57RMTqXoDEJ3CR0cOVlq8PteQY7S6ZSytIdHXu j/vHdIEhgg41blcENxhRcybZtXR/PNOAqznk8ojoYwuFI02oyy7LPOiT1grQY84Ua1cH lAoyap8wgRV9825fBlDKHuiVORoSTUfJZxYqfI1afxxqzVBz5bFk6J2e77zITzYlktyQ dD0AXBB2LLPx9BcSi/H2Iy6uyhFdByG1mVQcFuUnCpI3facKniGsZE9BbAJOlxJlDSus HAK/GnNlcbj5PAXZRSNQDQbJ33sV85Fo8qfBzJ9+EZhD1xx92jOqdYGVkS0+rq4v2XFE 8OWA== X-Gm-Message-State: AOAM532zuBMi1FfN295WxOMC446r0GzfzBvRA64Dwj9jpIL1ROYEr/te ajSYdgLav1yK7wn7I2Ms+v0mK+5GDUs= X-Google-Smtp-Source: ABdhPJxpW23+tMeViNNJdNDxnNHBn/N6N1dZtq1zj/2puWfovJ+jo4/66tnXJo06NZxj3NSJmOExoA== X-Received: by 2002:a17:90b:1297:: with SMTP id fw23mr51672pjb.97.1640119823803; Tue, 21 Dec 2021 12:50:23 -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 72sm3973pfu.70.2021.12.21.12.50.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 12:50:23 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 3/4] bootstrap-configure: Enable sanitizer options Date: Tue, 21 Dec 2021 12:50:18 -0800 Message-Id: <20211221205019.654432-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211221205019.654432-1-luiz.dentz@gmail.com> References: <20211221205019.654432-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 Tue Dec 21 20:50:19 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: 527757 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 32DD0C433FE for ; Tue, 21 Dec 2021 20:50:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235134AbhLUUu0 (ORCPT ); Tue, 21 Dec 2021 15:50:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235115AbhLUUu0 (ORCPT ); Tue, 21 Dec 2021 15:50:26 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06C0BC061574 for ; Tue, 21 Dec 2021 12:50:26 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id p14so191620plf.3 for ; Tue, 21 Dec 2021 12:50:26 -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=WvASFp0ky7hePV+IeIuCjEqhfIhfX+8O4J6sP3YLk7cB66u0opDoQkdfX5062wKG2S 58jS0ppoNOxYWQFN5xOhf82+WxjaycumPCyrH4WkYxC8f5JRHIuf/OzoRgNYqVy8nL3O wQS4FpKzLKEpGCzV5B+pjDjg5ax2ca+ZJSh2iUN2goxa4yW3EXPGnmj51lXr27qRa/yX yarRrxBweA8ycKuaDQw6f1L1oS8QaKoMi4ZRQNDjdGgITQmpNGZc1oSnfnUdlxWZ9bHu zC5XQ6mu3iWk9USAUG6csQIbNE0E7xFjaTNkmxbs5H6kVLcsQTDaMWLkAITtmHukQr7G TkQA== 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=DVoSTT4Q7RrPlCq6gxFG+rpTjU4irOCRJMCrjB1Nvv9ocQ9xlL6FpyvqvGWhkeOL8f Q222HVguQLR3/v6Z4zAhNgGlaOiV+apRJXIDogsU0olGbrbgwjFF2FaFteswtyJZ+Swo FDJRWbDRioPlx3bGjGX46NXwnRW0YCdG9vTgRKPHJmIE6UPJrKnlzPNtJh+4GOqZXWwy fS3rt91yoo4Q4gEMuUYdq4BDUPrUuXqsC/NbDOs9T0DM6GLGaHhSvp2Ihp0txTq4vHYb KZVGAqwLfwIFwJ3Tq636/8eFaR4FGnNiowPghBRqEX9CufCZnSEbdxDvarLmtgwiKIqH GVJA== X-Gm-Message-State: AOAM533EY+5g3KtxN0CB8iNc/Njm/nuxr8XhYfmmjTHWNbgpE5ePLNmV zaDNel325e+wkMacE+WijOXnT3S6vBQ= X-Google-Smtp-Source: ABdhPJwL8Sr9tsAqA7gDE9Bqjv5pIey88E/9vLiVwvFWJmrCUaU9optkjHQ1ysJxrPIgpMMvF7vvkg== X-Received: by 2002:a17:90a:f001:: with SMTP id bt1mr265727pjb.60.1640119824888; Tue, 21 Dec 2021 12:50:24 -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 72sm3973pfu.70.2021.12.21.12.50.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 12:50:24 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 4/4] gattrib: Fix passing NULL to memcpy Date: Tue, 21 Dec 2021 12:50:19 -0800 Message-Id: <20211221205019.654432-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211221205019.654432-1-luiz.dentz@gmail.com> References: <20211221205019.654432-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; }