librte_eal: fix wrong args operation in eal_parse_args
PATCH 1/1 librte_eal: fix wrong args operation in eal_parse_args
This patch is used to fix wrong operation on user input args. eal_parse_args function should not operate the args passed by the user. If the element in argv is generated by malloc function, changing it will cause memory issues when free the args.
--- lib/librte_eal/bsdapp/eal/eal.c | 2 -- lib/librte_eal/linuxapp/eal/eal.c | 2 -- 2 files changed, 4 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +0 -2
@@ -420,8 +420,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:
lib/librte_eal/linuxapp/eal/eal.c +0 -2
@@ -658,8 +658,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:
Signature · 1 line
1.9.3
Quoted 30 lines · Ziye Yang
This patch is used to fix wrong operation on user input args.
eal_parse_argsfunction should not operate the args passed by the user. If the element in argv is generated by malloc function, changing it will cause memory issues when free the args.Signed-off-by Ziye Yang <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 2 -- lib/librte_eal/linuxapp/eal/eal.c | 2 -- 2 files changed, 4 deletions(-)lib/librte_eal/bsdapp/eal/eal.c +0
-2@@ -420,8 +420,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:lib/librte_eal/linuxapp/eal/eal.c +0
-0
lib/librte_eal/linuxapp/eal/eal.c eal_parse_args(int argc, char **argv) · line 663
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal.c +0
-2@@ -658,8 +658,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:
This is a behaviour change in DPDK. The behaviour has always been that after calling eal init, you can update your argv/argc values by the number of args parsed and then parse your app args as normal, since argv[0] will still point to your program name. While I agree that having the current behaviour may cause some problems, changing this behaviour may break applications that have been written to use the existing behaviour.
Since it is only the last EAL parameter arg that is modified, I think it would be acceptable to have the behaviour well documented and then expect any app to store a second copy of the pointer to be modified if it is needed for a subsequent free call, for example.
/Bruce
Hi Bruce,
Could it be fixed later? If not, it should be documented. I faced this issued today, and found that dpdk changed my last arg. In my mind, dpdk should not change the argv[last], which will confuse the users.
Best Regards,
Ziye Yang
-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, May 11, 2016 7:25 PM
To: Yang, Ziye <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] librte_eal: fix wrong args operation in eal_parse_args
Quoted 30 lines · Ziye Yang
This patch is used to fix wrong operation on user input args.
eal_parse_argsfunction should not operate the args passed by the user. If the element in argv is generated by malloc function, changing it will cause memory issues when free the args.Signed-off-by Ziye Yang <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 2 -- lib/librte_eal/linuxapp/eal/eal.c | 2 -- 2 files changed, 4 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/bsdapp/eal/eal.cindex 06bfd4e..0eef92d 100644lib/librte_eal/bsdapp/eal/eal.c +0
-2@@ -420,8 +420,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:lib/librte_eal/linuxapp/eal/eal.c +0
-0
lib/librte_eal/linuxapp/eal/eal.c eal_parse_args(int argc, char **argv) · line 663
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal.c +0
-2@@ -658,8 +658,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:
This is a behaviour change in DPDK. The behaviour has always been that after calling eal init, you can update your argv/argc values by the number of args parsed and then parse your app args as normal, since argv[0] will still point to your program name. While I agree that having the current behaviour may cause some problems, changing this behaviour may break applications that have been written to use the existing behaviour.
Since it is only the last EAL parameter arg that is modified, I think it would be acceptable to have the behaviour well documented and then expect any app to store a second copy of the pointer to be modified if it is needed for a subsequent free call, for example.
/Bruce
Quoted 10 lines
-----Original Message-----
From: Yang, Ziye
Sent: Wednesday, May 11, 2016 12:51 PM
To: Richardson, Bruce <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH]librte_eal: fix wrong args operation ineal_parse_args
Quoted 6 lines
Hi Bruce,
Could it be fixed later? If not, it should be documented. I faced this issued today, and found that dpdk changed my last arg. In my mind, dpdk should not change the argv[last], which will confuse the users.
We can certainly consider changing it, but I am concerned about stability of existing apps. I think it needs some discussion and consensus on-list before a change like this is made.
For right now, definitely the behavior should be documented. Would you consider submitting a documentation update patch for this issue instead of this code change?
Thanks,
/Bruce
Quoted 63 lines
Best Regards,
Ziye Yang-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, May 11, 2016 7:25 PM
To: Yang, Ziye <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH]librte_eal: fix wrong args operation ineal_parse_argsQuoted 30 lines · Ziye Yang
This patch is used to fix wrong operation on user input args.
eal_parse_argsfunction should not operate the args passed by the user. If the element in argv is generated by malloc function, changing it will cause memory issues when free the args.Signed-off-by Ziye Yang <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 2 -- lib/librte_eal/linuxapp/eal/eal.c | 2 -- 2 files changed, 4 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/bsdapp/eal/eal.cindex 06bfd4e..0eef92d 100644lib/librte_eal/bsdapp/eal/eal.c +0
-2@@ -420,8 +420,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:lib/librte_eal/linuxapp/eal/eal.c +0
-0lib/librte_eal/linuxapp/eal/eal.c eal_parse_args(int argc, char **argv) · line 663
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal.c +0
-2@@ -658,8 +658,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:This is a behaviour change in DPDK. The behaviour has always been that after calling eal init, you can update your argv/argc values by the number of args parsed and then parse your app args as normal, since argv[0] will still point to your program name. While I agree that having the current behaviour may cause some problems, changing this behaviour may break applications that have been written to use the existing behaviour.
Since it is only the last EAL parameter arg that is modified, I think it would be acceptable to have the behaviour well documented and then expect any app to store a second copy of the pointer to be modified if it is needed for a subsequent free call, for example.
/Bruce
Hi Bruce,
Could you tell me the documentation file name? Then I can conduct the following documentation relate d patch.
-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, May 11, 2016 8:21 PM
To: Yang, Ziye <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH] librte_eal: fix wrong args operation in eal_parse_args
Quoted 8 lines
-----Original Message-----
From: Yang, Ziye
Sent: Wednesday, May 11, 2016 12:51 PM
To: Richardson, Bruce <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH]librte_eal: fix wrong args operation ineal_parse_args
Quoted 6 lines
Hi Bruce,
Could it be fixed later? If not, it should be documented. I faced this issued today, and found that dpdk changed my last arg. In my mind, dpdk should not change the argv[last], which will confuse the users.
We can certainly consider changing it, but I am concerned about stability of existing apps. I think it needs some discussion and consensus on-list before a change like this is made.
For right now, definitely the behavior should be documented. Would you consider submitting a documentation update patch for this issue instead of this code change?
Thanks,
/Bruce
Quoted 63 lines
Best Regards,
Ziye Yang-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, May 11, 2016 7:25 PM
To: Yang, Ziye <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH]librte_eal: fix wrong args operation ineal_parse_argsQuoted 30 lines · Ziye Yang
This patch is used to fix wrong operation on user input args.
eal_parse_argsfunction should not operate the args passed by the user. If the element in argv is generated by malloc function, changing it will cause memory issues when free the args.Signed-off-by Ziye Yang <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 2 -- lib/librte_eal/linuxapp/eal/eal.c | 2 -- 2 files changed, 4 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/bsdapp/eal/eal.cindex 06bfd4e..0eef92d 100644lib/librte_eal/bsdapp/eal/eal.c +0
-2@@ -420,8 +420,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:lib/librte_eal/linuxapp/eal/eal.c +0
-0lib/librte_eal/linuxapp/eal/eal.c eal_parse_args(int argc, char **argv) · line 663
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal.c +0
-2@@ -658,8 +658,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:This is a behaviour change in DPDK. The behaviour has always been that after calling eal init, you can update your argv/argc values by the number of args parsed and then parse your app args as normal, since argv[0] will still point to your program name. While I agree that
having the current behaviour may cause some problems, changing this behaviour may break applications that have been written to use the existing behaviour.Since it is only the last EAL parameter arg that is modified, I think it would be acceptable to have the behaviour well documented and then expect any app to store a second copy of the pointer to be modified if it is needed for a subsequent free call, for example.
/Bruce
Quoted 10 lines
-----Original Message-----
From: Yang, Ziye
Sent: Wednesday, May 11, 2016 2:39 PM
To: Richardson, Bruce <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH]librte_eal: fix wrong args operation ineal_parse_args
Quoted 4 lines
Hi Bruce,
Could you tell me the documentation file name? Then I can conduct the following documentation relate d patch.
The behavior is already documented in the doxygen API definitions for rte_eal_init().
* @return$
* - On success, the number of parsed arguments, which is greater or$
* equal to zero. After the call to rte_eal_init(),$ * all arguments argv[x] with x < ret may be modified and should$ * not be accessed by the application.$
* - On failure, a negative error value.$
However, maybe you want to call it out in a different way to make it clearer for those using the functions. Other than that, perhaps look in the programmers guide document to see if it needs a mention there - or a reference to the API doc.
/Bruce
PS: When replying, please respond below existing emails, rather than top-posting. Thanks.
Quoted 102 lines
-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, May 11, 2016 8:21 PM
To: Yang, Ziye <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH]librte_eal: fix wrong args operation ineal_parse_argsQuoted 8 lines
-----Original Message-----
From: Yang, Ziye
Sent: Wednesday, May 11, 2016 12:51 PM
To: Richardson, Bruce <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH]librte_eal: fix wrong args operation ineal_parse_argsQuoted 5 lines
Hi Bruce,
Could it be fixed later? If not, it should be documented. I faced this issued today, and found that dpdk changed my last arg. In my mind, dpdk should not change the argv[last], which will confuse the
users.
Quoted 1 line
We can certainly consider changing it, but I am concerned about stability of existing apps. I think it needs some discussion and consensus on-list before a change like this is made.
For right now, definitely the behavior should be documented. Would you consider submitting a documentation update patch for this issue instead of this code change?
Thanks,
/BruceQuoted 49 lines
Best Regards,
Ziye Yang-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, May 11, 2016 7:25 PM
To: Yang, Ziye <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH]librte_eal: fix wrong args operation ineal_parse_argsQuoted 37 lines · Ziye Yang
This patch is used to fix wrong operation on user input args.
eal_parse_argsfunction should not operate the args passed by the user. If the element in argv is generated by malloc function, changing it will cause memory issues when free the args.Signed-off-by Ziye Yang <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 2 -- lib/librte_eal/linuxapp/eal/eal.c | 2 -- 2 files changed, 4 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/bsdapp/eal/eal.cindex 06bfd4e..0eef92d 100644lib/librte_eal/bsdapp/eal/eal.c +0
-2@@ -420,8 +420,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ; out:lib/librte_eal/linuxapp/eal/eal.c +0
-2@@ -658,8 +658,6 @@ eal_parse_args(int argc, char **argv) goto out; } -if (optind >=0 ) - argv[optind-1 ] = prgname; ret = optind-1 ;Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal.c eal_parse_args(int argc, char **argv) · line 663
Quoted 1 line
lib/librte_eal/linuxapp/eal/eal.c +0
-0out:This is a behaviour change in DPDK. The behaviour has always been that after calling eal init, you can update your argv/argc values by the number of args parsed and then parse your app args as normal, since argv[0] will still point to your program name. While I agree that having the current behaviour may cause some problems, changing this behaviour may break applications that have been written to use the
existing behaviour.
Quoted 7 lines
Since it is only the last EAL parameter arg that is modified, I think it would be acceptable to have the behaviour well documented and then expect any app to store a second copy of the pointer to be modified if it is needed for a subsequent free call, for example.
/Bruce