linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] kernel-shark: Fix simple typo in the "File" menu.
@ 2019-10-18  7:47 Yordan Karadzhov (VMware)
  2019-10-18  7:47 ` [PATCH 2/3] kernel-shark: Do not save the settings when running as Root Yordan Karadzhov (VMware)
  2019-10-18  7:47 ` [PATCH 3/3] kernel-shark: Fix potential memory leak in libkshark-collection Yordan Karadzhov (VMware)
  0 siblings, 2 replies; 6+ messages in thread
From: Yordan Karadzhov (VMware) @ 2019-10-18  7:47 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Yordan Karadzhov (VMware), Tzvetomir Stoyanov

Reported-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsMainWindow.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index a583f5f..3402764 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -45,7 +45,7 @@ KsMainWindow::KsMainWindow(QWidget *parent)
   _openAction("Open", this),
   _restoreSessionAction("Restore Last Session", this),
   _importSessionAction("Import Session", this),
-  _exportSessionAction("Export Sassion", this),
+  _exportSessionAction("Export Session", this),
   _quitAction("Quit", this),
   _importFilterAction("Import Filter", this),
   _exportFilterAction("Export Filter", this),
-- 
2.20.1


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

* [PATCH 2/3] kernel-shark: Do not save the settings when running as Root
  2019-10-18  7:47 [PATCH 1/3] kernel-shark: Fix simple typo in the "File" menu Yordan Karadzhov (VMware)
@ 2019-10-18  7:47 ` Yordan Karadzhov (VMware)
  2019-10-18 14:32   ` Steven Rostedt
  2019-10-18  7:47 ` [PATCH 3/3] kernel-shark: Fix potential memory leak in libkshark-collection Yordan Karadzhov (VMware)
  1 sibling, 1 reply; 6+ messages in thread
From: Yordan Karadzhov (VMware) @ 2019-10-18  7:47 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Yordan Karadzhov (VMware)

Do not save the settings if KernelShark is running with Root privileges.
Otherwise the configuration file will be owned by Root and later the
normal user will have no access to it.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsMainWindow.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 3402764..6da8670 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -152,9 +152,15 @@ KsMainWindow::~KsMainWindow()
 					_session.getConfDocPtr());
 	}
 
-	_settings.setValue("dataPath", _lastDataFilePath);
-	_settings.setValue("confPath", _lastConfFilePath);
-	_settings.setValue("pluginPath", _lastPluginFilePath);
+	/*
+	 * Do not save the settings if KernelShark is running with Root
+	 * privileges. Otherwise the configuration file will be owned by Root.
+	 */
+	if (geteuid() != 0) {
+		_settings.setValue("dataPath", _lastDataFilePath);
+		_settings.setValue("confPath", _lastConfFilePath);
+		_settings.setValue("pluginPath", _lastPluginFilePath);
+	}
 
 	_data.clear();
 
-- 
2.20.1


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

* [PATCH 3/3] kernel-shark: Fix potential memory leak in libkshark-collection
  2019-10-18  7:47 [PATCH 1/3] kernel-shark: Fix simple typo in the "File" menu Yordan Karadzhov (VMware)
  2019-10-18  7:47 ` [PATCH 2/3] kernel-shark: Do not save the settings when running as Root Yordan Karadzhov (VMware)
@ 2019-10-18  7:47 ` Yordan Karadzhov (VMware)
  1 sibling, 0 replies; 6+ messages in thread
From: Yordan Karadzhov (VMware) @ 2019-10-18  7:47 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Yordan Karadzhov (VMware)

When searching for the entry, do not loop over the original list of
requests. Use a copy instead. If we loop over the original list and
no entry is found in the first element of the list, later the memory
used for this first element will leak.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/libkshark-collection.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/kernel-shark/src/libkshark-collection.c b/kernel-shark/src/libkshark-collection.c
index 02a014e..95fdbab 100644
--- a/kernel-shark/src/libkshark-collection.c
+++ b/kernel-shark/src/libkshark-collection.c
@@ -622,6 +622,7 @@ kshark_get_collection_entry_front(struct kshark_entry_request **req,
 				  ssize_t *index)
 {
 	const struct kshark_entry *entry = NULL;
+	struct kshark_entry_request *list;
 	int req_count;
 
 	/*
@@ -638,12 +639,10 @@ kshark_get_collection_entry_front(struct kshark_entry_request **req,
 	 * Loop over the list of redefined requests and search until you find
 	 * the first matching entry.
 	 */
-	while (*req) {
-		entry = kshark_get_entry_front(*req, data, index);
+	for (list = *req; list; list = list->next) {
+		entry = kshark_get_entry_front(list, data, index);
 		if (entry)
 			break;
-
-		*req = (*req)->next;
 	}
 
 	return entry;
@@ -680,6 +679,7 @@ kshark_get_collection_entry_back(struct kshark_entry_request **req,
 				 ssize_t *index)
 {
 	const struct kshark_entry *entry = NULL;
+	struct kshark_entry_request *list;
 	int req_count;
 
 	/*
@@ -695,12 +695,10 @@ kshark_get_collection_entry_back(struct kshark_entry_request **req,
 	 * Loop over the list of redefined requests and search until you find
 	 * the first matching entry.
 	 */
-	while (*req) {
-		entry = kshark_get_entry_back(*req, data, index);
+	for (list = *req; list; list = list->next) {
+		entry = kshark_get_entry_back(list, data, index);
 		if (entry)
 			break;
-
-		*req = (*req)->next;
 	}
 
 	return entry;
-- 
2.20.1


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

* Re: [PATCH 2/3] kernel-shark: Do not save the settings when running as Root
  2019-10-18  7:47 ` [PATCH 2/3] kernel-shark: Do not save the settings when running as Root Yordan Karadzhov (VMware)
@ 2019-10-18 14:32   ` Steven Rostedt
  2019-10-23 10:49     ` Yordan Karadzhov (VMware)
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2019-10-18 14:32 UTC (permalink / raw)
  To: Yordan Karadzhov (VMware); +Cc: linux-trace-devel

On Fri, 18 Oct 2019 10:47:21 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> Do not save the settings if KernelShark is running with Root privileges.
> Otherwise the configuration file will be owned by Root and later the
> normal user will have no access to it.

Perhaps we should have the settings saved in the root home directory?

Reason being, I run kernelshark as root all the time (on my test boxes,
where I only log in as root).

And I would still like to have the settings saved. Maybe check if the
settings path is the same as $HOME variable?

-- Steve

> 
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> ---
>  kernel-shark/src/KsMainWindow.cpp | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
> index 3402764..6da8670 100644
> --- a/kernel-shark/src/KsMainWindow.cpp
> +++ b/kernel-shark/src/KsMainWindow.cpp
> @@ -152,9 +152,15 @@ KsMainWindow::~KsMainWindow()
>  					_session.getConfDocPtr());
>  	}
>  
> -	_settings.setValue("dataPath", _lastDataFilePath);
> -	_settings.setValue("confPath", _lastConfFilePath);
> -	_settings.setValue("pluginPath", _lastPluginFilePath);
> +	/*
> +	 * Do not save the settings if KernelShark is running with Root
> +	 * privileges. Otherwise the configuration file will be owned by Root.
> +	 */
> +	if (geteuid() != 0) {
> +		_settings.setValue("dataPath", _lastDataFilePath);
> +		_settings.setValue("confPath", _lastConfFilePath);
> +		_settings.setValue("pluginPath", _lastPluginFilePath);
> +	}
>  
>  	_data.clear();
>  


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

* Re: [PATCH 2/3] kernel-shark: Do not save the settings when running as Root
  2019-10-18 14:32   ` Steven Rostedt
@ 2019-10-23 10:49     ` Yordan Karadzhov (VMware)
  2019-10-23 11:59       ` Steven Rostedt
  0 siblings, 1 reply; 6+ messages in thread
From: Yordan Karadzhov (VMware) @ 2019-10-23 10:49 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel



On 18.10.19 г. 17:32 ч., Steven Rostedt wrote:
> On Fri, 18 Oct 2019 10:47:21 +0300
> "Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
> 
>> Do not save the settings if KernelShark is running with Root privileges.
>> Otherwise the configuration file will be owned by Root and later the
>> normal user will have no access to it.
> 
> Perhaps we should have the settings saved in the root home directory?
> 
> Reason being, I run kernelshark as root all the time (on my test boxes,
> where I only log in as root).
> 
> And I would still like to have the settings saved. Maybe check if the
> settings path is the same as $HOME variable?
> 

OK I think I have a solution that does a better job. Do you prefer to 
resend all 3 patches or just this one?

Thanks!
Yordan


> -- Steve
> 
>>
>> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
>> ---
>>   kernel-shark/src/KsMainWindow.cpp | 12 +++++++++---
>>   1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
>> index 3402764..6da8670 100644
>> --- a/kernel-shark/src/KsMainWindow.cpp
>> +++ b/kernel-shark/src/KsMainWindow.cpp
>> @@ -152,9 +152,15 @@ KsMainWindow::~KsMainWindow()
>>   					_session.getConfDocPtr());
>>   	}
>>   
>> -	_settings.setValue("dataPath", _lastDataFilePath);
>> -	_settings.setValue("confPath", _lastConfFilePath);
>> -	_settings.setValue("pluginPath", _lastPluginFilePath);
>> +	/*
>> +	 * Do not save the settings if KernelShark is running with Root
>> +	 * privileges. Otherwise the configuration file will be owned by Root.
>> +	 */
>> +	if (geteuid() != 0) {
>> +		_settings.setValue("dataPath", _lastDataFilePath);
>> +		_settings.setValue("confPath", _lastConfFilePath);
>> +		_settings.setValue("pluginPath", _lastPluginFilePath);
>> +	}
>>   
>>   	_data.clear();
>>   
> 

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

* Re: [PATCH 2/3] kernel-shark: Do not save the settings when running as Root
  2019-10-23 10:49     ` Yordan Karadzhov (VMware)
@ 2019-10-23 11:59       ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2019-10-23 11:59 UTC (permalink / raw)
  To: Yordan Karadzhov (VMware); +Cc: linux-trace-devel

On Wed, 23 Oct 2019 13:49:25 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> OK I think I have a solution that does a better job. Do you prefer to 
> resend all 3 patches or just this one?

Send them all again.

Thanks!

-- Steve

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

end of thread, other threads:[~2019-10-23 12:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18  7:47 [PATCH 1/3] kernel-shark: Fix simple typo in the "File" menu Yordan Karadzhov (VMware)
2019-10-18  7:47 ` [PATCH 2/3] kernel-shark: Do not save the settings when running as Root Yordan Karadzhov (VMware)
2019-10-18 14:32   ` Steven Rostedt
2019-10-23 10:49     ` Yordan Karadzhov (VMware)
2019-10-23 11:59       ` Steven Rostedt
2019-10-18  7:47 ` [PATCH 3/3] kernel-shark: Fix potential memory leak in libkshark-collection Yordan Karadzhov (VMware)

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).