From: <mad...@us...> - 2007-07-09 17:38:22
|
Revision: 2492 http://svn.sourceforge.net/selinux/?rev=2492&view=rev Author: madmethod Date: 2007-07-09 10:38:19 -0700 (Mon, 09 Jul 2007) Log Message: ----------- Author: Stephen Smalley Email: sd...@ty... Subject: libselinux: fix getfilecon handling of zero-length context Date: Mon, 09 Jul 2007 12:45:53 -0400 As observed by John Ramsdell, *getfilecon() on a /proc/sys inode on returns garbage and can lead to memory corruption upon later freecon. This happens on 2.6.21 and later due to the proc sysctl rewrite in the kernel. The *getfilecon_raw() functions correctly return zero in this case, but the non-raw functions are not handling that result properly. Initialize *context on entry to *getfilecon() so that it has a well-defined value even if *getfilecon_raw() returns zero. Signed-off-by: Stephen Smalley <sd...@ty...> Acked-By: Joshua Brindle <me...@ma...> Modified Paths: -------------- trunk/libselinux/ChangeLog trunk/libselinux/VERSION trunk/libselinux/src/fgetfilecon.c trunk/libselinux/src/getfilecon.c trunk/libselinux/src/lgetfilecon.c Modified: trunk/libselinux/ChangeLog =================================================================== --- trunk/libselinux/ChangeLog 2007-07-09 17:35:49 UTC (rev 2491) +++ trunk/libselinux/ChangeLog 2007-07-09 17:38:19 UTC (rev 2492) @@ -1,3 +1,6 @@ +2.0.24 2007-09-07 + * Fix for getfilecon() for zero-length contexts from Stephen Smalley. + 2.0.23 2007-06-22 * Refactored SWIG bindings from James Athey. Modified: trunk/libselinux/VERSION =================================================================== --- trunk/libselinux/VERSION 2007-07-09 17:35:49 UTC (rev 2491) +++ trunk/libselinux/VERSION 2007-07-09 17:38:19 UTC (rev 2492) @@ -1 +1 @@ -2.0.23 +2.0.24 Modified: trunk/libselinux/src/fgetfilecon.c =================================================================== --- trunk/libselinux/src/fgetfilecon.c 2007-07-09 17:35:49 UTC (rev 2491) +++ trunk/libselinux/src/fgetfilecon.c 2007-07-09 17:38:19 UTC (rev 2492) @@ -51,6 +51,8 @@ security_context_t rcontext; int ret; + *context = NULL; + ret = fgetfilecon_raw(fd, &rcontext); if (ret > 0) { Modified: trunk/libselinux/src/getfilecon.c =================================================================== --- trunk/libselinux/src/getfilecon.c 2007-07-09 17:35:49 UTC (rev 2491) +++ trunk/libselinux/src/getfilecon.c 2007-07-09 17:38:19 UTC (rev 2492) @@ -51,6 +51,8 @@ int ret; security_context_t rcontext; + *context = NULL; + ret = getfilecon_raw(path, &rcontext); if (ret > 0) { Modified: trunk/libselinux/src/lgetfilecon.c =================================================================== --- trunk/libselinux/src/lgetfilecon.c 2007-07-09 17:35:49 UTC (rev 2491) +++ trunk/libselinux/src/lgetfilecon.c 2007-07-09 17:38:19 UTC (rev 2492) @@ -51,6 +51,8 @@ int ret; security_context_t rcontext; + *context = NULL; + ret = lgetfilecon_raw(path, &rcontext); if (ret > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |