patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] lib/cmdline: release cl when cmdline exit
@ 2021-08-31  2:28 zhihongx.peng
  2021-08-31 16:59 ` [dpdk-stable] [dpdk-dev] " Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: zhihongx.peng @ 2021-08-31  2:28 UTC (permalink / raw)
  To: olivier.matz; +Cc: dev, Zhihong Peng, stable

From: Zhihong Peng <zhihongx.peng@intel.com>

Malloc cl in the cmdline_stdin_new function, so release in the
cmdline_stdin_exit function is logical, so that cl will not be
released alone.

Fixes: af75078fece3 (first public release)
Cc: stable@dpdk.org

Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
---
 lib/cmdline/cmdline_socket.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
index 998e8ade25..ebd5343754 100644
--- a/lib/cmdline/cmdline_socket.c
+++ b/lib/cmdline/cmdline_socket.c
@@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
 		return;
 
 	terminal_restore(cl);
+	cmdline_free(cl);
 }
-- 
2.25.1


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
  2021-08-31  2:28 [dpdk-stable] [PATCH] lib/cmdline: release cl when cmdline exit zhihongx.peng
@ 2021-08-31 16:59 ` Stephen Hemminger
  2021-09-06  5:45   ` Peng, ZhihongX
  2021-08-31 17:52 ` Dmitry Kozlyuk
  2021-09-17  2:15 ` [dpdk-stable] [PATCH v2 1/2] " zhihongx.peng
  2 siblings, 1 reply; 24+ messages in thread
From: Stephen Hemminger @ 2021-08-31 16:59 UTC (permalink / raw)
  To: zhihongx.peng; +Cc: olivier.matz, dev, stable

On Tue, 31 Aug 2021 10:28:44 +0800
zhihongx.peng@intel.com wrote:

> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Malloc cl in the cmdline_stdin_new function, so release in the
> cmdline_stdin_exit function is logical, so that cl will not be
> released alone.
> 
> Fixes: af75078fece3 (first public release)
> Cc: stable@dpdk.org
> 
> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> ---
>  lib/cmdline/cmdline_socket.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
> index 998e8ade25..ebd5343754 100644
> --- a/lib/cmdline/cmdline_socket.c
> +++ b/lib/cmdline/cmdline_socket.c
> @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
>  		return;
>  
>  	terminal_restore(cl);
> +	cmdline_free(cl);
>  }

How did you find this? valgrind? address-sanitizer?

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
  2021-08-31  2:28 [dpdk-stable] [PATCH] lib/cmdline: release cl when cmdline exit zhihongx.peng
  2021-08-31 16:59 ` [dpdk-stable] [dpdk-dev] " Stephen Hemminger
@ 2021-08-31 17:52 ` Dmitry Kozlyuk
  2021-09-06  5:51   ` Peng, ZhihongX
  2021-09-17  2:15 ` [dpdk-stable] [PATCH v2 1/2] " zhihongx.peng
  2 siblings, 1 reply; 24+ messages in thread
From: Dmitry Kozlyuk @ 2021-08-31 17:52 UTC (permalink / raw)
  To: zhihongx.peng; +Cc: olivier.matz, dev, stable

2021-08-31 10:28 (UTC+0800), zhihongx.peng@intel.com:
> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Malloc cl in the cmdline_stdin_new function, so release in the
> cmdline_stdin_exit function is logical, so that cl will not be
> released alone.
> 
> Fixes: af75078fece3 (first public release)
> Cc: stable@dpdk.org
> 
> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> ---
>  lib/cmdline/cmdline_socket.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
> index 998e8ade25..ebd5343754 100644
> --- a/lib/cmdline/cmdline_socket.c
> +++ b/lib/cmdline/cmdline_socket.c
> @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
>  		return;
>  
>  	terminal_restore(cl);
> +	cmdline_free(cl);
>  }

Now cmdline_free() may not be called after cmdline_stdin_exit().
User code that does so needs to be changed to avoid double-free.
This behavior change must be documented in the release notes.
I'm not sure it should be backported because of the above.


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
  2021-08-31 16:59 ` [dpdk-stable] [dpdk-dev] " Stephen Hemminger
@ 2021-09-06  5:45   ` Peng, ZhihongX
  0 siblings, 0 replies; 24+ messages in thread
From: Peng, ZhihongX @ 2021-09-06  5:45 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: olivier.matz, dev, stable



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Wednesday, September 1, 2021 12:59 AM
> To: Peng, ZhihongX <zhihongx.peng@intel.com>
> Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
> 
> On Tue, 31 Aug 2021 10:28:44 +0800
> zhihongx.peng@intel.com wrote:
> 
> > From: Zhihong Peng <zhihongx.peng@intel.com>
> >
> > Malloc cl in the cmdline_stdin_new function, so release in the
> > cmdline_stdin_exit function is logical, so that cl will not be
> > released alone.
> >
> > Fixes: af75078fece3 (first public release)
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> > ---
> >  lib/cmdline/cmdline_socket.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/cmdline/cmdline_socket.c
> > b/lib/cmdline/cmdline_socket.c index 998e8ade25..ebd5343754 100644
> > --- a/lib/cmdline/cmdline_socket.c
> > +++ b/lib/cmdline/cmdline_socket.c
> > @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
> >  		return;
> >
> >  	terminal_restore(cl);
> > +	cmdline_free(cl);
> >  }
> 
> How did you find this? valgrind? address-sanitizer?
Use address-sanitizer.

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
  2021-08-31 17:52 ` Dmitry Kozlyuk
@ 2021-09-06  5:51   ` Peng, ZhihongX
  2021-09-06  7:33     ` Dmitry Kozlyuk
  0 siblings, 1 reply; 24+ messages in thread
From: Peng, ZhihongX @ 2021-09-06  5:51 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: olivier.matz, dev, stable



> -----Original Message-----
> From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Sent: Wednesday, September 1, 2021 1:52 AM
> To: Peng, ZhihongX <zhihongx.peng@intel.com>
> Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
> 
> 2021-08-31 10:28 (UTC+0800), zhihongx.peng@intel.com:
> > From: Zhihong Peng <zhihongx.peng@intel.com>
> >
> > Malloc cl in the cmdline_stdin_new function, so release in the
> > cmdline_stdin_exit function is logical, so that cl will not be
> > released alone.
> >
> > Fixes: af75078fece3 (first public release)
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> > ---
> >  lib/cmdline/cmdline_socket.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/cmdline/cmdline_socket.c
> > b/lib/cmdline/cmdline_socket.c index 998e8ade25..ebd5343754 100644
> > --- a/lib/cmdline/cmdline_socket.c
> > +++ b/lib/cmdline/cmdline_socket.c
> > @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
> >  		return;
> >
> >  	terminal_restore(cl);
> > +	cmdline_free(cl);
> >  }
> 
> Now cmdline_free() may not be called after cmdline_stdin_exit().
> User code that does so needs to be changed to avoid double-free.
> This behavior change must be documented in the release notes.
> I'm not sure it should be backported because of the above.
Using the asan tool, I found that many dpdk apps did not call cmdline_free, only one app called.


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
  2021-09-06  5:51   ` Peng, ZhihongX
@ 2021-09-06  7:33     ` Dmitry Kozlyuk
  2021-09-30  6:53       ` Peng, ZhihongX
  0 siblings, 1 reply; 24+ messages in thread
From: Dmitry Kozlyuk @ 2021-09-06  7:33 UTC (permalink / raw)
  To: Peng, ZhihongX; +Cc: olivier.matz, dev, stable

2021-09-06 05:51 (UTC+0000), Peng, ZhihongX:
> > -----Original Message-----
> > From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > Sent: Wednesday, September 1, 2021 1:52 AM
> > To: Peng, ZhihongX <zhihongx.peng@intel.com>
> > Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
> > 
> > 2021-08-31 10:28 (UTC+0800), zhihongx.peng@intel.com:  
> > > From: Zhihong Peng <zhihongx.peng@intel.com>
> > >
> > > Malloc cl in the cmdline_stdin_new function, so release in the
> > > cmdline_stdin_exit function is logical, so that cl will not be
> > > released alone.
> > >
> > > Fixes: af75078fece3 (first public release)
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> > > ---
> > >  lib/cmdline/cmdline_socket.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/lib/cmdline/cmdline_socket.c
> > > b/lib/cmdline/cmdline_socket.c index 998e8ade25..ebd5343754 100644
> > > --- a/lib/cmdline/cmdline_socket.c
> > > +++ b/lib/cmdline/cmdline_socket.c
> > > @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
> > >  		return;
> > >
> > >  	terminal_restore(cl);
> > > +	cmdline_free(cl);
> > >  }  
> > 
> > Now cmdline_free() may not be called after cmdline_stdin_exit().
> > User code that does so needs to be changed to avoid double-free.
> > This behavior change must be documented in the release notes.
> > I'm not sure it should be backported because of the above.  
> Using the asan tool, I found that many dpdk apps did not call cmdline_free, only one app called.

I mean external programs that use DPDK, not DPDK bundled apps only.
If some of them use a stable DPDK branch and the change is backported,
a double-free will be introduced by upgrading DPDK to a minor version.
Users of current DPDK version that call cmdline_free() after
cmdline_stdin_exit() will have to upgrade their code,
release notes are the place to inform them about this need.
The patch itself is good and now it is the right time for it.

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

* [dpdk-stable] [PATCH v2 1/2] lib/cmdline: release cl when cmdline exit
  2021-08-31  2:28 [dpdk-stable] [PATCH] lib/cmdline: release cl when cmdline exit zhihongx.peng
  2021-08-31 16:59 ` [dpdk-stable] [dpdk-dev] " Stephen Hemminger
  2021-08-31 17:52 ` Dmitry Kozlyuk
@ 2021-09-17  2:15 ` zhihongx.peng
  2021-09-17  2:15   ` [dpdk-stable] [PATCH v2 2/2] app/test: Delete cmdline free function zhihongx.peng
  2021-09-30  6:47   ` [dpdk-stable] [PATCH v2 " Peng, ZhihongX
  2 siblings, 2 replies; 24+ messages in thread
From: zhihongx.peng @ 2021-09-17  2:15 UTC (permalink / raw)
  To: olivier.matz, stephen; +Cc: dev, Zhihong Peng, stable

From: Zhihong Peng <zhihongx.peng@intel.com>

Malloc cl in the cmdline_stdin_new function, so release in the
cmdline_stdin_exit function is logical, so that cl will not be
released alone.

Fixes: af75078fece3 (first public release)
Cc: stable@dpdk.org

Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
---
 lib/cmdline/cmdline_socket.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
index 998e8ade25..ebd5343754 100644
--- a/lib/cmdline/cmdline_socket.c
+++ b/lib/cmdline/cmdline_socket.c
@@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
 		return;
 
 	terminal_restore(cl);
+	cmdline_free(cl);
 }
-- 
2.25.1


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

* [dpdk-stable] [PATCH v2 2/2] app/test: Delete cmdline free function
  2021-09-17  2:15 ` [dpdk-stable] [PATCH v2 1/2] " zhihongx.peng
@ 2021-09-17  2:15   ` zhihongx.peng
  2021-10-08  6:41     ` [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit zhihongx.peng
  2021-09-30  6:47   ` [dpdk-stable] [PATCH v2 " Peng, ZhihongX
  1 sibling, 1 reply; 24+ messages in thread
From: zhihongx.peng @ 2021-09-17  2:15 UTC (permalink / raw)
  To: olivier.matz, stephen; +Cc: dev, Zhihong Peng, stable

From: Zhihong Peng <zhihongx.peng@intel.com>

Cmdline will be released in cmdline_stdin_exit function,
so it does not need to be released here.

Fixes: acdabc450ea0 (test: fix terminal settings on exit)
Cc: stable@dpdk.org

Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
---
 app/test/test.c             | 1 -
 app/test/test_cmdline_lib.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/app/test/test.c b/app/test/test.c
index 173d202e47..5194131026 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -233,7 +233,6 @@ main(int argc, char **argv)
 
 		cmdline_interact(cl);
 		cmdline_stdin_exit(cl);
-		cmdline_free(cl);
 	}
 #endif
 	ret = 0;
diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c
index d5a09b4541..6bcfa6511e 100644
--- a/app/test/test_cmdline_lib.c
+++ b/app/test/test_cmdline_lib.c
@@ -174,7 +174,6 @@ test_cmdline_socket_fns(void)
 	/* void functions */
 	cmdline_stdin_exit(NULL);
 
-	cmdline_free(cl);
 	return 0;
 error:
 	printf("Error: function accepted null parameter!\n");
-- 
2.25.1


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

* Re: [dpdk-stable] [PATCH v2 1/2] lib/cmdline: release cl when cmdline exit
  2021-09-17  2:15 ` [dpdk-stable] [PATCH v2 1/2] " zhihongx.peng
  2021-09-17  2:15   ` [dpdk-stable] [PATCH v2 2/2] app/test: Delete cmdline free function zhihongx.peng
@ 2021-09-30  6:47   ` Peng, ZhihongX
  1 sibling, 0 replies; 24+ messages in thread
From: Peng, ZhihongX @ 2021-09-30  6:47 UTC (permalink / raw)
  To: olivier.matz, stephen; +Cc: dev, stable

> -----Original Message-----
> From: Peng, ZhihongX <zhihongx.peng@intel.com>
> Sent: Friday, September 17, 2021 10:15 AM
> To: olivier.matz@6wind.com; stephen@networkplumber.org
> Cc: dev@dpdk.org; Peng, ZhihongX <zhihongx.peng@intel.com>;
> stable@dpdk.org
> Subject: [PATCH v2 1/2] lib/cmdline: release cl when cmdline exit
> 
> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Malloc cl in the cmdline_stdin_new function, so release in the
> cmdline_stdin_exit function is logical, so that cl will not be released alone.
> 
> Fixes: af75078fece3 (first public release)
> Cc: stable@dpdk.org
> 
> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> ---
>  lib/cmdline/cmdline_socket.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
> index 998e8ade25..ebd5343754 100644
> --- a/lib/cmdline/cmdline_socket.c
> +++ b/lib/cmdline/cmdline_socket.c
> @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
>  		return;
> 
>  	terminal_restore(cl);
> +	cmdline_free(cl);
>  }
> --
> 2.25.1

Tested-by: Zhihong Peng <zhihongx.peng@intel.com>

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
  2021-09-06  7:33     ` Dmitry Kozlyuk
@ 2021-09-30  6:53       ` Peng, ZhihongX
  2021-09-30  7:44         ` Dmitry Kozlyuk
  0 siblings, 1 reply; 24+ messages in thread
From: Peng, ZhihongX @ 2021-09-30  6:53 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: olivier.matz, dev, stable

> -----Original Message-----
> From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Sent: Monday, September 6, 2021 3:34 PM
> To: Peng, ZhihongX <zhihongx.peng@intel.com>
> Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
> 
> 2021-09-06 05:51 (UTC+0000), Peng, ZhihongX:
> > > -----Original Message-----
> > > From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > > Sent: Wednesday, September 1, 2021 1:52 AM
> > > To: Peng, ZhihongX <zhihongx.peng@intel.com>
> > > Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> > > Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline
> > > exit
> > >
> > > 2021-08-31 10:28 (UTC+0800), zhihongx.peng@intel.com:
> > > > From: Zhihong Peng <zhihongx.peng@intel.com>
> > > >
> > > > Malloc cl in the cmdline_stdin_new function, so release in the
> > > > cmdline_stdin_exit function is logical, so that cl will not be
> > > > released alone.
> > > >
> > > > Fixes: af75078fece3 (first public release)
> > > > Cc: stable@dpdk.org
> > > >
> > > > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> > > > ---
> > > >  lib/cmdline/cmdline_socket.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/lib/cmdline/cmdline_socket.c
> > > > b/lib/cmdline/cmdline_socket.c index 998e8ade25..ebd5343754 100644
> > > > --- a/lib/cmdline/cmdline_socket.c
> > > > +++ b/lib/cmdline/cmdline_socket.c
> > > > @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
> > > >  		return;
> > > >
> > > >  	terminal_restore(cl);
> > > > +	cmdline_free(cl);
> > > >  }
> > >
> > > Now cmdline_free() may not be called after cmdline_stdin_exit().
> > > User code that does so needs to be changed to avoid double-free.
> > > This behavior change must be documented in the release notes.
> > > I'm not sure it should be backported because of the above.
> > Using the asan tool, I found that many dpdk apps did not call cmdline_free,
> only one app called.
> 
> I mean external programs that use DPDK, not DPDK bundled apps only.
> If some of them use a stable DPDK branch and the change is backported, a
> double-free will be introduced by upgrading DPDK to a minor version.
> Users of current DPDK version that call cmdline_free() after
> cmdline_stdin_exit() will have to upgrade their code, release notes are the
> place to inform them about this need.
> The patch itself is good and now it is the right time for it.

Can you give me an ack, I have submitted v2:
http://patches.dpdk.org/project/dpdk/patch/20210917021502.502560-1-zhihongx.peng@intel.com/

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
  2021-09-30  6:53       ` Peng, ZhihongX
@ 2021-09-30  7:44         ` Dmitry Kozlyuk
  2021-10-08  6:55           ` Peng, ZhihongX
  0 siblings, 1 reply; 24+ messages in thread
From: Dmitry Kozlyuk @ 2021-09-30  7:44 UTC (permalink / raw)
  To: Peng, ZhihongX, olivier.matz; +Cc: dev, stable

2021-09-30 06:53 (UTC+0000), Peng, ZhihongX:
> > -----Original Message-----
> > From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > Sent: Monday, September 6, 2021 3:34 PM
> > To: Peng, ZhihongX <zhihongx.peng@intel.com>
> > Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
> > 
> > 2021-09-06 05:51 (UTC+0000), Peng, ZhihongX:  
> > > > -----Original Message-----
> > > > From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > > > Sent: Wednesday, September 1, 2021 1:52 AM
> > > > To: Peng, ZhihongX <zhihongx.peng@intel.com>
> > > > Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> > > > Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline
> > > > exit
> > > >
> > > > 2021-08-31 10:28 (UTC+0800), zhihongx.peng@intel.com:  
> > > > > From: Zhihong Peng <zhihongx.peng@intel.com>
> > > > >
> > > > > Malloc cl in the cmdline_stdin_new function, so release in the
> > > > > cmdline_stdin_exit function is logical, so that cl will not be
> > > > > released alone.
> > > > >
> > > > > Fixes: af75078fece3 (first public release)
> > > > > Cc: stable@dpdk.org
> > > > >
> > > > > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> > > > > ---
> > > > >  lib/cmdline/cmdline_socket.c | 1 +
> > > > >  1 file changed, 1 insertion(+)
> > > > >
> > > > > diff --git a/lib/cmdline/cmdline_socket.c
> > > > > b/lib/cmdline/cmdline_socket.c index 998e8ade25..ebd5343754 100644
> > > > > --- a/lib/cmdline/cmdline_socket.c
> > > > > +++ b/lib/cmdline/cmdline_socket.c
> > > > > @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
> > > > >  		return;
> > > > >
> > > > >  	terminal_restore(cl);
> > > > > +	cmdline_free(cl);
> > > > >  }  
> > > >
> > > > Now cmdline_free() may not be called after cmdline_stdin_exit().
> > > > User code that does so needs to be changed to avoid double-free.
> > > > This behavior change must be documented in the release notes.
> > > > I'm not sure it should be backported because of the above.  
> > > Using the asan tool, I found that many dpdk apps did not call cmdline_free,  
> > only one app called.
> > 
> > I mean external programs that use DPDK, not DPDK bundled apps only.
> > If some of them use a stable DPDK branch and the change is backported, a
> > double-free will be introduced by upgrading DPDK to a minor version.
> > Users of current DPDK version that call cmdline_free() after
> > cmdline_stdin_exit() will have to upgrade their code, release notes are the
> > place to inform them about this need.
> > The patch itself is good and now it is the right time for it.  
> 
> Can you give me an ack, I have submitted v2:
> http://patches.dpdk.org/project/dpdk/patch/20210917021502.502560-1-zhihongx.peng@intel.com/

Hi Zhihong,
v2 doesn't address my concerns above.
Do you have any objections?

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

* [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
  2021-09-17  2:15   ` [dpdk-stable] [PATCH v2 2/2] app/test: Delete cmdline free function zhihongx.peng
@ 2021-10-08  6:41     ` zhihongx.peng
  2021-10-08  6:41       ` [dpdk-stable] [PATCH v3 2/2] app/test: delete cmdline free function zhihongx.peng
                         ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: zhihongx.peng @ 2021-10-08  6:41 UTC (permalink / raw)
  To: olivier.matz, dmitry.kozliuk; +Cc: dev, Zhihong Peng, stable

From: Zhihong Peng <zhihongx.peng@intel.com>

Malloc cl in the cmdline_stdin_new function, so release in the
cmdline_stdin_exit function is logical, so that cl will not be
released alone.

Fixes: af75078fece3 (first public release)
Cc: stable@dpdk.org

Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
---
 doc/guides/rel_notes/release_21_11.rst | 5 +++++
 lib/cmdline/cmdline_socket.c           | 1 +
 2 files changed, 6 insertions(+)

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index efeffe37a0..be24925d16 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -191,6 +191,11 @@ API Changes
   the crypto/security operation. This field will be used to communicate
   events such as soft expiry with IPsec in lookaside mode.
 
+* cmdline: The API cmdline_stdin_exit has added cmdline_free function.
+  Malloc cl in the cmdline_stdin_new function, so release in the
+  cmdline_stdin_exit function is logical. The application code
+  that calls cmdline_free needs to be deleted.
+
 
 ABI Changes
 -----------
diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
index 998e8ade25..ebd5343754 100644
--- a/lib/cmdline/cmdline_socket.c
+++ b/lib/cmdline/cmdline_socket.c
@@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
 		return;
 
 	terminal_restore(cl);
+	cmdline_free(cl);
 }
-- 
2.25.1


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

* [dpdk-stable] [PATCH v3 2/2] app/test: delete cmdline free function
  2021-10-08  6:41     ` [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit zhihongx.peng
@ 2021-10-08  6:41       ` zhihongx.peng
  2021-10-11  8:26         ` Dmitry Kozlyuk
  2021-10-11  5:20       ` [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit Peng, ZhihongX
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 24+ messages in thread
From: zhihongx.peng @ 2021-10-08  6:41 UTC (permalink / raw)
  To: olivier.matz, dmitry.kozliuk; +Cc: dev, Zhihong Peng, stable

From: Zhihong Peng <zhihongx.peng@intel.com>

Cmdline will be released in cmdline_stdin_exit function,
so it does not need to be released here.

Fixes: acdabc450ea0 (test: fix terminal settings on exit)
Cc: stable@dpdk.org

Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
---
 app/test/test.c             | 1 -
 app/test/test_cmdline_lib.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/app/test/test.c b/app/test/test.c
index 173d202e47..5194131026 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -233,7 +233,6 @@ main(int argc, char **argv)
 
 		cmdline_interact(cl);
 		cmdline_stdin_exit(cl);
-		cmdline_free(cl);
 	}
 #endif
 	ret = 0;
diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c
index d5a09b4541..6bcfa6511e 100644
--- a/app/test/test_cmdline_lib.c
+++ b/app/test/test_cmdline_lib.c
@@ -174,7 +174,6 @@ test_cmdline_socket_fns(void)
 	/* void functions */
 	cmdline_stdin_exit(NULL);
 
-	cmdline_free(cl);
 	return 0;
 error:
 	printf("Error: function accepted null parameter!\n");
-- 
2.25.1


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
  2021-09-30  7:44         ` Dmitry Kozlyuk
@ 2021-10-08  6:55           ` Peng, ZhihongX
  0 siblings, 0 replies; 24+ messages in thread
From: Peng, ZhihongX @ 2021-10-08  6:55 UTC (permalink / raw)
  To: Dmitry Kozlyuk, olivier.matz; +Cc: dev, stable

> -----Original Message-----
> From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Sent: Thursday, September 30, 2021 3:44 PM
> To: Peng, ZhihongX <zhihongx.peng@intel.com>; olivier.matz@6wind.com
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline exit
> 
> 2021-09-30 06:53 (UTC+0000), Peng, ZhihongX:
> > > -----Original Message-----
> > > From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > > Sent: Monday, September 6, 2021 3:34 PM
> > > To: Peng, ZhihongX <zhihongx.peng@intel.com>
> > > Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> > > Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when cmdline
> > > exit
> > >
> > > 2021-09-06 05:51 (UTC+0000), Peng, ZhihongX:
> > > > > -----Original Message-----
> > > > > From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > > > > Sent: Wednesday, September 1, 2021 1:52 AM
> > > > > To: Peng, ZhihongX <zhihongx.peng@intel.com>
> > > > > Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> > > > > Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: release cl when
> > > > > cmdline exit
> > > > >
> > > > > 2021-08-31 10:28 (UTC+0800), zhihongx.peng@intel.com:
> > > > > > From: Zhihong Peng <zhihongx.peng@intel.com>
> > > > > >
> > > > > > Malloc cl in the cmdline_stdin_new function, so release in the
> > > > > > cmdline_stdin_exit function is logical, so that cl will not be
> > > > > > released alone.
> > > > > >
> > > > > > Fixes: af75078fece3 (first public release)
> > > > > > Cc: stable@dpdk.org
> > > > > >
> > > > > > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> > > > > > ---
> > > > > >  lib/cmdline/cmdline_socket.c | 1 +
> > > > > >  1 file changed, 1 insertion(+)
> > > > > >
> > > > > > diff --git a/lib/cmdline/cmdline_socket.c
> > > > > > b/lib/cmdline/cmdline_socket.c index 998e8ade25..ebd5343754
> > > > > > 100644
> > > > > > --- a/lib/cmdline/cmdline_socket.c
> > > > > > +++ b/lib/cmdline/cmdline_socket.c
> > > > > > @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
> > > > > >  		return;
> > > > > >
> > > > > >  	terminal_restore(cl);
> > > > > > +	cmdline_free(cl);
> > > > > >  }
> > > > >
> > > > > Now cmdline_free() may not be called after cmdline_stdin_exit().
> > > > > User code that does so needs to be changed to avoid double-free.
> > > > > This behavior change must be documented in the release notes.
> > > > > I'm not sure it should be backported because of the above.
> > > > Using the asan tool, I found that many dpdk apps did not call
> > > > cmdline_free,
> > > only one app called.
> > >
> > > I mean external programs that use DPDK, not DPDK bundled apps only.
> > > If some of them use a stable DPDK branch and the change is
> > > backported, a double-free will be introduced by upgrading DPDK to a
> minor version.
> > > Users of current DPDK version that call cmdline_free() after
> > > cmdline_stdin_exit() will have to upgrade their code, release notes
> > > are the place to inform them about this need.
> > > The patch itself is good and now it is the right time for it.
> >
> > Can you give me an ack, I have submitted v2:
> > http://patches.dpdk.org/project/dpdk/patch/20210917021502.502560-1-
> zhi
> > hongx.peng@intel.com/
> 
> Hi Zhihong,
> v2 doesn't address my concerns above.
> Do you have any objections?

I got it wrong, I have submitted the v3 version and added the rel_notes document.


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

* Re: [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
  2021-10-08  6:41     ` [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit zhihongx.peng
  2021-10-08  6:41       ` [dpdk-stable] [PATCH v3 2/2] app/test: delete cmdline free function zhihongx.peng
@ 2021-10-11  5:20       ` Peng, ZhihongX
  2021-10-11  8:25       ` Dmitry Kozlyuk
  2021-10-13  1:52       ` [dpdk-stable] [PATCH v4 " zhihongx.peng
  3 siblings, 0 replies; 24+ messages in thread
From: Peng, ZhihongX @ 2021-10-11  5:20 UTC (permalink / raw)
  To: dmitry.kozliuk; +Cc: dev, stable, olivier.matz

> -----Original Message-----
> From: Peng, ZhihongX <zhihongx.peng@intel.com>
> Sent: Friday, October 8, 2021 2:42 PM
> To: olivier.matz@6wind.com; dmitry.kozliuk@gmail.com
> Cc: dev@dpdk.org; Peng, ZhihongX <zhihongx.peng@intel.com>;
> stable@dpdk.org
> Subject: [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
> 
> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Malloc cl in the cmdline_stdin_new function, so release in the
> cmdline_stdin_exit function is logical, so that cl will not be released alone.
> 
> Fixes: af75078fece3 (first public release)
> Cc: stable@dpdk.org
> 
> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> ---
>  doc/guides/rel_notes/release_21_11.rst | 5 +++++
>  lib/cmdline/cmdline_socket.c           | 1 +
>  2 files changed, 6 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/release_21_11.rst
> b/doc/guides/rel_notes/release_21_11.rst
> index efeffe37a0..be24925d16 100644
> --- a/doc/guides/rel_notes/release_21_11.rst
> +++ b/doc/guides/rel_notes/release_21_11.rst
> @@ -191,6 +191,11 @@ API Changes
>    the crypto/security operation. This field will be used to communicate
>    events such as soft expiry with IPsec in lookaside mode.
> 
> +* cmdline: The API cmdline_stdin_exit has added cmdline_free function.
> +  Malloc cl in the cmdline_stdin_new function, so release in the
> +  cmdline_stdin_exit function is logical. The application code
> +  that calls cmdline_free needs to be deleted.
> +
> 
>  ABI Changes
>  -----------
> diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
> index 998e8ade25..ebd5343754 100644
> --- a/lib/cmdline/cmdline_socket.c
> +++ b/lib/cmdline/cmdline_socket.c
> @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
>  		return;
> 
>  	terminal_restore(cl);
> +	cmdline_free(cl);
>  }
> --
> 2.25.1
Hi, kozliuk
Can you give me an ack, I have submitted v3, I have added the release notes.

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

* Re: [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
  2021-10-08  6:41     ` [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit zhihongx.peng
  2021-10-08  6:41       ` [dpdk-stable] [PATCH v3 2/2] app/test: delete cmdline free function zhihongx.peng
  2021-10-11  5:20       ` [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit Peng, ZhihongX
@ 2021-10-11  8:25       ` Dmitry Kozlyuk
  2021-10-13  1:53         ` Peng, ZhihongX
  2021-10-13  1:52       ` [dpdk-stable] [PATCH v4 " zhihongx.peng
  3 siblings, 1 reply; 24+ messages in thread
From: Dmitry Kozlyuk @ 2021-10-11  8:25 UTC (permalink / raw)
  To: zhihongx.peng; +Cc: olivier.matz, dev, stable

2021-10-08 06:41 (UTC+0000), zhihongx.peng@intel.com:
> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Malloc cl in the cmdline_stdin_new function, so release in the
> cmdline_stdin_exit function is logical, so that cl will not be
> released alone.
> 
> Fixes: af75078fece3 (first public release)
> Cc: stable@dpdk.org

As I have explained before, backporting this will introduce a double-free bug
in user apps unless their code are fixed, so it must not be done.

> 
> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> ---
>  doc/guides/rel_notes/release_21_11.rst | 5 +++++
>  lib/cmdline/cmdline_socket.c           | 1 +
>  2 files changed, 6 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
> index efeffe37a0..be24925d16 100644
> --- a/doc/guides/rel_notes/release_21_11.rst
> +++ b/doc/guides/rel_notes/release_21_11.rst
> @@ -191,6 +191,11 @@ API Changes
>    the crypto/security operation. This field will be used to communicate
>    events such as soft expiry with IPsec in lookaside mode.
>  
> +* cmdline: The API cmdline_stdin_exit has added cmdline_free function.
> +  Malloc cl in the cmdline_stdin_new function, so release in the
> +  cmdline_stdin_exit function is logical. The application code
> +  that calls cmdline_free needs to be deleted.
> +

There's probably no need to go into such details, suggestion:

* cmdline: ``cmdline_stdin_exit()`` now frees the ``cmdline`` structure.
  Calls to ``cmdline_free()`` after it need to be deleted from applications.

>  
>  ABI Changes
>  -----------
> diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
> index 998e8ade25..ebd5343754 100644
> --- a/lib/cmdline/cmdline_socket.c
> +++ b/lib/cmdline/cmdline_socket.c
> @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
>  		return;
>  
>  	terminal_restore(cl);
> +	cmdline_free(cl);
>  }


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

* Re: [dpdk-stable] [PATCH v3 2/2] app/test: delete cmdline free function
  2021-10-08  6:41       ` [dpdk-stable] [PATCH v3 2/2] app/test: delete cmdline free function zhihongx.peng
@ 2021-10-11  8:26         ` Dmitry Kozlyuk
  0 siblings, 0 replies; 24+ messages in thread
From: Dmitry Kozlyuk @ 2021-10-11  8:26 UTC (permalink / raw)
  To: zhihongx.peng; +Cc: olivier.matz, dev, stable

2021-10-08 06:41 (UTC+0000), zhihongx.peng@intel.com:
> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Cmdline will be released in cmdline_stdin_exit function,
> so it does not need to be released here.
> 
> Fixes: acdabc450ea0 (test: fix terminal settings on exit)
> Cc: stable@dpdk.org
> 
> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>

Except for backporting (see patch 1/2 comments),
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

> ---
>  app/test/test.c             | 1 -
>  app/test/test_cmdline_lib.c | 1 -
>  2 files changed, 2 deletions(-)
> 
> diff --git a/app/test/test.c b/app/test/test.c
> index 173d202e47..5194131026 100644
> --- a/app/test/test.c
> +++ b/app/test/test.c
> @@ -233,7 +233,6 @@ main(int argc, char **argv)
>  
>  		cmdline_interact(cl);
>  		cmdline_stdin_exit(cl);
> -		cmdline_free(cl);
>  	}
>  #endif
>  	ret = 0;
> diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c
> index d5a09b4541..6bcfa6511e 100644
> --- a/app/test/test_cmdline_lib.c
> +++ b/app/test/test_cmdline_lib.c
> @@ -174,7 +174,6 @@ test_cmdline_socket_fns(void)
>  	/* void functions */
>  	cmdline_stdin_exit(NULL);
>  
> -	cmdline_free(cl);
>  	return 0;
>  error:
>  	printf("Error: function accepted null parameter!\n");


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

* [dpdk-stable] [PATCH v4 1/2] lib/cmdline: release cl when cmdline exit
  2021-10-08  6:41     ` [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit zhihongx.peng
                         ` (2 preceding siblings ...)
  2021-10-11  8:25       ` Dmitry Kozlyuk
@ 2021-10-13  1:52       ` zhihongx.peng
  2021-10-13  1:52         ` [dpdk-stable] [PATCH v4 2/2] app/test: delete cmdline free function zhihongx.peng
  2021-10-15 12:58         ` [dpdk-stable] [PATCH v4 1/2] lib/cmdline: release cl when cmdline exit Olivier Matz
  3 siblings, 2 replies; 24+ messages in thread
From: zhihongx.peng @ 2021-10-13  1:52 UTC (permalink / raw)
  To: olivier.matz, dmitry.kozliuk; +Cc: dev, Zhihong Peng, stable

From: Zhihong Peng <zhihongx.peng@intel.com>

Malloc cl in the cmdline_stdin_new function, so release in the
cmdline_stdin_exit function is logical, so that cl will not be
released alone.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
---
 doc/guides/rel_notes/release_21_11.rst | 3 +++
 lib/cmdline/cmdline_socket.c           | 1 +
 2 files changed, 4 insertions(+)

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index f643a61f44..2f59077709 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -226,6 +226,9 @@ API Changes
   the crypto/security operation. This field will be used to communicate
   events such as soft expiry with IPsec in lookaside mode.
 
+* cmdline: ``cmdline_stdin_exit()`` now frees the ``cmdline`` structure.
+  Calls to ``cmdline_free()`` after it need to be deleted from applications.
+
 
 ABI Changes
 -----------
diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
index 998e8ade25..ebd5343754 100644
--- a/lib/cmdline/cmdline_socket.c
+++ b/lib/cmdline/cmdline_socket.c
@@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
 		return;
 
 	terminal_restore(cl);
+	cmdline_free(cl);
 }
-- 
2.25.1


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

* [dpdk-stable] [PATCH v4 2/2] app/test: delete cmdline free function
  2021-10-13  1:52       ` [dpdk-stable] [PATCH v4 " zhihongx.peng
@ 2021-10-13  1:52         ` zhihongx.peng
  2021-10-15 12:58         ` [dpdk-stable] [PATCH v4 1/2] lib/cmdline: release cl when cmdline exit Olivier Matz
  1 sibling, 0 replies; 24+ messages in thread
From: zhihongx.peng @ 2021-10-13  1:52 UTC (permalink / raw)
  To: olivier.matz, dmitry.kozliuk; +Cc: dev, Zhihong Peng, stable

From: Zhihong Peng <zhihongx.peng@intel.com>

Cmdline will be released in cmdline_stdin_exit function,
so it does not need to be released here.

Fixes: acdabc450ea0 ("test: fix terminal settings on exit")
Cc: stable@dpdk.org

Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
---
 app/test/test.c             | 1 -
 app/test/test_cmdline_lib.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/app/test/test.c b/app/test/test.c
index 173d202e47..5194131026 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -233,7 +233,6 @@ main(int argc, char **argv)
 
 		cmdline_interact(cl);
 		cmdline_stdin_exit(cl);
-		cmdline_free(cl);
 	}
 #endif
 	ret = 0;
diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c
index d5a09b4541..6bcfa6511e 100644
--- a/app/test/test_cmdline_lib.c
+++ b/app/test/test_cmdline_lib.c
@@ -174,7 +174,6 @@ test_cmdline_socket_fns(void)
 	/* void functions */
 	cmdline_stdin_exit(NULL);
 
-	cmdline_free(cl);
 	return 0;
 error:
 	printf("Error: function accepted null parameter!\n");
-- 
2.25.1


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

* Re: [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
  2021-10-11  8:25       ` Dmitry Kozlyuk
@ 2021-10-13  1:53         ` Peng, ZhihongX
  2021-10-13  2:36           ` Dmitry Kozlyuk
  0 siblings, 1 reply; 24+ messages in thread
From: Peng, ZhihongX @ 2021-10-13  1:53 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: olivier.matz, dev, stable

> -----Original Message-----
> From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Sent: Monday, October 11, 2021 4:26 PM
> To: Peng, ZhihongX <zhihongx.peng@intel.com>
> Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> Subject: Re: [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
> 
> 2021-10-08 06:41 (UTC+0000), zhihongx.peng@intel.com:
> > From: Zhihong Peng <zhihongx.peng@intel.com>
> >
> > Malloc cl in the cmdline_stdin_new function, so release in the
> > cmdline_stdin_exit function is logical, so that cl will not be
> > released alone.
> >
> > Fixes: af75078fece3 (first public release)
> > Cc: stable@dpdk.org
> 
> As I have explained before, backporting this will introduce a double-free bug
> in user apps unless their code are fixed, so it must not be done.

The release notes have stated that this is the only thing we can do,
and this unreasonable design should be resolved as soon as possible.
And the user apps change is very small.
> >
> > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> > ---
> >  doc/guides/rel_notes/release_21_11.rst | 5 +++++
> >  lib/cmdline/cmdline_socket.c           | 1 +
> >  2 files changed, 6 insertions(+)
> >
> > diff --git a/doc/guides/rel_notes/release_21_11.rst
> > b/doc/guides/rel_notes/release_21_11.rst
> > index efeffe37a0..be24925d16 100644
> > --- a/doc/guides/rel_notes/release_21_11.rst
> > +++ b/doc/guides/rel_notes/release_21_11.rst
> > @@ -191,6 +191,11 @@ API Changes
> >    the crypto/security operation. This field will be used to communicate
> >    events such as soft expiry with IPsec in lookaside mode.
> >
> > +* cmdline: The API cmdline_stdin_exit has added cmdline_free function.
> > +  Malloc cl in the cmdline_stdin_new function, so release in the
> > +  cmdline_stdin_exit function is logical. The application code
> > +  that calls cmdline_free needs to be deleted.
> > +
> 
> There's probably no need to go into such details, suggestion:
> 
> * cmdline: ``cmdline_stdin_exit()`` now frees the ``cmdline`` structure.
>   Calls to ``cmdline_free()`` after it need to be deleted from applications.

v4 version will be fixed.
> >
> >  ABI Changes
> >  -----------
> > diff --git a/lib/cmdline/cmdline_socket.c
> > b/lib/cmdline/cmdline_socket.c index 998e8ade25..ebd5343754 100644
> > --- a/lib/cmdline/cmdline_socket.c
> > +++ b/lib/cmdline/cmdline_socket.c
> > @@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
> >  		return;
> >
> >  	terminal_restore(cl);
> > +	cmdline_free(cl);
> >  }


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

* Re: [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
  2021-10-13  1:53         ` Peng, ZhihongX
@ 2021-10-13  2:36           ` Dmitry Kozlyuk
  2021-10-13  3:12             ` Peng, ZhihongX
  0 siblings, 1 reply; 24+ messages in thread
From: Dmitry Kozlyuk @ 2021-10-13  2:36 UTC (permalink / raw)
  To: Peng, ZhihongX; +Cc: olivier.matz, dev, stable

2021-10-13 01:53 (UTC+0000), Peng, ZhihongX:
> > -----Original Message-----
> > From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > Sent: Monday, October 11, 2021 4:26 PM
> > To: Peng, ZhihongX <zhihongx.peng@intel.com>
> > Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> > Subject: Re: [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
> > 
> > 2021-10-08 06:41 (UTC+0000), zhihongx.peng@intel.com:  
> > > From: Zhihong Peng <zhihongx.peng@intel.com>
> > >
> > > Malloc cl in the cmdline_stdin_new function, so release in the
> > > cmdline_stdin_exit function is logical, so that cl will not be
> > > released alone.
> > >
> > > Fixes: af75078fece3 (first public release)
> > > Cc: stable@dpdk.org  
> > 
> > As I have explained before, backporting this will introduce a double-free bug
> > in user apps unless their code are fixed, so it must not be done.  
> 
> The release notes have stated that this is the only thing we can do,
> and this unreasonable design should be resolved as soon as possible.
> And the user apps change is very small.

Stable release means stable ABI, which means that a compiled binary can use
the next minor version of DPDK without recompilation. No code change is
possible in this scenario. If the behavior changes such that cmdline_exit() +
cmdline_free() worked before and now cmdline_free() cause double-free, this
is an ABI breakage. Simply put, DPDK .so are replaced, the app restarts and
crashes. Users can do nothing about that.

Release notes are for developers updating their application code for the next
DPDK version.

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

* Re: [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
  2021-10-13  2:36           ` Dmitry Kozlyuk
@ 2021-10-13  3:12             ` Peng, ZhihongX
  0 siblings, 0 replies; 24+ messages in thread
From: Peng, ZhihongX @ 2021-10-13  3:12 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: olivier.matz, dev, stable

> -----Original Message-----
> From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Sent: Wednesday, October 13, 2021 10:36 AM
> To: Peng, ZhihongX <zhihongx.peng@intel.com>
> Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> Subject: Re: [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit
> 
> 2021-10-13 01:53 (UTC+0000), Peng, ZhihongX:
> > > -----Original Message-----
> > > From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > > Sent: Monday, October 11, 2021 4:26 PM
> > > To: Peng, ZhihongX <zhihongx.peng@intel.com>
> > > Cc: olivier.matz@6wind.com; dev@dpdk.org; stable@dpdk.org
> > > Subject: Re: [PATCH v3 1/2] lib/cmdline: release cl when cmdline
> > > exit
> > >
> > > 2021-10-08 06:41 (UTC+0000), zhihongx.peng@intel.com:
> > > > From: Zhihong Peng <zhihongx.peng@intel.com>
> > > >
> > > > Malloc cl in the cmdline_stdin_new function, so release in the
> > > > cmdline_stdin_exit function is logical, so that cl will not be
> > > > released alone.
> > > >
> > > > Fixes: af75078fece3 (first public release)
> > > > Cc: stable@dpdk.org
> > >
> > > As I have explained before, backporting this will introduce a
> > > double-free bug in user apps unless their code are fixed, so it must not
> be done.
> >
> > The release notes have stated that this is the only thing we can do,
> > and this unreasonable design should be resolved as soon as possible.
> > And the user apps change is very small.
> 
> Stable release means stable ABI, which means that a compiled binary can use
> the next minor version of DPDK without recompilation. No code change is
> possible in this scenario. If the behavior changes such that cmdline_exit() +
> cmdline_free() worked before and now cmdline_free() cause double-free,
> this is an ABI breakage. Simply put, DPDK .so are replaced, the app restarts
> and crashes. Users can do nothing about that.
> 
> Release notes are for developers updating their application code for the next
> DPDK version.

I may not understand what you mean. I want to know whether this code
can be merged, and if it can be merged, what work do I need to do.

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

* Re: [dpdk-stable] [PATCH v4 1/2] lib/cmdline: release cl when cmdline exit
  2021-10-13  1:52       ` [dpdk-stable] [PATCH v4 " zhihongx.peng
  2021-10-13  1:52         ` [dpdk-stable] [PATCH v4 2/2] app/test: delete cmdline free function zhihongx.peng
@ 2021-10-15 12:58         ` Olivier Matz
  2021-10-18  5:16           ` Peng, ZhihongX
  1 sibling, 1 reply; 24+ messages in thread
From: Olivier Matz @ 2021-10-15 12:58 UTC (permalink / raw)
  To: zhihongx.peng; +Cc: dmitry.kozliuk, dev, stable

On Wed, Oct 13, 2021 at 01:52:22AM +0000, zhihongx.peng@intel.com wrote:
> From: Zhihong Peng <zhihongx.peng@intel.com>
> 
> Malloc cl in the cmdline_stdin_new function, so release in the
> cmdline_stdin_exit function is logical, so that cl will not be
> released alone.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org

As said by Dmitry, we should not backport this fix to avoid breaking
external apps.

> Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>

I suggest to merge the 2 patches in one, because the second is mandatory
when the first one is applied.

Thanks Zhihong, and thanks Dmitry for the previous review.

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

* Re: [dpdk-stable] [PATCH v4 1/2] lib/cmdline: release cl when cmdline exit
  2021-10-15 12:58         ` [dpdk-stable] [PATCH v4 1/2] lib/cmdline: release cl when cmdline exit Olivier Matz
@ 2021-10-18  5:16           ` Peng, ZhihongX
  0 siblings, 0 replies; 24+ messages in thread
From: Peng, ZhihongX @ 2021-10-18  5:16 UTC (permalink / raw)
  To: Olivier Matz; +Cc: dmitry.kozliuk, dev, stable

> -----Original Message-----
> From: Olivier Matz <olivier.matz@6wind.com>
> Sent: Friday, October 15, 2021 8:58 PM
> To: Peng, ZhihongX <zhihongx.peng@intel.com>
> Cc: dmitry.kozliuk@gmail.com; dev@dpdk.org; stable@dpdk.org
> Subject: Re: [PATCH v4 1/2] lib/cmdline: release cl when cmdline exit
> 
> On Wed, Oct 13, 2021 at 01:52:22AM +0000, zhihongx.peng@intel.com wrote:
> > From: Zhihong Peng <zhihongx.peng@intel.com>
> >
> > Malloc cl in the cmdline_stdin_new function, so release in the
> > cmdline_stdin_exit function is logical, so that cl will not be
> > released alone.
> >
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable@dpdk.org
> 
> As said by Dmitry, we should not backport this fix to avoid breaking external
> apps.

The v5 version will be fixed.
> > Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
> 
> I suggest to merge the 2 patches in one, because the second is mandatory
> when the first one is applied.

The v5 version will be fixed
> Thanks Zhihong, and thanks Dmitry for the previous review.

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

end of thread, other threads:[~2021-10-18  5:16 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31  2:28 [dpdk-stable] [PATCH] lib/cmdline: release cl when cmdline exit zhihongx.peng
2021-08-31 16:59 ` [dpdk-stable] [dpdk-dev] " Stephen Hemminger
2021-09-06  5:45   ` Peng, ZhihongX
2021-08-31 17:52 ` Dmitry Kozlyuk
2021-09-06  5:51   ` Peng, ZhihongX
2021-09-06  7:33     ` Dmitry Kozlyuk
2021-09-30  6:53       ` Peng, ZhihongX
2021-09-30  7:44         ` Dmitry Kozlyuk
2021-10-08  6:55           ` Peng, ZhihongX
2021-09-17  2:15 ` [dpdk-stable] [PATCH v2 1/2] " zhihongx.peng
2021-09-17  2:15   ` [dpdk-stable] [PATCH v2 2/2] app/test: Delete cmdline free function zhihongx.peng
2021-10-08  6:41     ` [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit zhihongx.peng
2021-10-08  6:41       ` [dpdk-stable] [PATCH v3 2/2] app/test: delete cmdline free function zhihongx.peng
2021-10-11  8:26         ` Dmitry Kozlyuk
2021-10-11  5:20       ` [dpdk-stable] [PATCH v3 1/2] lib/cmdline: release cl when cmdline exit Peng, ZhihongX
2021-10-11  8:25       ` Dmitry Kozlyuk
2021-10-13  1:53         ` Peng, ZhihongX
2021-10-13  2:36           ` Dmitry Kozlyuk
2021-10-13  3:12             ` Peng, ZhihongX
2021-10-13  1:52       ` [dpdk-stable] [PATCH v4 " zhihongx.peng
2021-10-13  1:52         ` [dpdk-stable] [PATCH v4 2/2] app/test: delete cmdline free function zhihongx.peng
2021-10-15 12:58         ` [dpdk-stable] [PATCH v4 1/2] lib/cmdline: release cl when cmdline exit Olivier Matz
2021-10-18  5:16           ` Peng, ZhihongX
2021-09-30  6:47   ` [dpdk-stable] [PATCH v2 " Peng, ZhihongX

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://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/ http://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