[v2] eal: unmap undesired address upon config reattach failure

Message ID 1566223064-19932-1-git-send-email-arnon@qwilt.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v2] eal: unmap undesired address upon config reattach failure |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/iol-Compile-Testing success Compile Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Arnon Warshavsky Aug. 19, 2019, 1:57 p.m. UTC
  Have rte_eal_config_reattach clean up the mapped address
which is a valid address but not the one intended.

Coverity issue: 343439
Fixes: 4e8854ae89fa ("eal: do not panic on shared memory init")
Fixes: b149a7064261 ("eal/freebsd: add config reattach in secondary")
Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---

-v2 added fixes messages and applied also to freebsd

 lib/librte_eal/freebsd/eal/eal.c | 1 +
 lib/librte_eal/linux/eal/eal.c   | 1 +
 2 files changed, 2 insertions(+)
  

Comments

Burakov, Anatoly Aug. 19, 2019, 2:48 p.m. UTC | #1
On 19-Aug-19 2:57 PM, Arnon Warshavsky wrote:
> Have rte_eal_config_reattach clean up the mapped address
> which is a valid address but not the one intended.
> 
> Coverity issue: 343439
> Fixes: 4e8854ae89fa ("eal: do not panic on shared memory init")
> Fixes: b149a7064261 ("eal/freebsd: add config reattach in secondary")
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
David Marchand Aug. 19, 2019, 3:29 p.m. UTC | #2
On Mon, Aug 19, 2019 at 3:58 PM Arnon Warshavsky <arnon@qwilt.com> wrote:
>
> Have rte_eal_config_reattach clean up the mapped address
> which is a valid address but not the one intended.
>
> Coverity issue: 343439
> Fixes: 4e8854ae89fa ("eal: do not panic on shared memory init")
> Fixes: b149a7064261 ("eal/freebsd: add config reattach in secondary")
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---
>
> -v2 added fixes messages and applied also to freebsd
>
>  lib/librte_eal/freebsd/eal/eal.c | 1 +
>  lib/librte_eal/linux/eal/eal.c   | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
> index d53f0fe..963db76 100644
> --- a/lib/librte_eal/freebsd/eal/eal.c
> +++ b/lib/librte_eal/freebsd/eal/eal.c
> @@ -341,6 +341,7 @@ enum rte_iova_mode
>                 /* errno is stale, don't use */
>                 RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config at [%p], got [%p]\n",
>                           rte_mem_cfg_addr, mem_config);
> +               munmap(mem_config, sizeof(struct rte_mem_config));
>                 return -1;
>         }
>
> diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
> index 946222c..fac69b9 100644
> --- a/lib/librte_eal/linux/eal/eal.c
> +++ b/lib/librte_eal/linux/eal/eal.c
> @@ -438,6 +438,7 @@ enum rte_iova_mode
>                         RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config at [%p], got [%p]"
>                                 " - please use '--base-virtaddr' option\n",
>                                 rte_mem_cfg_addr, mem_config);
> +                       munmap(mem_config, sizeof(struct rte_mem_config));
>                         return -1;
>                 }
>                 RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n",
> --
> 1.8.3.1
>

Thanks Arnon.
Reviewed-by: David Marchand <david.marchand@redhat.com>
  
David Marchand Oct. 15, 2019, 6:39 p.m. UTC | #3
On Mon, Aug 19, 2019 at 5:29 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> On Mon, Aug 19, 2019 at 3:58 PM Arnon Warshavsky <arnon@qwilt.com> wrote:
> >
> > Have rte_eal_config_reattach clean up the mapped address
> > which is a valid address but not the one intended.
> >
> > Coverity issue: 343439
> > Fixes: 4e8854ae89fa ("eal: do not panic on shared memory init")
> > Fixes: b149a7064261 ("eal/freebsd: add config reattach in secondary")

Fixed this title.

> > Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> > ---
> >
> > -v2 added fixes messages and applied also to freebsd
> >
> >  lib/librte_eal/freebsd/eal/eal.c | 1 +
> >  lib/librte_eal/linux/eal/eal.c   | 1 +
> >  2 files changed, 2 insertions(+)
> >
> > diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
> > index d53f0fe..963db76 100644
> > --- a/lib/librte_eal/freebsd/eal/eal.c
> > +++ b/lib/librte_eal/freebsd/eal/eal.c
> > @@ -341,6 +341,7 @@ enum rte_iova_mode
> >                 /* errno is stale, don't use */
> >                 RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config at [%p], got [%p]\n",
> >                           rte_mem_cfg_addr, mem_config);
> > +               munmap(mem_config, sizeof(struct rte_mem_config));
> >                 return -1;
> >         }
> >
> > diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
> > index 946222c..fac69b9 100644
> > --- a/lib/librte_eal/linux/eal/eal.c
> > +++ b/lib/librte_eal/linux/eal/eal.c
> > @@ -438,6 +438,7 @@ enum rte_iova_mode
> >                         RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config at [%p], got [%p]"
> >                                 " - please use '--base-virtaddr' option\n",
> >                                 rte_mem_cfg_addr, mem_config);
> > +                       munmap(mem_config, sizeof(struct rte_mem_config));
> >                         return -1;
> >                 }
> >                 RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n",
> > --
> > 1.8.3.1
> >
>
> Thanks Arnon.
> Reviewed-by: David Marchand <david.marchand@redhat.com>

Applied, thanks.


--
David Marchand
  

Patch

diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index d53f0fe..963db76 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -341,6 +341,7 @@  enum rte_iova_mode
 		/* errno is stale, don't use */
 		RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config at [%p], got [%p]\n",
 			  rte_mem_cfg_addr, mem_config);
+		munmap(mem_config, sizeof(struct rte_mem_config));
 		return -1;
 	}
 
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 946222c..fac69b9 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -438,6 +438,7 @@  enum rte_iova_mode
 			RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config at [%p], got [%p]"
 				" - please use '--base-virtaddr' option\n",
 				rte_mem_cfg_addr, mem_config);
+			munmap(mem_config, sizeof(struct rte_mem_config));
 			return -1;
 		}
 		RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n",