From nobody Sun May 19 06:50:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1648785754; cv=none; d=zohomail.com; s=zohoarc; b=JRAPQC7SQ/jveyY55kvF1tQLGoU0ivU7sc3dk7kLn2bF/K5rmkkK6YUXEiBYiCcODqkdPVRo3e5+EpVKOLOjoxUPJMOSaWCHTMaWi0cVjxbH+q0OedsnFYpWV39F364vvyyPS09qGy43EgKU7YMv5KssNKjW3v6ULeAaJCLUb3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648785754; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/BQjfAn6wE15WpXLjLhXiMN8RPpCNJet8epHshcWnKQ=; b=X9pzPf1wuW5vj4G3MURALJ5Qr/T9Vr2eh1ZWym889coeWqTSaFZdFLuKdu9xIUHIb1sXt1tckOFS3xt7VPKdkaK5gzbzw2EUbtcv0IUUqjN6jE5cN1yyXIc+KeXF82fSEt2NYg5y+JEOXY+NlDWi02KwuEuFqfThvqLwJsmGDAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648785754505355.2659700886944; Thu, 31 Mar 2022 21:02:34 -0700 (PDT) Received: from localhost ([::1]:56146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1na8Ub-0004wk-0w for importer@patchew.org; Fri, 01 Apr 2022 00:02:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1na8RR-0001yi-Vq for qemu-devel@nongnu.org; Thu, 31 Mar 2022 23:59:18 -0400 Received: from mga18.intel.com ([134.134.136.126]:51138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1na8RN-0002s0-N5 for qemu-devel@nongnu.org; Thu, 31 Mar 2022 23:59:16 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 20:59:11 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 20:59:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648785553; x=1680321553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YLdF6NpOTfWp3qwGIAirD8aN2gGJUzJV8ptPQOvJvkI=; b=acqzN79DvkANOTYQZUVKidxQLr5ii9YqkhO7FpXP2GBaf9QBv79GgKc2 2aX6VY/AMAjR4ppPFCTlKCjjDVIbAWQJGBjOYUtA0kTIeqIMlSGvBkxOE 1rzQB6+/jbWkIxKweCYTkfkca6ZzBrupi+ZEIZ8gRtQ7aFRlQR8h8rnLr JK++3m573UUC2Vz6YKKrfBoeVl6cA3+ubwYFtYytEuR1/w1m476rDORTJ AakJ2IdpWVMaHbqdhuQyHkVmUx6UkiN0RBflO+LbCE64dD9E4++7OxiSn 6L1oJOTgYeR1TAEFKFcS7y3B3AB1xMQmYIHYOUo6XsW8J/U30zxUmkXkU A==; X-IronPort-AV: E=McAfee;i="6200,9189,10303"; a="242182895" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="242182895" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="567105814" From: Zhang Chen To: Jason Wang , Li Zhijian Subject: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH Date: Fri, 1 Apr 2022 11:46:59 +0800 Message-Id: <20220401034702.687057-2-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220401034702.687057-1-chen.zhang@intel.com> References: <20220401034702.687057-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.126; envelope-from=chen.zhang@intel.com; helo=mga18.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , qemu-dev , Like Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1648785756550100007 Content-Type: text/plain; charset="utf-8" If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log: {"timestamp": {"seconds": 1593484591, "microseconds": 26605},\ "event": "RESET", "data": {"guest": true, "reason": "guest-reset"}} qemu-system-x86_64: invalid runstate transition: 'colo' -> 'prelaunch' Long-term testing says that it's pretty safe. Signed-off-by: Like Xu Signed-off-by: Zhang Chen Acked-by: Dr. David Alan Gilbert --- softmmu/runstate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/softmmu/runstate.c b/softmmu/runstate.c index e0d869b21a..c021c56338 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -127,6 +127,7 @@ static const RunStateTransition runstate_transitions_de= f[] =3D { { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH }, =20 { RUN_STATE_COLO, RUN_STATE_RUNNING }, + { RUN_STATE_COLO, RUN_STATE_PRELAUNCH }, { RUN_STATE_COLO, RUN_STATE_SHUTDOWN}, =20 { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, --=20 2.25.1 From nobody Sun May 19 06:50:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1648785752; cv=none; d=zohomail.com; s=zohoarc; b=df8oked2R6ZgQQg9nNTAQ0wMYa31sFa7xSMpsuP0xzak9ZoWn2vQuguNOKB2n6qdZy68iEU5k7YNZZFJxkbIGAnzDtjIvkTnOobaCVquuT5Mz0EFiHT4ocpLi0r2m6MJSzDFL8t5RrwK93v5Mr28Zb8dpNFiAwiZqt+CL84jQZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648785752; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Icwe9nNRtY0DfHIOBSS6HvAqt/gyPQyz+BpYwBw3K3c=; b=Jew/2H18Lg9CS/JCFdnoDtVUeZ97ekwbcN8NgGLWeoV4GTPlwxfL4KTRrtdmBf1vARjnhV3z6xEmh/1WDV/mjLWkn1tvxPzm/dacPW452b86yILx9pAQS70QrfCZZh0QnaRBhVDuFIN8/as8FmUncTJPbwot9AweycfXLHBVEps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648785752137809.8683857728576; Thu, 31 Mar 2022 21:02:32 -0700 (PDT) Received: from localhost ([::1]:56028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1na8UZ-0004o3-0t for importer@patchew.org; Fri, 01 Apr 2022 00:02:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1na8RS-0001yj-0K for qemu-devel@nongnu.org; Thu, 31 Mar 2022 23:59:18 -0400 Received: from mga18.intel.com ([134.134.136.126]:51140) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1na8RP-0002sO-CO for qemu-devel@nongnu.org; Thu, 31 Mar 2022 23:59:16 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 20:59:13 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 20:59:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648785555; x=1680321555; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+KR3N9V7T8MqCND/Nwwc90Hdbu2yeWxQ07iPCUTk7qM=; b=ZvcE5KAnZmSJIMVgMbtAeBhpqZ9NRJn9tawKg89mGlVTj328h5cgZSEz 6uZ1nSo7F//8M+DzfAegspVU+rf4KqullYdqjVbzh3Tgc1S7iUock119U 7yEypWB7kDqIA/c/090F6fq6WXYmadSb7Xgqz6IaIlv28/EQh2E06oWr+ DMNv/+4IdsbsM1dFeu3xTvI2snhUG+F4FRl8KIvkytHrNc6AmaUv8GEAZ XUizMml1kga3SakoKSyXmHcTU1JeBVxTtxZlV1qYbTK4I46KTEHspsAqd iofRcp/RGPqemWDyI1yzOap53h3y+owSJvb6y5GdFf7bsKwp5rEROKh0Z w==; X-IronPort-AV: E=McAfee;i="6200,9189,10303"; a="242182899" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="242182899" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="567105837" From: Zhang Chen To: Jason Wang , Li Zhijian Subject: [PATCH V2 2/4] net/colo: Fix a "double free" crash to clear the conn_list Date: Fri, 1 Apr 2022 11:47:00 +0800 Message-Id: <20220401034702.687057-3-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220401034702.687057-1-chen.zhang@intel.com> References: <20220401034702.687057-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.126; envelope-from=chen.zhang@intel.com; helo=mga18.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , qemu-dev , Like Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1648785753161100002 Content-Type: text/plain; charset="utf-8" We notice the QEMU may crash when the guest has too many incoming network connections with the following log: 15197@1593578622.668573:colo_proxy_main : colo proxy connection hashtable f= ull, clear it free(): invalid pointer [1] 15195 abort (core dumped) qemu-system-x86_64 .... This is because we create the s->connection_track_table with g_hash_table_new_full() which is defined as: GHashTable * g_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func, GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func); The fourth parameter connection_destroy() will be called to free the memory allocated for all 'Connection' values in the hashtable when we call g_hash_table_remove_all() in the connection_hashtable_reset(). But both connection_track_table and conn_list reference to the same conn instance. It will trigger double free in conn_list clear. So this patch remove free action on hash table side to avoid double free the conn. Signed-off-by: Like Xu Signed-off-by: Zhang Chen --- net/colo-compare.c | 2 +- net/filter-rewriter.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 62554b5b3c..ab054cfd21 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -1324,7 +1324,7 @@ static void colo_compare_complete(UserCreatable *uc, = Error **errp) s->connection_track_table =3D g_hash_table_new_full(connection_key_has= h, connection_key_equal, g_free, - connection_destroy); + NULL); =20 colo_compare_iothread(s); =20 diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index bf05023dc3..c18c4c2019 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -383,7 +383,7 @@ static void colo_rewriter_setup(NetFilterState *nf, Err= or **errp) s->connection_track_table =3D g_hash_table_new_full(connection_key_has= h, connection_key_equal, g_free, - connection_destroy); + NULL); s->incoming_queue =3D qemu_new_net_queue(qemu_netfilter_pass_to_next, = nf); } =20 --=20 2.25.1 From nobody Sun May 19 06:50:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1648785753; cv=none; d=zohomail.com; s=zohoarc; b=esR7tBZR3flToHqJYnWk/60PvfKWYsAYmgIk5Kz+eYOkPr1bCWiGRy1Dr4a5XPgXmEGBszd1eyNlwdOQolkIVLMRVIIyuW9iKuMyKOYHUgU9rnUyd1izZLI3U1kSmvD1jw/bNB+D1mRWJE0E9IXyhQN/230fNvdXsjRB7C9YZao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648785753; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rEqW8gQxHjir5Jpj0rg4rqmYBa9NNHr+gc9YuBPBWms=; b=IUz3dk12Xdjfp0rXz7qYVuceHsSXEM/3RoTZmeCDHU+OwsPDga7AmIcwKK8KZGlaLhOPL6ZoclrAyyi5uvQJzzvUZWr1RcOBr/vhxm+/mtGVhUXUncF/ecz0TMY8yTHf80lTqawb/Iv33DMGPahV+ZMw+lsSRDWeCSL7hNqG2y8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648785753027263.15141918463826; Thu, 31 Mar 2022 21:02:33 -0700 (PDT) Received: from localhost ([::1]:56118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1na8UZ-0004v2-SB for importer@patchew.org; Fri, 01 Apr 2022 00:02:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1na8RS-0001z8-IQ for qemu-devel@nongnu.org; Thu, 31 Mar 2022 23:59:19 -0400 Received: from mga18.intel.com ([134.134.136.126]:51135) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1na8RQ-0002rm-9Q for qemu-devel@nongnu.org; Thu, 31 Mar 2022 23:59:18 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 20:59:15 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 20:59:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648785556; x=1680321556; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VEOvjFD4k6i7gSoK9//bs0L199HKmpI8ky3OQS0v42Q=; b=f5ZcawQkXNiMOm9+vXQQnSaTXI3p2KPw0YdFzdX1jCZ0jQ/ghKejK4sT tk246OqYqmU19R5KNa4rzWQdFTHlff04+5rZINjtPjiR9IqaJDz3LX57+ xcSVdrpNfmSaS/bpHItkgmnbXKPrkMJqjWKhExfxeZPZu0K3fv2E6z2TI KV7u4M4EmAkfGpYz8hsSFzhbqqYGyRNyfXln08C4og1AWiw4apAoR4KQU 4ULrAhv1W27Lc7zJOfteD67o2hEhQ2jz3VOtKJkI4q1QQqaEkrcBi+/+x ZdMZo25yoQ22HoZI72s8tVuHwmRZOyJ1Z8SDK4iJqbx7PXc+20RkhJ5HI g==; X-IronPort-AV: E=McAfee;i="6200,9189,10303"; a="242182903" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="242182903" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="567105864" From: Zhang Chen To: Jason Wang , Li Zhijian Subject: [PATCH V2 3/4] net/colo.c: No need to track conn_list for filter-rewriter Date: Fri, 1 Apr 2022 11:47:01 +0800 Message-Id: <20220401034702.687057-4-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220401034702.687057-1-chen.zhang@intel.com> References: <20220401034702.687057-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.126; envelope-from=chen.zhang@intel.com; helo=mga18.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , qemu-dev , Li Zhijian Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1648785754535100005 Content-Type: text/plain; charset="utf-8" Filter-rewriter no need to track connection in conn_list. This patch fix the glib g_queue_is_empty assertion when COLO guest keep a lot of network connection. Signed-off-by: Zhang Chen Reviewed-by: Li Zhijian --- net/colo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/colo.c b/net/colo.c index 1f8162f59f..694f3c93ef 100644 --- a/net/colo.c +++ b/net/colo.c @@ -218,7 +218,7 @@ Connection *connection_get(GHashTable *connection_track= _table, /* * clear the conn_list */ - while (!g_queue_is_empty(conn_list)) { + while (conn_list && !g_queue_is_empty(conn_list)) { connection_destroy(g_queue_pop_head(conn_list)); } } --=20 2.25.1 From nobody Sun May 19 06:50:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648785926738660.2759946865145; Thu, 31 Mar 2022 21:05:26 -0700 (PDT) Received: from localhost ([::1]:33516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1na8XN-0000qK-Hc for importer@patchew.org; Fri, 01 Apr 2022 00:05:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1na8RV-0001ze-76 for qemu-devel@nongnu.org; Thu, 31 Mar 2022 23:59:21 -0400 Received: from mga18.intel.com ([134.134.136.126]:51143) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1na8RS-0002tU-Jo for qemu-devel@nongnu.org; Thu, 31 Mar 2022 23:59:20 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 20:59:17 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 20:59:15 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648785558; x=1680321558; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7TieCHaXd/qt6aeQ/G3UtJJMKdCflNt2cJfEcvQ6hcI=; b=HSNYG8oFr/9HR+eM3cZMUf89nw6ERWjGkx2Txb+CK+Rex6x6QIguNAi+ ZKfp8bgIu1eHjZeveaORwlLCQ/nWVggUlduD0Prxpxn1jh0b5NZ6drhvL QY05JUk0ZYNuXLcgd7FUoOYjyJJKQV+JJoRM1ipTWkbb1CJtUciDhzfU8 WMwFsVfFzOBTJUBgrNWvgq9hE0xjRKY1a6F5k5GLXX7DGmVx4Qo8ThtzZ 8HxdHg+vufpZMi4BCZDPaH5/OZtP4928vLkSS6rNsXkT4E+DnmqKutqm1 Q9Czut22v0RO9tO9B9SHcl7DpcqBb92g+2y1L/S740HZICZsadJ4z7GCD A==; X-IronPort-AV: E=McAfee;i="6200,9189,10303"; a="242182911" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="242182911" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="567105887" From: Zhang Chen To: Jason Wang , Li Zhijian Subject: [PATCH V2 4/4] net/colo.c: fix segmentation fault when packet is not parsed correctly Date: Fri, 1 Apr 2022 11:47:02 +0800 Message-Id: <20220401034702.687057-5-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220401034702.687057-1-chen.zhang@intel.com> References: <20220401034702.687057-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.126; envelope-from=chen.zhang@intel.com; helo=mga18.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Tao Xu , qemu-dev , Li Zhijian Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648785928329100001 Content-Type: text/plain; charset="utf-8" When COLO use only one vnet_hdr_support parameter between filter-redirector and filter-mirror(or colo-compare), COLO will crash with segmentation fault. Back track as follow: Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault. 0x0000555555cb200b in eth_get_l2_hdr_length (p=3D0x0) at /home/tao/project/COLO/colo-qemu/include/net/eth.h:296 296 uint16_t proto =3D be16_to_cpu(PKT_GET_ETH_HDR(p)->h_proto); (gdb) bt 0 0x0000555555cb200b in eth_get_l2_hdr_length (p=3D0x0) at /home/tao/project/COLO/colo-qemu/include/net/eth.h:296 1 0x0000555555cb22b4 in parse_packet_early (pkt=3D0x555556a44840) at net/colo.c:49 2 0x0000555555cb2b91 in is_tcp_packet (pkt=3D0x555556a44840) at net/filter-rewriter.c:63 So wrong vnet_hdr_len will cause pkt->data become NULL. Add check to raise error and add trace-events to track vnet_hdr_len. Signed-off-by: Tao Xu Signed-off-by: Zhang Chen Reviewed-by: Li Zhijian --- net/colo.c | 9 ++++++++- net/trace-events | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/net/colo.c b/net/colo.c index 694f3c93ef..6b0ff562ad 100644 --- a/net/colo.c +++ b/net/colo.c @@ -46,7 +46,14 @@ int parse_packet_early(Packet *pkt) static const uint8_t vlan[] =3D {0x81, 0x00}; uint8_t *data =3D pkt->data + pkt->vnet_hdr_len; uint16_t l3_proto; - ssize_t l2hdr_len =3D eth_get_l2_hdr_length(data); + ssize_t l2hdr_len; + + if (data =3D=3D NULL) { + trace_colo_proxy_main_vnet_info("This packet is not parsed correct= ly, " + "pkt->vnet_hdr_len", pkt->vnet_hdr= _len); + return 1; + } + l2hdr_len =3D eth_get_l2_hdr_length(data); =20 if (pkt->size < ETH_HLEN + pkt->vnet_hdr_len) { trace_colo_proxy_main("pkt->size < ETH_HLEN"); diff --git a/net/trace-events b/net/trace-events index d7a17256cc..6af927b4b9 100644 --- a/net/trace-events +++ b/net/trace-events @@ -9,6 +9,7 @@ vhost_user_event(const char *chr, int event) "chr: %s got e= vent: %d" =20 # colo.c colo_proxy_main(const char *chr) ": %s" +colo_proxy_main_vnet_info(const char *sta, int size) ": %s =3D %d" =20 # colo-compare.c colo_compare_main(const char *chr) ": %s" --=20 2.25.1