patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 18.11] examples/fips_validation: fix buffer overflow
@ 2020-12-02 14:39 Olivier Matz
  2020-12-03 16:40 ` Kevin Traynor
  0 siblings, 1 reply; 2+ messages in thread
From: Olivier Matz @ 2020-12-02 14:39 UTC (permalink / raw)
  To: stable; +Cc: Fan Zhang

[ upstream commit 9275af3bd9faa0337b418736bb622704d158fbac ]

If the file name is larger than MAX_STRING_SIZE (64), strcpy()
will overwrite the content of memory.

Replace strcpy() by rte_strscpy(), check its return value, and
increase file_name size to 256.

Fixes: 3d0fad56b74a ("examples/fips_validation: add crypto FIPS application")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

Conflicts:
	examples/fips_validation/fips_validation.c
	examples/fips_validation/fips_validation.h

Most of the original commit has been removed, because a part of the
issue was introduced by commit efe3a8dbb66e ("examples/fips_validation:
support TDES ECB"), and it is not present in this branch.

Only the length check on the device name remains.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 examples/fips_validation/fips_validation.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index d46f72d9b8..3ea7ffaee7 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -255,7 +255,11 @@ fips_test_init(const char *req_file_path, const char *rsp_file_path,
 		return -ENOMEM;
 	}
 
-	strlcpy(info.device_name, device_name, sizeof(info.device_name));
+	if (rte_strscpy(info.device_name, device_name,
+				sizeof(info.device_name)) < 0) {
+		RTE_LOG(ERR, USER1, "Device name %s too long\n", device_name);
+		return -EINVAL;
+	}
 
 	if (fips_test_parse_header() < 0) {
 		RTE_LOG(ERR, USER1, "Failed parsing header\n");
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [PATCH 18.11] examples/fips_validation: fix buffer overflow
  2020-12-02 14:39 [dpdk-stable] [PATCH 18.11] examples/fips_validation: fix buffer overflow Olivier Matz
@ 2020-12-03 16:40 ` Kevin Traynor
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Traynor @ 2020-12-03 16:40 UTC (permalink / raw)
  To: Olivier Matz, stable; +Cc: Fan Zhang

On 02/12/2020 14:39, Olivier Matz wrote:
> [ upstream commit 9275af3bd9faa0337b418736bb622704d158fbac ]
> 
> If the file name is larger than MAX_STRING_SIZE (64), strcpy()
> will overwrite the content of memory.
> 
> Replace strcpy() by rte_strscpy(), check its return value, and
> increase file_name size to 256.
> 
> Fixes: 3d0fad56b74a ("examples/fips_validation: add crypto FIPS application")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
> 
> Conflicts:
> 	examples/fips_validation/fips_validation.c
> 	examples/fips_validation/fips_validation.h
> 
> Most of the original commit has been removed, because a part of the
> issue was introduced by commit efe3a8dbb66e ("examples/fips_validation:
> support TDES ECB"), and it is not present in this branch.
> 
> Only the length check on the device name remains.
> 
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-03 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 14:39 [dpdk-stable] [PATCH 18.11] examples/fips_validation: fix buffer overflow Olivier Matz
2020-12-03 16:40 ` Kevin Traynor

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/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 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git