From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B014A4577A; Fri, 9 Aug 2024 17:25:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3C4D4300B; Fri, 9 Aug 2024 17:25:53 +0200 (CEST) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by mails.dpdk.org (Postfix) with ESMTP id 031B34025F for ; Fri, 9 Aug 2024 17:25:52 +0200 (CEST) Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-70d1fb6c108so1748735b3a.3 for ; Fri, 09 Aug 2024 08:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1723217151; x=1723821951; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m1k9BA+x0j9zQdUqvXd2Lf1PWPyF+I7fseNcuSuXM8Q=; b=2uaOOiQpKGoThrlp+XVdxQ90CM7y+exGexwIa5Uz0VDxzaZ8ov6hiAFOZ+Sm3RMFFN /6CrUaEVIrAjfy1a2UzER6QydqATR1skvDJ4i1LMZqdZ5Zkw0SFsLuZpnyjp+xoftXCf mkPdbUTxO0Is66V31+iBPD7BsCwsNKhYw68lG6GAcPCuI6EmvJQjYNcgzeg7n/+4Oc31 6BNOZ0MsEyh37HWaMQbZfNy4HXNaz4E1D/Bw1K+9z63MsjAwZZ+BeUv+GKa/LkKSgB9D dphoiXVmas1EwVOLS8FiJgd8vnnVIQy5qPHPmNTL1GbMeod6iACjQuD6IZHakceE9TIF HFyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723217151; x=1723821951; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m1k9BA+x0j9zQdUqvXd2Lf1PWPyF+I7fseNcuSuXM8Q=; b=CfcpdPQC2Is4zDTWNBTfUlnNn5PnTWpojqoQ/xEJ4Q+hUVnMM+NX4FT5L/XsWpTX/T /rApkEjE0fb2baBRFu3q/u9qA8hvk0eyNPACWKKaf/2XOhopjSraB235u3HnwXHCIqub y2EaFX0fZSHDXQyAxvjga/rhRUKZBtgX1RxxlF3gObyB4O/ZC9uRX3nweotH7O8t/n3p tWFe/Jp0624BFQtYfcuPrJvUTN+KmG9fP7SVXd07RdV/giNSlSyaq6YbPcsTwdPyUHDf JWWvCzdyOto4aaCHVldREkl5Sx6BAKj67IX6Z46yKEcjbX3nnyUIDQhG46BnnZptc4qt zCPA== X-Gm-Message-State: AOJu0Yz2eZx/cPeluMoHaeZqa6oz5TtQb/jfiVL5F2ITcRX/Xge+6jbS VgvjMRzOkH+SYb1b8CQEgSNLBBqTOK1X1nOp/8w/kiGP8orxBkKOKXotSnO8YYCYdvHsq6zzDEO S X-Google-Smtp-Source: AGHT+IEQIXqys9ssehFn/bBu321Zarpfv7V6FmelbeFRZX1S5QhlCr4QAouwdYfa+BjJrGbiy9Pp2g== X-Received: by 2002:a05:6a20:9c9a:b0:1c6:9fe9:c425 with SMTP id adf61e73a8af0-1c8a00e2d3bmr2619231637.45.1723217151150; Fri, 09 Aug 2024 08:25:51 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d1c9c5e64fsm3154091a91.0.2024.08.09.08.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 08:25:50 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v2 1/3] eal: add missing parameter check to rte_eal_alarm_set on Windows Date: Fri, 9 Aug 2024 08:24:27 -0700 Message-ID: <20240809152540.9568-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240809152540.9568-1-stephen@networkplumber.org> References: <20240808194756.167664-1-stephen@networkplumber.org> <20240809152540.9568-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Both Linux and FreeBSD, check parameters to rte_eal_alarm_set, but Windows missed this. And the test was "fixed" instead. This reverts commit a089d320338d708f5b7126dab5fd6861c82e6347. Windows EAL should have been fixed rather than papering over the bug. Signed-off-by: Stephen Hemminger --- app/test/test_alarm.c | 4 ---- lib/eal/windows/eal_alarm.c | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/test/test_alarm.c b/app/test/test_alarm.c index 70e97a3109..b4034339b8 100644 --- a/app/test/test_alarm.c +++ b/app/test/test_alarm.c @@ -10,7 +10,6 @@ #include "test.h" -#ifndef RTE_EXEC_ENV_WINDOWS static volatile int flag; static void @@ -19,7 +18,6 @@ test_alarm_callback(void *cb_arg) flag = 1; printf("Callback setting flag - OK. [cb_arg = %p]\n", cb_arg); } -#endif static int test_alarm(void) @@ -29,7 +27,6 @@ test_alarm(void) return 0; #endif -#ifndef RTE_EXEC_ENV_WINDOWS /* check if it will fail to set alarm with wrong us value */ printf("check if it will fail to set alarm with wrong ms values\n"); if (rte_eal_alarm_set(0, test_alarm_callback, @@ -42,7 +39,6 @@ test_alarm(void) printf("should not be successful with (UINT64_MAX-1) us value\n"); return -1; } -#endif /* check if it will fail to set alarm with null callback parameter */ printf("check if it will fail to set alarm with null callback parameter\n"); diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c index 052af4b21b..09a02a1cbf 100644 --- a/lib/eal/windows/eal_alarm.c +++ b/lib/eal/windows/eal_alarm.c @@ -92,6 +92,13 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg) LARGE_INTEGER deadline; int ret; + /* Check parameters, including that us won't cause a uint64_t overflow */ + if (us < 1 || us > (UINT64_MAX - US_PER_S)) { + EAL_LOG(ERR, "Invalid alarm interval"); + ret = -EINVAL; + goto exit; + } + if (cb_fn == NULL) { EAL_LOG(ERR, "NULL callback"); ret = -EINVAL; -- 2.43.0