From patchwork Tue Feb 7 18:45:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Jarry X-Patchwork-Id: 123364 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2817141C32; Tue, 7 Feb 2023 19:45:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CBA540F18; Tue, 7 Feb 2023 19:45:29 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 1BD054021F for ; Tue, 7 Feb 2023 19:45:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675795527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wsjw//7l8rns2QbbtdaCBk9HlK9oxSAamDAyxfuKDaQ=; b=DTSfmgkqBowPB2jBCBxS4pqfZsuHvp/COYsCICLJPWO7JEHUVL6g9XBJptx0qvdq0e2EUp pC43I4CWTs1rNVBBKtKQqt6DmkwzQF4EEVZ128Ui2QKYYLfs4MQpxqPdsG3HhBpyzVFPv4 IPlmJJN4h7PnuJyIYLsCKsg1AWKn2ec= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-110-vPRWIZ4WOYyZgfi-PJOT4w-1; Tue, 07 Feb 2023 13:45:24 -0500 X-MC-Unique: vPRWIZ4WOYyZgfi-PJOT4w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0E7BE18E52C6; Tue, 7 Feb 2023 18:45:24 +0000 (UTC) Received: from ringo.home (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FEF62166B29; Tue, 7 Feb 2023 18:45:22 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org Cc: Robin Jarry , stable@dpdk.org, Ciara Power , Bruce Richardson , Keith Wiles Subject: [PATCH] telemetry: reset data before passing it to callback Date: Tue, 7 Feb 2023 19:45:20 +0100 Message-Id: <20230207184520.1238366-1-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If a telemetry endpoint callback returns 0 without modifying the data object, output_json() may be called with undefined contents in data. This can cause crashes and/or worse (double free, etc.). Reset data before passing it to the endpoint callbacks. Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality") Cc: stable@dpdk.org Signed-off-by: Robin Jarry --- lib/telemetry/telemetry.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 655191bcf17f..6303429bb0c9 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -335,6 +335,8 @@ perform_command(telemetry_cb fn, const char *cmd, const char *param, int s) { struct rte_tel_data data; + memset(&data, 0, sizeof(data)); + int ret = fn(cmd, param, &data); if (ret < 0) { char out_buf[MAX_CMD_LEN + 10];