Skip to contentSkip to conversation

sctp: fix /proc/net/sctp/ memory leak

PATCH Superseded Tommi Rantala 2 participants 2 messages Nov 15, 2012

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp: fix /proc/net/sctp/ memory leak

We are using single_open_net() and seq_open_net() in the opener functions, so avoid leaking memory by using single_release_net() and seq_release_net() as the struct file_operations release functions.

Discovered with Trinity (the syscall fuzzer).

---
 net/sctp/proc.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/sctp/proc.c +4 -4
index c3bea26..9966e7b 100644
@@ -102,7 +102,7 @@ static const struct file_operations sctp_snmp_seq_fops = {
 	.open	 = sctp_snmp_seq_open,
 	.read	 = seq_read,
 	.llseek	 = seq_lseek,
-	.release = single_release,
+	.release = single_release_net,
 };
 
 /* Set up the proc fs entry for 'snmp' object. */
@@ -251,7 +251,7 @@ static const struct file_operations sctp_eps_seq_fops = {
 	.open	 = sctp_eps_seq_open,
 	.read	 = seq_read,
 	.llseek	 = seq_lseek,
-	.release = seq_release,
+	.release = seq_release_net,
 };
 
 /* Set up the proc fs entry for 'eps' object. */
@@ -372,7 +372,7 @@ static const struct file_operations sctp_assocs_seq_fops = {
 	.open	 = sctp_assocs_seq_open,
 	.read	 = seq_read,
 	.llseek	 = seq_lseek,
-	.release = seq_release,
+	.release = seq_release_net,
 };
 
 /* Set up the proc fs entry for 'assocs' object. */
@@ -517,7 +517,7 @@ static const struct file_operations sctp_remaddr_seq_fops = {
 	.open = sctp_remaddr_seq_open,
 	.read = seq_read,
 	.llseek = seq_lseek,
-	.release = seq_release,
+	.release = seq_release_net,
 };
 
 int __net_init sctp_remaddr_proc_init(struct net *net)
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 17 lines · Tommi Rantala

We are using single_open_net() and seq_open_net() in the opener functions, so avoid leaking memory by using single_release_net() and seq_release_net() as the struct file_operations release functions.

Discovered with Trinity (the syscall fuzzer).

---
 net/sctp/proc.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/sctp/proc.c +0 -0
index c3bea26..9966e7b 100644

net/sctp/proc.c static const struct file_operations sctp_snmp_seq_fops = { · line 107

Quoted 7 lines
net/sctp/proc.c +1 -1
@@ -102,7 +102,7 @@ static const struct file_operations sctp_snmp_seq_fops = {
 	.open	 = sctp_snmp_seq_open,
 	.read	 = seq_read,
 	.llseek	 = seq_lseek,
-	.release = single_release,
+	.release = single_release_net,
 };
 

It seems you forgot to do do some work to pinpoint which commit added this bug. Please add this in the changelog to ease maintainer and stable teams work, and CC the author of said commit so that he has a chance to Ack your patch.

Thanks !