* Re: [dpdk-stable] [dpdk-dev] [PATCH] eal: fix strdup usages in internal config [not found] ` <f674f4cc-86b9-46f9-d485-75a471aecbad@intel.com> @ 2019-01-31 14:15 ` Kevin Traynor 2019-01-31 15:04 ` Thomas Monjalon 0 siblings, 1 reply; 4+ messages in thread From: Kevin Traynor @ 2019-01-31 14:15 UTC (permalink / raw) To: Burakov, Anatoly, dev Cc: Bruce Richardson, thomas, ferruh.yigit, andy01011501, Yongseok Koh, stable On 01/31/2019 02:10 PM, Burakov, Anatoly wrote: > On 31-Jan-19 11:21 AM, Kevin Traynor wrote: >> On 01/10/2019 01:38 PM, Anatoly Burakov wrote: >>> Currently, we use strdup in a few places to store command-line >>> parameter values for certain internal config values. There are >>> several issues with that. >>> >>> First of all, they're never freed, so memory ends up leaking >>> either after EAL exit, or when these command-line options are >>> supplied multiple times. >>> >>> Second of all, they're defined as `const char *`, so they >>> *cannot* be freed even if we wanted to. >>> >>> Finally, strdup may return NULL, which will be stored in the >>> config. For most fields, NULL is a valid value, but for the >>> default prefix, the value is always expected to be valid. >>> >>> To fix all of this, three things are done. First, we change >>> the definitions of these values to `char *` as opposed to >>> `const char *`. This does not break the ABI, and previous >>> code assumes constness (which is more restrictive), so it's >>> safe to do so. >>> >>> Then, fix all usages of strdup to check return value, and add >>> a cleanup function that will free the memory occupied by >>> these strings, as well as freeing them before assigning a new >>> value to prevent leaks when parameter is specified multiple >>> times. >>> >>> And finally, add an internal API to query hugefile prefix, so >>> that, absent of a valid value, a default value will be >>> returned, and also fix up all usages of hugefile prefix to >>> use this API instead of accessing hugefile prefix directly. >>> >>> Bugzilla ID: 108 >>> >> >> Hi Anatoly - this doesn't have stable or Fixes tags, but the bugzilla >> was reported on 17.11. Is it for backport to stable branches? >> > > It can be. Whether it's worth the effort of backporting is not my call :) > It's fine for 18.11 branch anyway, just needed a little help due to some changed context. I will send diff to stable list as normal. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] eal: fix strdup usages in internal config 2019-01-31 14:15 ` [dpdk-stable] [dpdk-dev] [PATCH] eal: fix strdup usages in internal config Kevin Traynor @ 2019-01-31 15:04 ` Thomas Monjalon 2019-01-31 15:55 ` Burakov, Anatoly 0 siblings, 1 reply; 4+ messages in thread From: Thomas Monjalon @ 2019-01-31 15:04 UTC (permalink / raw) To: Kevin Traynor Cc: Burakov, Anatoly, dev, Bruce Richardson, ferruh.yigit, andy01011501, Yongseok Koh, stable 31/01/2019 15:15, Kevin Traynor: > On 01/31/2019 02:10 PM, Burakov, Anatoly wrote: > > On 31-Jan-19 11:21 AM, Kevin Traynor wrote: > >> On 01/10/2019 01:38 PM, Anatoly Burakov wrote: > >>> Currently, we use strdup in a few places to store command-line > >>> parameter values for certain internal config values. There are > >>> several issues with that. > >>> > >>> First of all, they're never freed, so memory ends up leaking > >>> either after EAL exit, or when these command-line options are > >>> supplied multiple times. > >>> > >>> Second of all, they're defined as `const char *`, so they > >>> *cannot* be freed even if we wanted to. > >>> > >>> Finally, strdup may return NULL, which will be stored in the > >>> config. For most fields, NULL is a valid value, but for the > >>> default prefix, the value is always expected to be valid. > >>> > >>> To fix all of this, three things are done. First, we change > >>> the definitions of these values to `char *` as opposed to > >>> `const char *`. This does not break the ABI, and previous > >>> code assumes constness (which is more restrictive), so it's > >>> safe to do so. > >>> > >>> Then, fix all usages of strdup to check return value, and add > >>> a cleanup function that will free the memory occupied by > >>> these strings, as well as freeing them before assigning a new > >>> value to prevent leaks when parameter is specified multiple > >>> times. > >>> > >>> And finally, add an internal API to query hugefile prefix, so > >>> that, absent of a valid value, a default value will be > >>> returned, and also fix up all usages of hugefile prefix to > >>> use this API instead of accessing hugefile prefix directly. > >>> > >>> Bugzilla ID: 108 > >>> > >> > >> Hi Anatoly - this doesn't have stable or Fixes tags, but the bugzilla > >> was reported on 17.11. Is it for backport to stable branches? > >> > > > > It can be. Whether it's worth the effort of backporting is not my call :) > > > > It's fine for 18.11 branch anyway, just needed a little help due to some > changed context. I will send diff to stable list as normal. Nothing was broken. I see it like an improvement. Not sure it is worth the effort. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] eal: fix strdup usages in internal config 2019-01-31 15:04 ` Thomas Monjalon @ 2019-01-31 15:55 ` Burakov, Anatoly 2019-01-31 15:57 ` Kevin Traynor 0 siblings, 1 reply; 4+ messages in thread From: Burakov, Anatoly @ 2019-01-31 15:55 UTC (permalink / raw) To: Thomas Monjalon, Kevin Traynor Cc: dev, Bruce Richardson, ferruh.yigit, andy01011501, Yongseok Koh, stable On 31-Jan-19 3:04 PM, Thomas Monjalon wrote: > 31/01/2019 15:15, Kevin Traynor: >> On 01/31/2019 02:10 PM, Burakov, Anatoly wrote: >>> On 31-Jan-19 11:21 AM, Kevin Traynor wrote: >>>> On 01/10/2019 01:38 PM, Anatoly Burakov wrote: >>>>> Currently, we use strdup in a few places to store command-line >>>>> parameter values for certain internal config values. There are >>>>> several issues with that. >>>>> >>>>> First of all, they're never freed, so memory ends up leaking >>>>> either after EAL exit, or when these command-line options are >>>>> supplied multiple times. >>>>> >>>>> Second of all, they're defined as `const char *`, so they >>>>> *cannot* be freed even if we wanted to. >>>>> >>>>> Finally, strdup may return NULL, which will be stored in the >>>>> config. For most fields, NULL is a valid value, but for the >>>>> default prefix, the value is always expected to be valid. >>>>> >>>>> To fix all of this, three things are done. First, we change >>>>> the definitions of these values to `char *` as opposed to >>>>> `const char *`. This does not break the ABI, and previous >>>>> code assumes constness (which is more restrictive), so it's >>>>> safe to do so. >>>>> >>>>> Then, fix all usages of strdup to check return value, and add >>>>> a cleanup function that will free the memory occupied by >>>>> these strings, as well as freeing them before assigning a new >>>>> value to prevent leaks when parameter is specified multiple >>>>> times. >>>>> >>>>> And finally, add an internal API to query hugefile prefix, so >>>>> that, absent of a valid value, a default value will be >>>>> returned, and also fix up all usages of hugefile prefix to >>>>> use this API instead of accessing hugefile prefix directly. >>>>> >>>>> Bugzilla ID: 108 >>>>> >>>> >>>> Hi Anatoly - this doesn't have stable or Fixes tags, but the bugzilla >>>> was reported on 17.11. Is it for backport to stable branches? >>>> >>> >>> It can be. Whether it's worth the effort of backporting is not my call :) >>> >> >> It's fine for 18.11 branch anyway, just needed a little help due to some >> changed context. I will send diff to stable list as normal. > > Nothing was broken. I see it like an improvement. > Not sure it is worth the effort. > Well, *technically*, there was a memory leak. For example, if you specify mbuf pool ops flag multiple times, previously allocated strdup() call results would be discarded and leaked. However, it's such a minor issue that it's indeed likely not worth the effort. -- Thanks, Anatoly ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] eal: fix strdup usages in internal config 2019-01-31 15:55 ` Burakov, Anatoly @ 2019-01-31 15:57 ` Kevin Traynor 0 siblings, 0 replies; 4+ messages in thread From: Kevin Traynor @ 2019-01-31 15:57 UTC (permalink / raw) To: Burakov, Anatoly, Thomas Monjalon Cc: dev, Bruce Richardson, ferruh.yigit, andy01011501, Yongseok Koh, stable On 01/31/2019 03:55 PM, Burakov, Anatoly wrote: > On 31-Jan-19 3:04 PM, Thomas Monjalon wrote: >> 31/01/2019 15:15, Kevin Traynor: >>> On 01/31/2019 02:10 PM, Burakov, Anatoly wrote: >>>> On 31-Jan-19 11:21 AM, Kevin Traynor wrote: >>>>> On 01/10/2019 01:38 PM, Anatoly Burakov wrote: >>>>>> Currently, we use strdup in a few places to store command-line >>>>>> parameter values for certain internal config values. There are >>>>>> several issues with that. >>>>>> >>>>>> First of all, they're never freed, so memory ends up leaking >>>>>> either after EAL exit, or when these command-line options are >>>>>> supplied multiple times. >>>>>> >>>>>> Second of all, they're defined as `const char *`, so they >>>>>> *cannot* be freed even if we wanted to. >>>>>> >>>>>> Finally, strdup may return NULL, which will be stored in the >>>>>> config. For most fields, NULL is a valid value, but for the >>>>>> default prefix, the value is always expected to be valid. >>>>>> >>>>>> To fix all of this, three things are done. First, we change >>>>>> the definitions of these values to `char *` as opposed to >>>>>> `const char *`. This does not break the ABI, and previous >>>>>> code assumes constness (which is more restrictive), so it's >>>>>> safe to do so. >>>>>> >>>>>> Then, fix all usages of strdup to check return value, and add >>>>>> a cleanup function that will free the memory occupied by >>>>>> these strings, as well as freeing them before assigning a new >>>>>> value to prevent leaks when parameter is specified multiple >>>>>> times. >>>>>> >>>>>> And finally, add an internal API to query hugefile prefix, so >>>>>> that, absent of a valid value, a default value will be >>>>>> returned, and also fix up all usages of hugefile prefix to >>>>>> use this API instead of accessing hugefile prefix directly. >>>>>> >>>>>> Bugzilla ID: 108 >>>>>> >>>>> >>>>> Hi Anatoly - this doesn't have stable or Fixes tags, but the bugzilla >>>>> was reported on 17.11. Is it for backport to stable branches? >>>>> >>>> >>>> It can be. Whether it's worth the effort of backporting is not my >>>> call :) >>>> >>> >>> It's fine for 18.11 branch anyway, just needed a little help due to some >>> changed context. I will send diff to stable list as normal. >> >> Nothing was broken. I see it like an improvement. >> Not sure it is worth the effort. >> > > Well, *technically*, there was a memory leak. For example, if you > specify mbuf pool ops flag multiple times, previously allocated strdup() > call results would be discarded and leaked. > > However, it's such a minor issue that it's indeed likely not worth the > effort. > > It's already done - just sent it in the batch a few mins ago ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-31 15:57 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <4e041e83fb00d8d818682997f795928c36b3283a.1547127516.git.anatoly.burakov@intel.com> [not found] ` <e652078e-0027-8168-2c08-d3d0f11441b1@redhat.com> [not found] ` <f674f4cc-86b9-46f9-d485-75a471aecbad@intel.com> 2019-01-31 14:15 ` [dpdk-stable] [dpdk-dev] [PATCH] eal: fix strdup usages in internal config Kevin Traynor 2019-01-31 15:04 ` Thomas Monjalon 2019-01-31 15:55 ` Burakov, Anatoly 2019-01-31 15:57 ` Kevin Traynor
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).