Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 1/3] kernel-shark: Fix simple typo in the "File" menu.
@ 2019-10-23 12:21 Yordan Karadzhov (VMware)
  2019-10-23 12:21 ` [PATCH v2 2/3] kernel-shark: Fix potential memory leak in libkshark-collection Yordan Karadzhov (VMware)
  2019-10-23 12:21 ` [PATCH v2 3/3] kernel-shark: When running as Root save all config settings in /root/ Yordan Karadzhov (VMware)
  0 siblings, 2 replies; 3+ messages in thread
From: Yordan Karadzhov (VMware) @ 2019-10-23 12:21 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	[flat|nested] 3+ messages in thread

* [PATCH v2 2/3] kernel-shark: Fix potential memory leak in libkshark-collection
  2019-10-23 12:21 [PATCH v2 1/3] kernel-shark: Fix simple typo in the "File" menu Yordan Karadzhov (VMware)
@ 2019-10-23 12:21 ` Yordan Karadzhov (VMware)
  2019-10-23 12:21 ` [PATCH v2 3/3] kernel-shark: When running as Root save all config settings in /root/ Yordan Karadzhov (VMware)
  1 sibling, 0 replies; 3+ messages in thread
From: Yordan Karadzhov (VMware) @ 2019-10-23 12:21 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	[flat|nested] 3+ messages in thread

* [PATCH v2 3/3] kernel-shark: When running as Root save all config settings in /root/
  2019-10-23 12:21 [PATCH v2 1/3] kernel-shark: Fix simple typo in the "File" menu Yordan Karadzhov (VMware)
  2019-10-23 12:21 ` [PATCH v2 2/3] kernel-shark: Fix potential memory leak in libkshark-collection Yordan Karadzhov (VMware)
@ 2019-10-23 12:21 ` Yordan Karadzhov (VMware)
  1 sibling, 0 replies; 3+ messages in thread
From: Yordan Karadzhov (VMware) @ 2019-10-23 12:21 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Yordan Karadzhov (VMware)

If KernelShark is running with Root privileges, do not save the settings
in the standard location. Otherwise the configuration files will be owned
by Root and later the normal user will have no access to those files.

The patch seems to do the right thing in all cases that I tested, however
there is definitely something that I do not understand. QDir::homePath()
always returns the path to the home of the normal user, even if I build
and run kernelshark as root (sudo -s).

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

diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 3402764..bd6c338 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -69,7 +69,7 @@ KsMainWindow::KsMainWindow(QWidget *parent)
   _contentsAction("Contents", this),
   _bugReportAction("Report a bug", this),
   _deselectShortcut(this),
-  _settings("kernelshark.org", "Kernel Shark") // organization , application
+  _settings(_getCacheDir() + "/setting.ini", QSettings::IniFormat)
 {
 	setWindowTitle("Kernel Shark");
 	_createActions();
@@ -431,6 +431,9 @@ QString KsMainWindow::_getCacheDir()
 		dir = QStandardPaths::writableLocation(appCachePath);
 		dir += "/kernelshark";
 
+		if (geteuid() == 0)
+			dir.replace(QDir::homePath(), "/root");
+
 		if (!QDir(dir).exists())
 			lamMakePath(false);
 	}
-- 
2.20.1


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23 12:21 [PATCH v2 1/3] kernel-shark: Fix simple typo in the "File" menu Yordan Karadzhov (VMware)
2019-10-23 12:21 ` [PATCH v2 2/3] kernel-shark: Fix potential memory leak in libkshark-collection Yordan Karadzhov (VMware)
2019-10-23 12:21 ` [PATCH v2 3/3] kernel-shark: When running as Root save all config settings in /root/ Yordan Karadzhov (VMware)

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/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 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git