From patchwork Mon Dec 11 13:44:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 847167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PfUyDu4K"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ywX655fkbz9sNx for ; Tue, 12 Dec 2017 05:48:29 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CA488D1D; Mon, 11 Dec 2017 18:48:25 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 514E9BAD for ; Mon, 11 Dec 2017 18:48:24 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0847E17E for ; Mon, 11 Dec 2017 18:48:23 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id j4so11544350pgp.1 for ; Mon, 11 Dec 2017 10:48:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fj9T6ZCKDMT3eGz9B9e9eWoMwYL1/cjQ0Btwrmx2mT0=; b=PfUyDu4KjF6H830xD18TKpddkyTeRMjNQR4N0rCXeSeGoavqee9PvaH0WcANQVZ8eS p8rj3wMq5bUdqUAjyHmgPSLJgzITZjcGlkVA9UWfrlWs2p8gApfUVqQZHWbYvJQHRWZ/ BP5w+E0yJYrNR42fjFwKdRil9t8jQeXWAEw0vKLkxmu/1PcUVT6HckZrfEwoDwdlZuCj Xg5qClePqgKLruX6OPOSQzx8xUqGDSkqssXw1eSgz9wsCfj4XSW0Sv1newYgiXawjA/q OOBoTSBLTrE9STdcwDZjZzllnsycZB53/VJ9iZFTobMobyPCrV1jRgvKZhZJKgPoY3w9 bynA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fj9T6ZCKDMT3eGz9B9e9eWoMwYL1/cjQ0Btwrmx2mT0=; b=ckCmBe8ClVfbAAGLC7ZLGHFDfYkuSzDcFT1OZZ9jiqH/a6yZOmGhM84cYio4u/rCd6 OM85oS5wYxeXmdQktbnublKY5+GFgZdeDD2RJAztZ1qE1/tsR0fzlqEG6MmNeCMXI5nq 5bNI7G9tQVrL0rxH+ukmU+WWyS5+7EaHAlknB7y/R+N3MlC3Jk6ov9kvJ1MLSoaV+xdt Ip49KQl3cEU3BgQvKTml2xVvf/W9vC15ql3RhDRTln9C9qFQa6dBBH+3o7/y392fFWrw 8jTKRdbihSTPRjnEdAr2tq5LTvLbbqPTWZ7/dwBAHdHycZZgNe6+NY7iKdMIXaoaX7j6 +x6A== X-Gm-Message-State: AKGB3mIeSymRZwZYc6Di2SOCsq3uOF6YprnAwAV/pYDM/l/WI4AZNBRG 2r45uoa2DQwbO7waryB1x5imEA== X-Google-Smtp-Source: ACJfBoun8T2VYPq+4v0z2AMeBymXIwoAOq2f1OspjG0/Q0zn7FXz/Ldlo0oVfZWSh17FOn430uaGow== X-Received: by 10.84.232.141 with SMTP id i13mr1229194plk.315.1513018103342; Mon, 11 Dec 2017 10:48:23 -0800 (PST) Received: from yfsovs.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id g77sm31658766pfd.75.2017.12.11.10.48.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 10:48:22 -0800 (PST) From: Yifeng Sun To: dev@openvswitch.org Date: Mon, 11 Dec 2017 05:44:06 -0800 Message-Id: <1512999847-24034-1-git-send-email-pkusunyifeng@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 1/2] valgrind: Add support to run kernel datapath testsuite under valgrind X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org With this patch, kernel datapath testsuite can be run under valgrind by using the "check-kernel-valgrind" target and the results can be found under directory "tests/system-kmod-testsuite.dir/". Signed-off-by: Yifeng Sun Tested-by: Greg Rose --- Documentation/topics/testing.rst | 4 ++++ tests/automake.mk | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/topics/testing.rst b/Documentation/topics/testing.rst index 85aa6a1fb495..6645b794a07f 100644 --- a/Documentation/topics/testing.rst +++ b/Documentation/topics/testing.rst @@ -118,6 +118,10 @@ valgrind by using the ``check-valgrind`` target:: When you do this, the "valgrind" results for test ```` are reported in files named ``tests/testsuite.dir//valgrind.*``. +To test the testsuite of kernel datapath under valgrind, you can use the +``check-kernel-valgrind`` target and find the "valgrind" results under +directory ``tests/system-kmod-testsuite.dir/``. + All the same options are available via TESTSUITEFLAGS. .. hint:: diff --git a/tests/automake.mk b/tests/automake.mk index 7eed1064e82b..0acafca100d3 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -214,6 +214,13 @@ check-valgrind: all $(valgrind_wrappers) $(check_DATA) @echo '----------------------------------------------------------------------' @echo 'Valgrind output can be found in tests/testsuite.dir/*/valgrind.*' @echo '----------------------------------------------------------------------' +check-kernel-valgrind: all $(valgrind_wrappers) $(check_DATA) + set $(SHELL) '$(SYSTEM_KMOD_TESTSUITE)' -C tests VALGRIND='$(VALGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d $(TESTSUITEFLAGS) -j1; \ + "$$@" || (test X'$(RECHECK)' = Xyes && "$$@" --recheck) + @echo + @echo '----------------------------------------------------------------------' + @echo 'Valgrind output can be found in tests/system-kmod-testsuite.dir/*/valgrind.*' + @echo '----------------------------------------------------------------------' check-helgrind: all $(valgrind_wrappers) $(check_DATA) -$(SHELL) '$(TESTSUITE)' -C tests CHECK_VALGRIND=true VALGRIND='$(HELGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d $(TESTSUITEFLAGS) From patchwork Mon Dec 11 13:44:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 847168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dJr5BKC4"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ywX6Z1RHMz9s5L for ; Tue, 12 Dec 2017 05:48:54 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id BF99ED1E; Mon, 11 Dec 2017 18:48:26 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 378A3BAD for ; Mon, 11 Dec 2017 18:48:25 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E7C1F4F6 for ; Mon, 11 Dec 2017 18:48:24 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id b18so11531565pgv.10 for ; Mon, 11 Dec 2017 10:48:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4yQtMfI2AQ6dySzPuCF/pbvuS1IRXWulpss+Lm2jtFg=; b=dJr5BKC4oXLw4MDQFV42N/13xeDy2nvnHpqmmcCWzqDhegToXClGVJyqH2NofWWVTM 1AAwUD9udctGS/+LeQiOgHioKRH1Y16H/GyXu4FjSlMbm/lmR3dwMMAXtOuUog+3e5kN Oxp7SzYLHFIjsZSK98LlTvq4uC8RKw5YcjxYoJ1ZUG3gAk4V8F/BlwE/Yy2WfB4TWN2W 0LQ52ItBPZZDJvu02X45yyZaaxVR7f8yAv6Z3+SEFSYL46hvloTmQXZIzOT78pcD+DjF DhORK+tfZEpcXifSMvI20HHIJPC0KjBYGxDq/kJ50uNAIavlH7e92rG6oL+UiRx4xzDU c0iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4yQtMfI2AQ6dySzPuCF/pbvuS1IRXWulpss+Lm2jtFg=; b=c5TNLGnrVrvEtRT12YjPCmZMD7v5OAH+PnmsZj/ANwmXvLK98XZoW1oGv4yi6cEXcY WgJyIwn0EgwnubSqa7+iXb9sG8PkJTptQr0pp0aRzUBhlDVhQfcQSn8MyE52sMygmMAx p97bKnFS/6SzyS/GDAX8K8U5SKSy7BMGan1STgTw55wPTVTPcezxaE3mGOvUr+MRkOts DkLwymHOhOS4YBtUJIZXBJeD1B86SpXPdLeM1ZPP46s5lyIhMNUAX32H3fq8Eh4JinKa FVw94EVnb9vtfiWCx2621IUplEyf4jd0/cmX0Ox7J+jcWqLuF+6oIo/hs+r8au0jGTVS tOew== X-Gm-Message-State: AKGB3mI0GSdLMoWcknN9X77x/pre38K55P+pcZXffQj+ssSBqwCcSEno ZKeQgqs1dMgI8YTtAVm2NVvONA== X-Google-Smtp-Source: ACJfBouGB1wDPt/iFUvJ4gzJH/cZ0zt7T1DfM4LPTbOWSAEvhgOUY21IaBqBXwAsDi87A6hvzyQVtw== X-Received: by 10.99.190.14 with SMTP id l14mr1141607pgf.168.1513018104386; Mon, 11 Dec 2017 10:48:24 -0800 (PST) Received: from yfsovs.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id g77sm31658766pfd.75.2017.12.11.10.48.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 10:48:23 -0800 (PST) From: Yifeng Sun To: dev@openvswitch.org Date: Mon, 11 Dec 2017 05:44:07 -0800 Message-Id: <1512999847-24034-2-git-send-email-pkusunyifeng@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512999847-24034-1-git-send-email-pkusunyifeng@gmail.com> References: <1512999847-24034-1-git-send-email-pkusunyifeng@gmail.com> X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/2] bond: Fix bug that writes to freed memory X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org pr_op->pr_rule is pointing to memory in bond->hash. It shouldn't be written if bond->hash is already freed. This bug is reported by running kernel path testsuite under valgrind: Invalid write of size 8 at 0x413D16: update_recirc_rules__ (bond.c:392) by 0x414CA0: bond_unref (bond.c:290) by 0x427E3C: bundle_destroy (ofproto-dpif.c:3002) by 0x429EF4: bundle_set (ofproto-dpif.c:3023) by 0x40858B: port_destroy (bridge.c:4087) by 0x40BD04: bridge_destroy (bridge.c:3266) by 0x410528: bridge_exit (bridge.c:506) by 0x4072EE: main (ovs-vswitchd.c:135) Address 0xb5a85f0 is 5,360 bytes inside a block of size 12,288 free'd at 0x4C2EDEB: free (/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x414C8D: bond_unref (bond.c:288) by 0x427E3C: bundle_destroy (ofproto-dpif.c:3002) by 0x429EF4: bundle_set (ofproto-dpif.c:3023) by 0x40858B: port_destroy (bridge.c:4087) by 0x40BD04: bridge_destroy (bridge.c:3266) by 0x410528: bridge_exit (bridge.c:506) by 0x4072EE: main (ovs-vswitchd.c:135) Block was alloc'd at at 0x4C2DB8F: malloc (/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x516C04: xmalloc (util.c:120) by 0x414FD1: bond_entry_reset (bond.c:1651) by 0x414FD1: bond_reconfigure (bond.c:470) by 0x41507D: bond_create (bond.c:245) by 0x429D5D: bundle_set (ofproto-dpif.c:3194) by 0x408AC8: port_configure (bridge.c:1052) by 0x40CD87: bridge_reconfigure (bridge.c:682) by 0x410775: bridge_run (bridge.c:2998) by 0x407244: main (ovs-vswitchd.c:119) Signed-off-by: Yifeng Sun Tested-by: Greg Rose Reviewed-by: Greg Rose --- ofproto/bond.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ofproto/bond.c b/ofproto/bond.c index 8ecd22c7d5d3..6f3d7b5b3817 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -389,7 +389,9 @@ update_recirc_rules__(struct bond *bond) } hmap_remove(&bond->pr_rule_ops, &pr_op->hmap_node); - *pr_op->pr_rule = NULL; + if (bond->hash) { + *pr_op->pr_rule = NULL; + } free(pr_op); break; }