[PATCH][SELINUX] Fix error handling in selinuxfs

From: Stephen Smalley
Date: Mon May 17 2004 - 09:36:04 EST


Hi,

This patch against 2.6.6 fixes error handling for two out-of-memory
conditions in selinuxfs, avoiding potential deadlock due to returning
without releasing a semaphore. The patch was submitted by Karl
MacMillan of Tresys. Please apply.

security/selinux/selinuxfs.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)

Index: linux-2.6/security/selinux/selinuxfs.c
===================================================================
RCS file: /nfshome/pal/CVS/linux-2.6/security/selinux/selinuxfs.c,v
retrieving revision 1.43
diff -u -r1.43 selinuxfs.c
--- linux-2.6/security/selinux/selinuxfs.c 20 Apr 2004 15:40:22 -0000 1.43
+++ linux-2.6/security/selinux/selinuxfs.c 17 May 2004 14:11:03 -0000
@@ -833,8 +833,10 @@
goto out;
}
page = (char*)__get_free_page(GFP_KERNEL);
- if (!page)
- return -ENOMEM;
+ if (!page) {
+ length = -ENOMEM;
+ goto out;
+ }
memset(page, 0, PAGE_SIZE);

if (copy_from_user(page, buf, count))
@@ -889,8 +891,10 @@
goto out;
}
page = (char*)__get_free_page(GFP_KERNEL);
- if (!page)
- return -ENOMEM;
+ if (!page) {
+ length = -ENOMEM;
+ goto out;
+ }

memset(page, 0, PAGE_SIZE);



--
Stephen Smalley <sds@xxxxxxxxxxxxxx>
National Security Agency

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/