From: Kevin Laatz <kevin.laatz@intel.com> To: dev@dpdk.org Cc: ferruh.yigit@intel.com, bruce.richardson@intel.com, stephen@networkplumber.org, Kevin Laatz <kevin.laatz@intel.com>, stable@dpdk.org Subject: [dpdk-dev] [PATCH v3] net/ring: fix unchecked return value Date: Tue, 13 Oct 2020 14:07:04 +0100 Message-ID: <20201013130704.1186595-1-kevin.laatz@intel.com> (raw) In-Reply-To: <20201001170902.487111-1-kevin.laatz@intel.com> Add a check for the return value of the sscanf call in parse_internal_args(), returning an error if we don't get the expected result. Coverity issue: 362049 Fixes: 96cb19521147 ("net/ring: use EAL APIs in PMD specific API") Cc: stable@dpdk.org Signed-off-by: Kevin Laatz <kevin.laatz@intel.com> --- v2: added consumed characters count check v3: add more improved checks --- drivers/net/ring/rte_eth_ring.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 40fe1ca4ba..41692305e7 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -16,6 +16,7 @@ #define ETH_RING_ACTION_CREATE "CREATE" #define ETH_RING_ACTION_ATTACH "ATTACH" #define ETH_RING_INTERNAL_ARG "internal" +#define ETH_RING_INTERNAL_ARG_MAX_LEN 19 static const char *valid_arguments[] = { ETH_RING_NUMA_NODE_ACTION_ARG, @@ -538,8 +539,21 @@ parse_internal_args(const char *key __rte_unused, const char *value, { struct ring_internal_args **internal_args = data; void *args; + int ret, n; - sscanf(value, "%p", &args); + /* make sure 'value' is valid pointer length */ + if (strnlen(value, ETH_RING_INTERNAL_ARG_MAX_LEN) >= + ETH_RING_INTERNAL_ARG_MAX_LEN) { + PMD_LOG(ERR, "Error parsing internal args, 'value' too long"); + return -1; + } + + ret = sscanf(value, "%p%n", &args, &n); + if (ret == 0 || (size_t)n != strlen(value)) { + PMD_LOG(ERR, "Error parsing internal args"); + + return -1; + } *internal_args = args; -- 2.25.1
next prev parent reply other threads:[~2020-10-13 13:11 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-22 17:20 [dpdk-dev] [PATCH] " Kevin Laatz 2020-09-23 8:06 ` David Marchand 2020-09-23 9:39 ` Bruce Richardson 2020-09-23 9:43 ` David Marchand 2020-09-23 10:04 ` Kevin Laatz 2020-09-23 10:25 ` Bruce Richardson 2020-09-25 12:43 ` Ferruh Yigit 2020-10-01 14:14 ` Kevin Laatz 2020-10-01 14:51 ` Ferruh Yigit 2020-10-01 17:09 ` [dpdk-dev] [PATCH v2] " Kevin Laatz 2020-10-12 11:57 ` Ferruh Yigit 2020-10-12 12:45 ` Bruce Richardson 2020-10-12 13:04 ` Ferruh Yigit 2020-10-12 13:11 ` Bruce Richardson 2020-10-13 13:07 ` Kevin Laatz [this message] 2020-10-13 17:23 ` [dpdk-dev] [PATCH v3] " Ferruh Yigit
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=20201013130704.1186595-1-kevin.laatz@intel.com \ --to=kevin.laatz@intel.com \ --cc=bruce.richardson@intel.com \ --cc=dev@dpdk.org \ --cc=ferruh.yigit@intel.com \ --cc=stable@dpdk.org \ --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
DPDK patches and discussions This inbox may be cloned and mirrored by anyone: git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \ dev@dpdk.org public-inbox-index dev Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.dpdk.org/inbox.dpdk.dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git