Skip to contentSkip to conversation

SELinux: memory leak in selinux_sb_copy_data()

PATCH In review Gerald Schaefer 2 participants 5 messages Jun 17, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SELinux: memory leak in selinux_sb_copy_data()

[PATCH 1/1] SELinux: memory leak in selinux_sb_copy_data()
There is a memory leak during mount when SELinux is active and mount options are specified.

---

security/selinux/hooks.c 2005-06-17 14:38:08.000000000 +0200 renamed from security/selinux/hooks.c 2005-06-16 20:01:03.000000000 +0200 +1 -0
diff -pruN linux-2.6-git/security/selinux/hooks.c linux-2.6-git_xxx/security/selinux/hooks.c
@@ -1945,6 +1945,7 @@ static int selinux_sb_copy_data(struct f
        } while (*in_end++);
 
        copy_page(in_save, nosec_save);
+       free_page((unsigned long)nosec);
 out:
        return rc;
 }
#1 lore raw
Quoted 12 lines · Gerald Schaefer

[PATCH 1/1] SELinux: memory leak in selinux_sb_copy_data()
There is a memory leak during mount when SELinux is active and mount options are specified.

---

diff -pruN linux-2.6-git/security/selinux/hooks.c linux-2.6-git_xxx/security/selinux/hooks.c

security/selinux/hooks.c 2005-06-17 14:38:08.000000000 +0200 static int selinux_sb_copy_data(struct f · line 1951

Quoted 7 lines
security/selinux/hooks.c 2005-06-17 14:38:08.000000000 +0200 renamed from security/selinux/hooks.c 2005-06-16 20:01:03.000000000 +0200 +1 -0
@@ -1945,6 +1945,7 @@ static int selinux_sb_copy_data(struct f
        } while (*in_end++);
 
        copy_page(in_save, nosec_save);
+       free_page((unsigned long)nosec);
 out:
        return rc;
 }

Sorry, there was a whitespace accident and the above patch would not apply.
Here is the fixed version:

security/selinux/hooks.c +1 -0
diff -pruN linux-2.6-git/security/selinux/hooks.c linux-2.6-git_xxx/security/selinux/hooks.c
@@ -1945,6 +1945,7 @@ static int selinux_sb_copy_data(struct f
 	} while (*in_end++);
 
 	copy_page(in_save, nosec_save);
+	free_page((unsigned long)nosec);
 out:
 	return rc;
 }
#2 lore raw
Quoted 8 lines · Gerald Schaefer

Sorry, there was a whitespace accident and the above patch would not apply.
Here is the fixed version:

diff -pruN linux-2.6-git/security/selinux/hooks.c linux-2.6-git_xxx/security/selinux/hooks.c

security/selinux/hooks.c static int selinux_sb_copy_data(struct f · line 1951

Quoted 7 lines
security/selinux/hooks.c +1 -0
@@ -1945,6 +1945,7 @@ static int selinux_sb_copy_data(struct f
 	} while (*in_end++);
 
 	copy_page(in_save, nosec_save);
+	free_page((unsigned long)nosec);
 out:
 	return rc;
 }

Shouldn't that be nosec_save? nosec is advanced by take_option().

Signature · 2 lines
Stephen Smalley
National Security Agency
#3 lore raw
Quoted 3 lines · Stephen Smalley

Shouldn't that be nosec_save? nosec is advanced by take_option().

That's right, I muddled that up. Hope I got this one-line patch right this time...

security/selinux/hooks.c +1 -0
diff -pruN linux-2.6-git/security/selinux/hooks.c linux-2.6-git_xxx/security/selinux/hooks.c
@@ -1945,6 +1945,7 @@ static int selinux_sb_copy_data(struct f
 	} while (*in_end++);
 
 	copy_page(in_save, nosec_save);
+	free_page((unsigned long)nosec_save);
 out:
 	return rc;
 }
#4 lore raw
Quoted 11 lines · Gerald Schaefer
Quoted 3 lines · Stephen Smalley

Shouldn't that be nosec_save? nosec is advanced by take_option().

That's right, I muddled that up. Hope I got this one-line patch right this time...

diff -pruN linux-2.6-git/security/selinux/hooks.c linux-2.6-git_xxx/security/selinux/hooks.c

security/selinux/hooks.c static int selinux_sb_copy_data(struct f · line 1951

Quoted 7 lines
security/selinux/hooks.c +1 -0
@@ -1945,6 +1945,7 @@ static int selinux_sb_copy_data(struct f
 	} while (*in_end++);
 
 	copy_page(in_save, nosec_save);
+	free_page((unsigned long)nosec_save);
 out:
 	return rc;
 }

Thanks, looks fine.

Signature · 2 lines
Stephen Smalley
National Security Agency