Skip to contentSkip to conversation

memory leaks triggered by perf --namespace

PATCH New Vasily Averin 2 participants 3 messages Nov 15, 2017 – Nov 29, 2017 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory leaks triggered by perf --namespace

perf with --namespace key leaks various memory objects including namespaces

# uname -r
4.14.0+
# perf record  -q  --namespace unshare -n -U  -p --fork true
# grep namespace /proc/slabinfo
pid_namespace          1     12   2568   12    8 
user_namespace         1     39    824   39    8 
net_namespace          1      5   6272    5    8 

This happen because perf_fill_ns_link_info() struct patch ns_path:
during initialization ns_path incremented counters on related mnt and dentry, but without lost path_put nobody decremented them back.
Leaked dentry is name of related namespace,
and its leak does not allow to free unused namespace.

Fixes commit e422267322cd ("perf: Add PERF_RECORD_NAMESPACES to include namespaces related info")
---
 kernel/events/core.c | 1 +
 1 file changed, 1 insertion(+)
kernel/events/core.c +1 -0
index 10cdb9c..ab5ac84 100644
@@ -6756,6 +6756,7 @@ static void perf_fill_ns_link_info(struct perf_ns_link_info *ns_link_info,
 		ns_inode = ns_path.dentry->d_inode;
 		ns_link_info->dev = new_encode_dev(ns_inode->i_sb->s_dev);
 		ns_link_info->ino = ns_inode->i_ino;
+		path_put(&ns_path);
 	}
 }
 
Signature · 1 line
2.7.4
#1 lore raw

[tip:perf/urgent] perf/core: Fix memory leak triggered by perf --namespace

perf/core: Fix memory leak triggered by perf --namespace
Commit-ID:  4a31b424ac0656d1bb17520ee861144fe7a19664
Gitweb:     https://git.kernel.org/tip/4a31b424ac0656d1bb17520ee861144fe7a19664
Author:     Vasily Averin <[email protected]>
AuthorDate: Wed, 15 Nov 2017 08:47:02 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 15 Nov 2017 09:48:10 +0100

perf/core: Fix memory leak triggered by perf --namespace

perf with --namespace key leaks various memory objects including namespaces

4.14.0+

  pid_namespace          1     12   2568   12    8
  user_namespace         1     39    824   39    8
  net_namespace          1      5   6272    5    8

This happen because perf_fill_ns_link_info() struct patch ns_path:
during initialization ns_path incremented counters on related mnt and dentry, but without lost path_put nobody decremented them back.
Leaked dentry is name of related namespace,
and its leak does not allow to free unused namespace.

Cc Alexander Shishkin <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Hari Bathini <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Thomas Gleixner <[email protected]>
Fixes commit e422267322cd ("perf: Add PERF_RECORD_NAMESPACES to include namespaces related info")
---
 kernel/events/core.c | 1 +
 1 file changed, 1 insertion(+)
kernel/events/core.c +1 -0
index 10cdb9c..ab5ac84 100644
@@ -6756,6 +6756,7 @@ static void perf_fill_ns_link_info(struct perf_ns_link_info *ns_link_info,
 		ns_inode = ns_path.dentry->d_inode;
 		ns_link_info->dev = new_encode_dev(ns_inode->i_sb->s_dev);
 		ns_link_info->ino = ns_inode->i_ino;
+		path_put(&ns_path);
 	}
 }
 
#2 lore raw

[tip:perf/urgent] perf/core: Fix memory leak triggered by perf --namespace

In reply to Vasily Averin
perf/core: Fix memory leak triggered by perf --namespace
Commit-ID:  0e18dd12064e07519f7cbff4149ca7fff620cbed
Gitweb:     https://git.kernel.org/tip/0e18dd12064e07519f7cbff4149ca7fff620cbed
Author:     Vasily Averin <[email protected]>
AuthorDate: Wed, 15 Nov 2017 08:47:02 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 15 Nov 2017 09:47:27 +0100

perf/core: Fix memory leak triggered by perf --namespace

perf with --namespace key leaks various memory objects including namespaces

4.14.0+

  pid_namespace          1     12   2568   12    8
  user_namespace         1     39    824   39    8
  net_namespace          1      5   6272    5    8

This happen because perf_fill_ns_link_info() struct patch ns_path:
during initialization ns_path incremented counters on related mnt and dentry, but without lost path_put nobody decremented them back.
Leaked dentry is name of related namespace,
and its leak does not allow to free unused namespace.

Cc Alexander Shishkin <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Hari Bathini <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Thomas Gleixner <[email protected]>
Fixes commit e422267322cd ("perf: Add PERF_RECORD_NAMESPACES to include namespaces related info")
---
 kernel/events/core.c | 1 +
 1 file changed, 1 insertion(+)
kernel/events/core.c +1 -0
index 10cdb9c..ab5ac84 100644
@@ -6756,6 +6756,7 @@ static void perf_fill_ns_link_info(struct perf_ns_link_info *ns_link_info,
 		ns_inode = ns_path.dentry->d_inode;
 		ns_link_info->dev = new_encode_dev(ns_inode->i_sb->s_dev);
 		ns_link_info->ino = ns_inode->i_ino;
+		path_put(&ns_path);
 	}
 }