From: Bruce Richardson <bruce.richardson@intel.com>
To: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH v5 2/3] net/ice: refactor raw pattern parsing function
Date: Mon, 22 Jul 2024 16:10:36 +0100 [thread overview]
Message-ID: <Zp52bLN5H6oipOEG@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20240722135046.285868-2-vladimir.medvedkin@intel.com>
On Mon, Jul 22, 2024 at 01:50:45PM +0000, Vladimir Medvedkin wrote:
> Replace strlen with more secure strnlen in ice_hash_parse_raw_pattern.
>
> Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
>
I believe there are quite a number of other small things in this function
that could do with improvement e.g. the processing of the hex strings has
no error checks for reporting invalid (i.e. non-hex) characters.
However, this patch does improve things a bit by enhancing the length
checks, so
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> drivers/net/ice/ice_hash.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
> index 6b3095e2c5..aa76718313 100644
> --- a/drivers/net/ice/ice_hash.c
> +++ b/drivers/net/ice/ice_hash.c
> @@ -658,10 +658,13 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad,
> raw_spec = item->spec;
> raw_mask = item->mask;
>
> - spec_len = strlen((char *)(uintptr_t)raw_spec->pattern);
> - if (strlen((char *)(uintptr_t)raw_mask->pattern) !=
> - spec_len)
> - return -rte_errno;
> + spec_len = strnlen((char *)(uintptr_t)raw_spec->pattern,
> + raw_spec->length + 1);
> + if (spec_len != raw_spec->length)
> + return -EINVAL;
> + if (strnlen((char *)(uintptr_t)raw_mask->pattern, raw_spec->length + 1) !=
> + spec_len)
> + return -EINVAL;
>
> pkt_len = spec_len / 2;
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-07-22 15:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 16:59 [PATCH] net/ice: fix possible memory leak Vladimir Medvedkin
2024-07-11 17:05 ` Bruce Richardson
2024-07-11 17:07 ` Medvedkin, Vladimir
2024-07-15 18:04 ` [PATCH v2 1/3] " Vladimir Medvedkin
2024-07-15 18:04 ` [PATCH v2 2/3] net/ice: refactor raw pattern parsing function Vladimir Medvedkin
2024-07-17 11:05 ` Bruce Richardson
2024-07-15 18:04 ` [PATCH v2 3/3] net/ice: fix return value for " Vladimir Medvedkin
2024-07-17 11:06 ` Bruce Richardson
2024-07-17 11:04 ` [PATCH v2 1/3] net/ice: fix possible memory leak Bruce Richardson
2024-07-22 8:28 ` [PATCH v3 " Vladimir Medvedkin
2024-07-22 8:28 ` [PATCH v3 2/3] net/ice: refactor raw pattern parsing function Vladimir Medvedkin
2024-07-22 8:28 ` [PATCH v3 3/3] net/ice: fix return value for " Vladimir Medvedkin
2024-07-22 10:41 ` [PATCH v3 1/3] net/ice: fix possible memory leak Bruce Richardson
2024-07-22 11:00 ` Medvedkin, Vladimir
2024-07-22 10:59 ` [PATCH v4 " Vladimir Medvedkin
2024-07-22 10:59 ` [PATCH v4 2/3] net/ice: refactor raw pattern parsing function Vladimir Medvedkin
2024-07-22 11:25 ` Bruce Richardson
2024-07-22 13:51 ` Medvedkin, Vladimir
2024-07-22 10:59 ` [PATCH v4 3/3] net/ice: fix return value for " Vladimir Medvedkin
2024-07-22 13:50 ` [PATCH v5 1/3] net/ice: fix possible memory leak Vladimir Medvedkin
2024-07-22 13:50 ` [PATCH v5 2/3] net/ice: refactor raw pattern parsing function Vladimir Medvedkin
2024-07-22 15:10 ` Bruce Richardson [this message]
2024-07-22 13:50 ` [PATCH v5 3/3] net/ice: fix return value for " Vladimir Medvedkin
2024-07-22 15:11 ` Bruce Richardson
2024-07-22 15:09 ` [PATCH v5 1/3] net/ice: fix possible memory leak Bruce Richardson
2024-07-22 15:18 ` Bruce Richardson
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=Zp52bLN5H6oipOEG@bricha3-mobl1.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=vladimir.medvedkin@intel.com \
/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).