[v3,1/2] lib/cmdline: release cl when cmdline exit

Message ID 20211008064131.369133-1-zhihongx.peng@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v3,1/2] lib/cmdline: release cl when cmdline exit |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Peng, ZhihongX Oct. 8, 2021, 6:41 a.m. UTC
  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(+)
  

Comments

Peng, ZhihongX Oct. 11, 2021, 5:20 a.m. UTC | #1
> -----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.
  
Dmitry Kozlyuk Oct. 11, 2021, 8:25 a.m. UTC | #2
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);
>  }
  
Peng, ZhihongX Oct. 13, 2021, 1:53 a.m. UTC | #3
> -----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);
> >  }
  
Dmitry Kozlyuk Oct. 13, 2021, 2:36 a.m. UTC | #4
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.
  
Peng, ZhihongX Oct. 13, 2021, 3:12 a.m. UTC | #5
> -----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.
  

Patch

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);
 }