DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal: fix out of bound access when no cpu is available
@ 2019-01-17 13:12 David Marchand
  2019-01-17 16:34 ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: David Marchand @ 2019-01-17 13:12 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, solal.pirelli

In the unlikely case when the dpdk application is started with no cpu
available in the [0, RTE_MAX_LCORE - 1] range, the master_lcore is
automatically chosen as RTE_MAX_LCORE which triggers an out of bound
access.

Either you have a crash then, or the initialisation fails later when
trying to pin the master thread on it.
In my test, with RTE_MAX_LCORE == 2:

$ taskset -c 2 ./master/app/testpmd --no-huge -m 512 --log-level *:debug
[...]
EAL: pthread_setaffinity_np failed
PANIC in eal_thread_init_master():
cannot set affinity
7: [./master/app/testpmd() [0x47f629]]

Bugzilla ID: 19
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/common/eal_common_options.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 3796dbf..7aad303 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -1383,6 +1383,8 @@ static int xdigit2val(unsigned char c)
 	/* default master lcore is the first one */
 	if (!master_lcore_parsed) {
 		cfg->master_lcore = rte_get_next_lcore(-1, 0, 0);
+		if (cfg->master_lcore >= RTE_MAX_LCORE)
+			return -1;
 		lcore_config[cfg->master_lcore].core_role = ROLE_RTE;
 	}
 
-- 
1.8.3.1

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

* Re: [dpdk-dev] [PATCH] eal: fix out of bound access when no cpu is available
  2019-01-17 13:12 [dpdk-dev] [PATCH] eal: fix out of bound access when no cpu is available David Marchand
@ 2019-01-17 16:34 ` Thomas Monjalon
  2019-01-17 17:17   ` David Marchand
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2019-01-17 16:34 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, bruce.richardson, solal.pirelli

17/01/2019 14:12, David Marchand:
> In the unlikely case when the dpdk application is started with no cpu
> available in the [0, RTE_MAX_LCORE - 1] range, the master_lcore is
> automatically chosen as RTE_MAX_LCORE which triggers an out of bound
> access.
> 
> Either you have a crash then, or the initialisation fails later when
> trying to pin the master thread on it.
> In my test, with RTE_MAX_LCORE == 2:
> 
> $ taskset -c 2 ./master/app/testpmd --no-huge -m 512 --log-level *:debug
> [...]
> EAL: pthread_setaffinity_np failed
> PANIC in eal_thread_init_master():
> cannot set affinity
> 7: [./master/app/testpmd() [0x47f629]]
> 
> Bugzilla ID: 19
> Signed-off-by: David Marchand <david.marchand@redhat.com>

We should backport this fix.
When this bug has been introduced?

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

* Re: [dpdk-dev] [PATCH] eal: fix out of bound access when no cpu is available
  2019-01-17 16:34 ` Thomas Monjalon
@ 2019-01-17 17:17   ` David Marchand
  2019-01-17 17:38     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: David Marchand @ 2019-01-17 17:17 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Bruce Richardson, solal.pirelli, dpdk stable

On Thu, Jan 17, 2019 at 5:34 PM Thomas Monjalon <thomas@monjalon.net> wrote:

> 17/01/2019 14:12, David Marchand:
> > In the unlikely case when the dpdk application is started with no cpu
> > available in the [0, RTE_MAX_LCORE - 1] range, the master_lcore is
> > automatically chosen as RTE_MAX_LCORE which triggers an out of bound
> > access.
> >
> > Either you have a crash then, or the initialisation fails later when
> > trying to pin the master thread on it.
> > In my test, with RTE_MAX_LCORE == 2:
> >
> > $ taskset -c 2 ./master/app/testpmd --no-huge -m 512 --log-level *:debug
> > [...]
> > EAL: pthread_setaffinity_np failed
> > PANIC in eal_thread_init_master():
> > cannot set affinity
> > 7: [./master/app/testpmd() [0x47f629]]
> >
> > Bugzilla ID: 19
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
>
> We should backport this fix.
> When this bug has been introduced?
>

Indeed, at first, I thought the problem had always been there, but it
should be starting 17.02:
Fixes: 2eba8d21f3c9 ("eal: restrict cores auto detection")

+ CC stable

Do you want a v2 ?


-- 
David Marchand

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

* Re: [dpdk-dev] [PATCH] eal: fix out of bound access when no cpu is available
  2019-01-17 17:17   ` David Marchand
@ 2019-01-17 17:38     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2019-01-17 17:38 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Bruce Richardson, solal.pirelli, dpdk stable

17/01/2019 18:17, David Marchand:
> On Thu, Jan 17, 2019 at 5:34 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > 17/01/2019 14:12, David Marchand:
> > > In the unlikely case when the dpdk application is started with no cpu
> > > available in the [0, RTE_MAX_LCORE - 1] range, the master_lcore is
> > > automatically chosen as RTE_MAX_LCORE which triggers an out of bound
> > > access.
> > >
> > > Either you have a crash then, or the initialisation fails later when
> > > trying to pin the master thread on it.
> > > In my test, with RTE_MAX_LCORE == 2:
> > >
> > > $ taskset -c 2 ./master/app/testpmd --no-huge -m 512 --log-level *:debug
> > > [...]
> > > EAL: pthread_setaffinity_np failed
> > > PANIC in eal_thread_init_master():
> > > cannot set affinity
> > > 7: [./master/app/testpmd() [0x47f629]]
> > >
> > > Bugzilla ID: 19
> > > Signed-off-by: David Marchand <david.marchand@redhat.com>
> >
> > We should backport this fix.
> > When this bug has been introduced?
> >
> 
> Indeed, at first, I thought the problem had always been there, but it
> should be starting 17.02:
> Fixes: 2eba8d21f3c9 ("eal: restrict cores auto detection")
> 
> + CC stable
> 
> Do you want a v2 ?

Applied, thanks

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

end of thread, other threads:[~2019-01-17 17:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17 13:12 [dpdk-dev] [PATCH] eal: fix out of bound access when no cpu is available David Marchand
2019-01-17 16:34 ` Thomas Monjalon
2019-01-17 17:17   ` David Marchand
2019-01-17 17:38     ` 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).