From: Jerin Jacob <jerinjacobk@gmail.com>
To: Hanumanth Pothula <hpothula@marvell.com>
Cc: Jerin Jacob <jerinj@marvell.com>,
Pavan Nikhilesh <pbhagavatula@marvell.com>,
dev@dpdk.org, hkalra@marvell.com, stephen@networkplumber.org
Subject: Re: [PATCH v4 1/1] event/octeontx: fix possible integer overflow
Date: Mon, 28 Oct 2024 21:01:53 +0530 [thread overview]
Message-ID: <CALBAE1O2cm4OovKXDZzC+fVxqifGLs8nX1=sJy-+kg7aSWDiLg@mail.gmail.com> (raw)
In-Reply-To: <20241025105802.1099531-1-hpothula@marvell.com>
[-- Attachment #1: Type: text/plain, Size: 1851 bytes --]
On Fri, Oct 25, 2024 at 4:28 PM Hanumanth Pothula <hpothula@marvell.com> wrote:
>
> The last argument passed to ssovf_parsekv() is an
> unsigned char*, but it is accessed as an integer.
> This can lead to an integer overflow.
>
> Hence, make ensure the argument is accessed as a char
> and for better error handling use strtol instead of atoi.
>
> Bugzilla ID: 1512
> Fixes: 3516327e00fd ("event/octeontx: add selftest to device arguments")
>
> Signed-off-by: Hanumanth Pothula <hpothula@marvell.com>
Missed following tag
Tested-by: Ali Alnubani <alialnu@nvidia.com>
Applied to dpdk-next-net-mrvl/for-main. Thanks
> ---
>
> v2: Use strtoul instead of strtol
> v3: Add value boundry check. Here, value can be either 0 or 1.
> v4: Commit text update
> ---
> drivers/event/octeontx/ssovf_evdev.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
> index 3a933b1db7..957fcab04e 100644
> --- a/drivers/event/octeontx/ssovf_evdev.c
> +++ b/drivers/event/octeontx/ssovf_evdev.c
> @@ -717,10 +717,20 @@ ssovf_close(struct rte_eventdev *dev)
> }
>
> static int
> -ssovf_parsekv(const char *key __rte_unused, const char *value, void *opaque)
> +ssovf_parsekv(const char *key, const char *value, void *opaque)
> {
> - int *flag = opaque;
> - *flag = !!atoi(value);
> + uint8_t *flag = opaque;
> + uint64_t v;
> + char *end;
> +
> + errno = 0;
> + v = strtoul(value, &end, 0);
> + if ((errno != 0) || (value == end) || *end != '\0' || v > 1) {
> + ssovf_log_err("invalid %s value %s", key, value);
> + return -EINVAL;
> + }
> +
> + *flag = !!v;
> return 0;
> }
>
> --
> 2.25.1
>
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 6473 bytes --]
prev parent reply other threads:[~2024-10-28 15:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 7:59 [PATCH] event/octeontx: resolve " Hanumanth Pothula
2024-10-18 16:36 ` [EXTERNAL] " Pavan Nikhilesh Bhagavatula
2024-10-18 17:35 ` Stephen Hemminger
2024-10-23 7:15 ` [PATCH v2 1/1] " Hanumanth Pothula
2024-10-23 16:16 ` Stephen Hemminger
2024-10-23 20:29 ` [EXTERNAL] " Hanumanth Reddy Pothula
2024-10-24 3:55 ` [PATCH v3 " Hanumanth Pothula
2024-10-24 7:57 ` Ali Alnubani
2024-10-25 10:27 ` Jerin Jacob
2024-10-25 10:58 ` [PATCH v4 1/1] event/octeontx: fix " Hanumanth Pothula
2024-10-28 15:31 ` Jerin Jacob [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALBAE1O2cm4OovKXDZzC+fVxqifGLs8nX1=sJy-+kg7aSWDiLg@mail.gmail.com' \
--to=jerinjacobk@gmail.com \
--cc=dev@dpdk.org \
--cc=hkalra@marvell.com \
--cc=hpothula@marvell.com \
--cc=jerinj@marvell.com \
--cc=pbhagavatula@marvell.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).