From patchwork Wed Oct 27 14:22:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 103056 X-Patchwork-Delegate: maxime.coquelin@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 14CABA0C47; Wed, 27 Oct 2021 16:24:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0627D41151; Wed, 27 Oct 2021 16:24:00 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id B048540DDA for ; Wed, 27 Oct 2021 16:23:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635344637; 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: in-reply-to:in-reply-to:references:references; bh=exjK/nYcxDNyQdQGRay0yFUFMPpckKP8NXEkfDBJFsE=; b=ImH4aFnynPWexP12h4btJZcYFFPdjtBmKha591skf6G69mnPnhtaZY2ZugPt7jZL5WZ19P mvZQ419eercPPS0q2gOo5tm90OReiX9HGuuI99VGE3hDGGULrRVbrpCinKByaHyUdDbQ/N 9lbl1dJE85Z8+6j3Z7RhCAFtrXhQU1U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-x-bdHO9iOeGeFKT3rEXe-A-1; Wed, 27 Oct 2021 10:23:54 -0400 X-MC-Unique: x-bdHO9iOeGeFKT3rEXe-A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8BB03180831A; Wed, 27 Oct 2021 14:23:52 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4AA4100E12C; Wed, 27 Oct 2021 14:23:31 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, amorenoz@redhat.com, david.marchand@redhat.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@intel.com, michaelba@nvidia.com, viacheslavo@nvidia.com, xiaoyun.li@intel.com Cc: nelio.laranjeiro@6wind.com, yvugenfi@redhat.com, ybendito@redhat.com, Maxime Coquelin , stable@dpdk.org Date: Wed, 27 Oct 2021 16:22:10 +0200 Message-Id: <20211027142213.556166-3-maxime.coquelin@redhat.com> In-Reply-To: <20211027142213.556166-1-maxime.coquelin@redhat.com> References: <20211027142213.556166-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v6 2/5] app/testpmd: fix RSS key length 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 Sender: "dev" port_rss_hash_key_update() initializes rss_conf with the RSS key configuration provided by the user, but it calls rte_eth_dev_rss_hash_conf_get() before calling rte_eth_dev_rss_hash_update(), which overrides the parsed RSS config. While the RSS key value is set again after, this is not the case of the key length. It could cause out of bounds access if the key length parsed is smaller than the one read from rte_eth_dev_rss_hash_conf_get(). This patch restores the key length before the rte_eth_dev_rss_hash_update() call to ensure the RSS key value/length pair is consistent. Fixes: 8205e241b2b0 ("app/testpmd: add missing type to RSS hash commands") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Acked-by: Xiaoyun Li Reviewed-by: Chenbo Xia --- app/test-pmd/config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a18871d461..e5c58ceb37 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3040,7 +3040,7 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key, unsigned int i; rss_conf.rss_key = NULL; - rss_conf.rss_key_len = hash_key_len; + rss_conf.rss_key_len = 0; rss_conf.rss_hf = 0; for (i = 0; rss_type_table[i].str; i++) { if (!strcmp(rss_type_table[i].str, rss_type)) @@ -3049,6 +3049,7 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key, diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf); if (diag == 0) { rss_conf.rss_key = hash_key; + rss_conf.rss_key_len = hash_key_len; diag = rte_eth_dev_rss_hash_update(port_id, &rss_conf); } if (diag == 0)