patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] ipc: fix undefined behavior in no-shconf mode
@ 2018-10-24 10:05 Darek Stojaczyk
  2018-10-24 10:20 ` Burakov, Anatoly
  0 siblings, 1 reply; 3+ messages in thread
From: Darek Stojaczyk @ 2018-10-24 10:05 UTC (permalink / raw)
  To: dev; +Cc: Darek Stojaczyk, anatoly.burakov, stable

In no-shconf mode the rte_mp_request_sync() wasn't initializing
the `reply` parameter, which contained e.g. a number of sent
requests. Callers of rte_mp_request_sync() might check that
param afterwards and might read potentially unitialized memory.

The no-shconf check that makes us return early (with rc = 0) was
placed before the `reply` initialization. Fix this by making the
`reply` initialization occur first.

Fixes: 5848e3d2813c ("ipc: support --no-shconf mode")
Cc: anatoly.burakov@intel.com
Cc: stable@dpdk.org

Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
---
 lib/librte_eal/common/eal_common_proc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
index 9fcb91219..97663d3ba 100644
--- a/lib/librte_eal/common/eal_common_proc.c
+++ b/lib/librte_eal/common/eal_common_proc.c
@@ -939,13 +939,17 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply,
 	if (check_input(req) == false)
 		return -1;
 
+	reply->nb_sent = 0;
+	reply->nb_received = 0;
+	reply->msgs = NULL;
+
 	if (internal_config.no_shconf) {
 		RTE_LOG(DEBUG, EAL, "No shared files mode enabled, IPC is disabled\n");
 		return 0;
 	}
 
 	if (gettimeofday(&now, NULL) < 0) {
-		RTE_LOG(ERR, EAL, "Faile to get current time\n");
+		RTE_LOG(ERR, EAL, "Failed to get current time\n");
 		rte_errno = errno;
 		return -1;
 	}
@@ -954,10 +958,6 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply,
 	end.tv_sec = now.tv_sec + ts->tv_sec +
 			(now.tv_usec * 1000 + ts->tv_nsec) / 1000000000;
 
-	reply->nb_sent = 0;
-	reply->nb_received = 0;
-	reply->msgs = NULL;
-
 	/* for secondary process, send request to the primary process only */
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
 		pthread_mutex_lock(&pending_requests.lock);
-- 
2.17.1

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

* Re: [dpdk-stable] [PATCH] ipc: fix undefined behavior in no-shconf mode
  2018-10-24 10:05 [dpdk-stable] [PATCH] ipc: fix undefined behavior in no-shconf mode Darek Stojaczyk
@ 2018-10-24 10:20 ` Burakov, Anatoly
  2018-10-24 14:47   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Burakov, Anatoly @ 2018-10-24 10:20 UTC (permalink / raw)
  To: Darek Stojaczyk, dev; +Cc: stable

On 24-Oct-18 11:05 AM, Darek Stojaczyk wrote:
> In no-shconf mode the rte_mp_request_sync() wasn't initializing
> the `reply` parameter, which contained e.g. a number of sent
> requests. Callers of rte_mp_request_sync() might check that
> param afterwards and might read potentially unitialized memory.
> 
> The no-shconf check that makes us return early (with rc = 0) was
> placed before the `reply` initialization. Fix this by making the
> `reply` initialization occur first.
> 
> Fixes: 5848e3d2813c ("ipc: support --no-shconf mode")
> Cc: anatoly.burakov@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

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

* Re: [dpdk-stable] [PATCH] ipc: fix undefined behavior in no-shconf mode
  2018-10-24 10:20 ` Burakov, Anatoly
@ 2018-10-24 14:47   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-10-24 14:47 UTC (permalink / raw)
  To: Darek Stojaczyk; +Cc: stable, Burakov, Anatoly, dev

24/10/2018 12:20, Burakov, Anatoly:
> On 24-Oct-18 11:05 AM, Darek Stojaczyk wrote:
> > In no-shconf mode the rte_mp_request_sync() wasn't initializing
> > the `reply` parameter, which contained e.g. a number of sent
> > requests. Callers of rte_mp_request_sync() might check that
> > param afterwards and might read potentially unitialized memory.
> > 
> > The no-shconf check that makes us return early (with rc = 0) was
> > placed before the `reply` initialization. Fix this by making the
> > `reply` initialization occur first.
> > 
> > Fixes: 5848e3d2813c ("ipc: support --no-shconf mode")
> > Cc: anatoly.burakov@intel.com
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
> > ---
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

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

end of thread, other threads:[~2018-10-24 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24 10:05 [dpdk-stable] [PATCH] ipc: fix undefined behavior in no-shconf mode Darek Stojaczyk
2018-10-24 10:20 ` Burakov, Anatoly
2018-10-24 14:47   ` 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).