* [dpdk-stable] [PATCH v2] eal/windows: enforce alarm APIs parameter check
[not found] <1624495001-16613-1-git-send-email-jizh@linux.microsoft.com>
@ 2021-07-07 20:25 ` Jie Zhou
2021-07-21 15:28 ` Dmitry Kozlyuk
0 siblings, 1 reply; 3+ messages in thread
From: Jie Zhou @ 2021-07-07 20:25 UTC (permalink / raw)
To: dev
Cc: dmitry.kozliuk, roretzla, talshn, pallavi.kadam, navasile,
dmitrym, david.marchand, stable
eal/windows alarm APIs rte_eal_alarm_set and rte_eal_alarm_cancel
did not check parameters to fail fast for invalid parameters, which
caught by DPDK UT alarm_autotest.
Enforce eal/windows alarm APIs parameter check to fail fast for
invalid parameters.
Fixes: f4cbdbc7fbd2 ("eal/windows: implement alarm API")
Cc: stable@dpdk.org
Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
---
V2 changes:
- Remove API parameter check on arbitrary 'us' range
- Do explicit NULL cb_fn check
---
lib/eal/windows/eal_alarm.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c
index f5bf88715a..e5dc54efb8 100644
--- a/lib/eal/windows/eal_alarm.c
+++ b/lib/eal/windows/eal_alarm.c
@@ -91,6 +91,12 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
LARGE_INTEGER deadline;
int ret;
+ if (cb_fn == NULL) {
+ RTE_LOG(ERR, EAL, "NULL callback\n");
+ ret = -EINVAL;
+ goto exit;
+ }
+
/* Calculate deadline ASAP, unit of measure = 100ns. */
GetSystemTimePreciseAsFileTime(&ft);
deadline.LowPart = ft.dwLowDateTime;
@@ -180,6 +186,12 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
bool executing;
removed = 0;
+
+ if (cb_fn == NULL) {
+ RTE_LOG(ERR, EAL, "NULL callback\n");
+ return -EINVAL;
+ }
+
do {
executing = false;
--
2.31.0.vfs.0.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-stable] [PATCH v2] eal/windows: enforce alarm APIs parameter check
2021-07-07 20:25 ` [dpdk-stable] [PATCH v2] eal/windows: enforce alarm APIs parameter check Jie Zhou
@ 2021-07-21 15:28 ` Dmitry Kozlyuk
2021-07-22 20:06 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Kozlyuk @ 2021-07-21 15:28 UTC (permalink / raw)
To: Jie Zhou
Cc: dev, roretzla, talshn, pallavi.kadam, navasile, dmitrym,
david.marchand, stable
2021-07-07 13:25 (UTC-0700), Jie Zhou:
> eal/windows alarm APIs rte_eal_alarm_set and rte_eal_alarm_cancel
> did not check parameters to fail fast for invalid parameters, which
> caught by DPDK UT alarm_autotest.
>
> Enforce eal/windows alarm APIs parameter check to fail fast for
> invalid parameters.
>
> Fixes: f4cbdbc7fbd2 ("eal/windows: implement alarm API")
> Cc: stable@dpdk.org
>
> Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
>
> ---
> V2 changes:
> - Remove API parameter check on arbitrary 'us' range
> - Do explicit NULL cb_fn check
>
> ---
> lib/eal/windows/eal_alarm.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c
> index f5bf88715a..e5dc54efb8 100644
> --- a/lib/eal/windows/eal_alarm.c
> +++ b/lib/eal/windows/eal_alarm.c
> @@ -91,6 +91,12 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
> LARGE_INTEGER deadline;
> int ret;
>
> + if (cb_fn == NULL) {
> + RTE_LOG(ERR, EAL, "NULL callback\n");
> + ret = -EINVAL;
> + goto exit;
> + }
> +
> /* Calculate deadline ASAP, unit of measure = 100ns. */
> GetSystemTimePreciseAsFileTime(&ft);
> deadline.LowPart = ft.dwLowDateTime;
> @@ -180,6 +186,12 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
> bool executing;
>
> removed = 0;
> +
> + if (cb_fn == NULL) {
> + RTE_LOG(ERR, EAL, "NULL callback\n");
> + return -EINVAL;
> + }
> +
> do {
> executing = false;
>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] eal/windows: enforce alarm APIs parameter check
2021-07-21 15:28 ` Dmitry Kozlyuk
@ 2021-07-22 20:06 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2021-07-22 20:06 UTC (permalink / raw)
To: Jie Zhou
Cc: dev, roretzla, talshn, pallavi.kadam, navasile, dmitrym,
david.marchand, stable, Dmitry Kozlyuk
21/07/2021 17:28, Dmitry Kozlyuk:
> 2021-07-07 13:25 (UTC-0700), Jie Zhou:
> > eal/windows alarm APIs rte_eal_alarm_set and rte_eal_alarm_cancel
> > did not check parameters to fail fast for invalid parameters, which
> > caught by DPDK UT alarm_autotest.
> >
> > Enforce eal/windows alarm APIs parameter check to fail fast for
> > invalid parameters.
> >
> > Fixes: f4cbdbc7fbd2 ("eal/windows: implement alarm API")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
>
> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Applied with title "eal/windows: check callback parameter of alarm functions"
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-22 20:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1624495001-16613-1-git-send-email-jizh@linux.microsoft.com>
2021-07-07 20:25 ` [dpdk-stable] [PATCH v2] eal/windows: enforce alarm APIs parameter check Jie Zhou
2021-07-21 15:28 ` Dmitry Kozlyuk
2021-07-22 20:06 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).