All of lore.kernel.org
 help / color / mirror / Atom feed
* Toolchain is broken?
@ 2011-08-27  7:45 HarryCiao
  2011-08-27  8:00 ` HarryCiao
  0 siblings, 1 reply; 8+ messages in thread
From: HarryCiao @ 2011-08-27  7:45 UTC (permalink / raw)
  To: selinux

[-- Attachment #1: Type: text/plain, Size: 927 bytes --]


Hi,

When I am improving my patchset to discard unused branches of tunable conditionals these days, I run into a new segfault issue that seems has nothing to do with my patchset. After I checked back to the master branch for both toolchain and refpolicy and pulled the latest codes, the segfault still exist.

Turns out the problem lies in genhomedircon.c, the level argument passed to set_fallback_user is NULL, and strdup(NULL) would segfault in the end. Below is the debug message I've seen:

genhomedircon.c Entered set_fallback_user, user = user_u, prefix = user, level = (null)
Passing NULL to strdup would segfault
make: *** [load] Segmentation fault

Has anyone else also run into the same problem? I didn't run into it before Aug 23rd, if this is a real problem, then it must have been introduced after that date.

So far I am pretty new to the semanage code, any idea to fix this issue?

Thanks,
Harry


 		 	   		  

[-- Attachment #2: Type: text/html, Size: 1188 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Toolchain is broken?
  2011-08-27  7:45 Toolchain is broken? HarryCiao
@ 2011-08-27  8:00 ` HarryCiao
  2011-08-27 13:46   ` Eric Paris
  0 siblings, 1 reply; 8+ messages in thread
From: HarryCiao @ 2011-08-27  8:00 UTC (permalink / raw)
  To: selinux

[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]


BTW, on my box this problem could temporarily worked around by specifying "disable-genhomedircon = true". 

From: harrytaurus2002@hotmail.com
To: selinux@tycho.nsa.gov
Subject: Toolchain is broken?
Date: Sat, 27 Aug 2011 07:45:11 +0000








Hi,

When I am improving my patchset to discard unused branches of tunable conditionals these days, I run into a new segfault issue that seems has nothing to do with my patchset. After I checked back to the master branch for both toolchain and refpolicy and pulled the latest codes, the segfault still exist.

Turns out the problem lies in genhomedircon.c, the level argument passed to set_fallback_user is NULL, and strdup(NULL) would segfault in the end. Below is the debug message I've seen:

genhomedircon.c Entered set_fallback_user, user = user_u, prefix = user, level = (null)
Passing NULL to strdup would segfault
make: *** [load] Segmentation fault

Has anyone else also run into the same problem? I didn't run into it before Aug 23rd, if this is a real problem, then it must have been introduced after that date.

So far I am pretty new to the semanage code, any idea to fix this issue?

Thanks,
Harry


 		 	   		   		 	   		  

[-- Attachment #2: Type: text/html, Size: 1775 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Toolchain is broken?
  2011-08-27  8:00 ` HarryCiao
@ 2011-08-27 13:46   ` Eric Paris
  2011-08-29  5:41     ` HarryCiao
  2011-08-29 11:28     ` Russell Coker
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Paris @ 2011-08-27 13:46 UTC (permalink / raw)
  To: HarryCiao; +Cc: selinux, russell

Must have come from this patch.

commit d784fd71b56cb8f57d5b9fcd784094e004bf7c6a
Author: Russell Coker <russell@coker.com.au>
Date:   Wed Jan 5 19:30:25 2011 +1100

    libsemanage: patch for MCS/MLS in user files

Russell, do you know what's going on?

-Eric

2011/8/27 HarryCiao <harrytaurus2002@hotmail.com>:
> BTW, on my box this problem could temporarily worked around by specifying
> "disable-genhomedircon = true".
>
> ________________________________
> From: harrytaurus2002@hotmail.com
> To: selinux@tycho.nsa.gov
> Subject: Toolchain is broken?
> Date: Sat, 27 Aug 2011 07:45:11 +0000
>
> Hi,
>
> When I am improving my patchset to discard unused branches of tunable
> conditionals these days, I run into a new segfault issue that seems has
> nothing to do with my patchset. After I checked back to the master branch
> for both toolchain and refpolicy and pulled the latest codes, the segfault
> still exist.
>
> Turns out the problem lies in genhomedircon.c, the level argument passed to
> set_fallback_user is NULL, and strdup(NULL) would segfault in the end. Below
> is the debug message I've seen:
>
> genhomedircon.c Entered set_fallback_user, user = user_u, prefix = user,
> level = (null)
> Passing NULL to strdup would segfault
> make: *** [load] Segmentation fault
>
> Has anyone else also run into the same problem? I didn't run into it before
> Aug 23rd, if this is a real problem, then it must have been introduced after
> that date.
>
> So far I am pretty new to the semanage code, any idea to fix this issue?
>
> Thanks,
> Harry
>
>
>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Toolchain is broken?
  2011-08-27 13:46   ` Eric Paris
@ 2011-08-29  5:41     ` HarryCiao
  2011-08-29 11:28     ` Russell Coker
  1 sibling, 0 replies; 8+ messages in thread
From: HarryCiao @ 2011-08-29  5:41 UTC (permalink / raw)
  Cc: selinux, russell

[-- Attachment #1: Type: text/plain, Size: 2168 bytes --]


Yep, just verified that revert this commit and the problem would go away.

> Date: Sat, 27 Aug 2011 09:46:41 -0400
> Subject: Re: Toolchain is broken?
> From: eparis@parisplace.org
> To: harrytaurus2002@hotmail.com
> CC: selinux@tycho.nsa.gov; russell@coker.com.au
> 
> Must have come from this patch.
> 
> commit d784fd71b56cb8f57d5b9fcd784094e004bf7c6a
> Author: Russell Coker <russell@coker.com.au>
> Date:   Wed Jan 5 19:30:25 2011 +1100
> 
>     libsemanage: patch for MCS/MLS in user files
> 
> Russell, do you know what's going on?
> 
> -Eric
> 
> 2011/8/27 HarryCiao <harrytaurus2002@hotmail.com>:
> > BTW, on my box this problem could temporarily worked around by specifying
> > "disable-genhomedircon = true".
> >
> > ________________________________
> > From: harrytaurus2002@hotmail.com
> > To: selinux@tycho.nsa.gov
> > Subject: Toolchain is broken?
> > Date: Sat, 27 Aug 2011 07:45:11 +0000
> >
> > Hi,
> >
> > When I am improving my patchset to discard unused branches of tunable
> > conditionals these days, I run into a new segfault issue that seems has
> > nothing to do with my patchset. After I checked back to the master branch
> > for both toolchain and refpolicy and pulled the latest codes, the segfault
> > still exist.
> >
> > Turns out the problem lies in genhomedircon.c, the level argument passed to
> > set_fallback_user is NULL, and strdup(NULL) would segfault in the end. Below
> > is the debug message I've seen:
> >
> > genhomedircon.c Entered set_fallback_user, user = user_u, prefix = user,
> > level = (null)
> > Passing NULL to strdup would segfault
> > make: *** [load] Segmentation fault
> >
> > Has anyone else also run into the same problem? I didn't run into it before
> > Aug 23rd, if this is a real problem, then it must have been introduced after
> > that date.
> >
> > So far I am pretty new to the semanage code, any idea to fix this issue?
> >
> > Thanks,
> > Harry
> >
> >
> >
> 
> --
> This message was distributed to subscribers of the selinux mailing list.
> If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
> the words "unsubscribe selinux" without quotes as the message.
 		 	   		  

[-- Attachment #2: Type: text/html, Size: 2885 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Toolchain is broken?
  2011-08-27 13:46   ` Eric Paris
  2011-08-29  5:41     ` HarryCiao
@ 2011-08-29 11:28     ` Russell Coker
  2011-08-30  5:40       ` HarryCiao
  1 sibling, 1 reply; 8+ messages in thread
From: Russell Coker @ 2011-08-29 11:28 UTC (permalink / raw)
  To: Eric Paris; +Cc: HarryCiao, selinux

[-- Attachment #1: Type: Text/Plain, Size: 434 bytes --]

On Sat, 27 Aug 2011, Eric Paris <eparis@parisplace.org> wrote:
> Must have come from this patch.
> 
> commit d784fd71b56cb8f57d5b9fcd784094e004bf7c6a
> Author: Russell Coker <russell@coker.com.au>
> Date:   Wed Jan 5 19:30:25 2011 +1100
> 
>     libsemanage: patch for MCS/MLS in user files
> 

What do you think of the attached patch?

-- 
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/

[-- Attachment #2: diff2 --]
[-- Type: text/x-patch, Size: 1498 bytes --]

diff -ru libsemanage-2.0.46.old/src/genhomedircon.c libsemanage-2.0.46/src/genhomedircon.c
--- libsemanage-2.0.46.old/src/genhomedircon.c	2011-08-29 19:51:05.000000000 +1000
+++ libsemanage-2.0.46/src/genhomedircon.c	2011-08-29 20:18:23.000000000 +1000
@@ -629,9 +629,12 @@
 	home = strdup(h);
 	if (!home)
 		goto cleanup;
-	level = strdup(l);
-	if (!level)
-		goto cleanup;
+	if(l)
+	{
+		level = strdup(l);
+		if (!level)
+			goto cleanup;
+	}
 
 	temp->name = name;
 	temp->sename = sename;
@@ -675,15 +678,18 @@
 {
 	char *fallback_user = strdup(user);
 	char *fallback_user_prefix = strdup(prefix);
-	char *fallback_user_level = strdup(level);
+	char *fallback_user_level;
 
-	if (fallback_user == NULL || fallback_user_prefix == NULL || fallback_user_level == NULL) {
+	if (fallback_user == NULL || fallback_user_prefix == NULL) {
 		free(fallback_user);
 		free(fallback_user_prefix);
 		free(fallback_user_level);
 		return STATUS_ERR;
 	}
 
+	if(level)
+		fallback_user_level = strdup(level);
+
 	free(s->fallback_user);
 	free(s->fallback_user_prefix);
 	free(s->fallback_user_level);
@@ -727,7 +733,7 @@
 			if (semanage_user_query(s->h_semanage, key, &the_user) < 0)
 			{
 				prefix = name;
-				level = "s0";
+				level = FALLBACK_USER_LEVEL;
 			}
 			else
 			{
@@ -818,7 +824,7 @@
 			level = semanage_user_get_mlslevel(*u);
 		} else {
 			prefix = name;
-			level = "s0";
+			level = FALLBACK_USER_LEVEL;
 		}
 
 		retval = getpwnam_r(name, &pwstorage, rbuf, rbuflen, &pwent);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Toolchain is broken?
  2011-08-29 11:28     ` Russell Coker
@ 2011-08-30  5:40       ` HarryCiao
  2011-09-07 21:39         ` Eric Paris
  0 siblings, 1 reply; 8+ messages in thread
From: HarryCiao @ 2011-08-30  5:40 UTC (permalink / raw)
  To: russell, eparis; +Cc: selinux

[-- Attachment #1: Type: text/plain, Size: 2155 bytes --]


Hi Russell,

Please explicitly set fallback_user_level = NULL; or have "s->fallback_user_level = fallback_user_level;" controlled by if(level) too.

Unfortunately, this patch won't fix the segfault issue for standard refpolicy(BTW, the MLS refpolicy could be compiled/linked/expanded uneventfully) and I got below backtrace information from gdb:

Program received signal SIGSEGV, Segmentation fault.
0x00007fb03c2fd052 in ?? () from /lib/libc.so.6
(gdb) bt
#0  0x00007fb03c2fd052 in ?? () from /lib/libc.so.6
#1  0x00007fb03bc4e691 in ustr_replace_cstr () from /usr/lib/libustr-1.0.so.1
#2  0x00007fb03c615846 in replace_all (
    str=0xac3ab10 "HOME_DIR/.+\tsystem_u:object_r:user_home_t", 
    repl=0x7fff5d711cd0) at genhomedircon.c:442
#3  0x00007fb03c615ad8 in write_home_dir_context (s=0x7fff5d711df0, 
    out=0x10301f50, tpl=0xe2dc170, user=0xe25cec0 "user_u", 
    seuser=0xe25cec0 "user_u", home=0xe2913d3 "/home/[^/]*", 
    role_prefix=0xe261d30 "user", level=0x0) at genhomedircon.c:509
#4  0x00007fb03c616b50 in write_context_file (s=0x7fff5d711df0, out=0x10301f50)
    at genhomedircon.c:942
#5  0x00007fb03c616df0 in semanage_genhomedircon (sh=0x228b790, 
    policydb=0xaab4370, usepasswd=1) at genhomedircon.c:1017
#6  0x00007fb03c611baa in semanage_direct_commit (sh=0x228b790)
    at direct_api.c:1008
#7  0x00007fb03c617c44 in semanage_commit (sh=0x228b790) at handle.c:435
#8  0x0000000000402471 in main ()
(gdb) 

I didn't go further than that.

Thanks,
Harry


> From: russell@coker.com.au
> To: eparis@parisplace.org
> Subject: Re: Toolchain is broken?
> Date: Mon, 29 Aug 2011 21:28:50 +1000
> CC: harrytaurus2002@hotmail.com; selinux@tycho.nsa.gov
> 
> On Sat, 27 Aug 2011, Eric Paris <eparis@parisplace.org> wrote:
> > Must have come from this patch.
> > 
> > commit d784fd71b56cb8f57d5b9fcd784094e004bf7c6a
> > Author: Russell Coker <russell@coker.com.au>
> > Date:   Wed Jan 5 19:30:25 2011 +1100
> > 
> >     libsemanage: patch for MCS/MLS in user files
> > 
> 
> What do you think of the attached patch?
> 
> -- 
> My Main Blog         http://etbe.coker.com.au/
> My Documents Blog    http://doc.coker.com.au/
 		 	   		  

[-- Attachment #2: Type: text/html, Size: 2809 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Toolchain is broken?
  2011-08-30  5:40       ` HarryCiao
@ 2011-09-07 21:39         ` Eric Paris
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Paris @ 2011-09-07 21:39 UTC (permalink / raw)
  To: HarryCiao; +Cc: russell, selinux

Russell, thoughts?

2011/8/30 HarryCiao <harrytaurus2002@hotmail.com>:
> Hi Russell,
>
> Please explicitly set fallback_user_level = NULL; or have
> "s->fallback_user_level = fallback_user_level;" controlled by if(level) too.
>
> Unfortunately, this patch won't fix the segfault issue for standard
> refpolicy(BTW, the MLS refpolicy could be compiled/linked/expanded
> uneventfully) and I got below backtrace information from gdb:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007fb03c2fd052 in ?? () from /lib/libc.so.6
> (gdb) bt
> #0  0x00007fb03c2fd052 in ?? () from /lib/libc.so.6
> #1  0x00007fb03bc4e691 in ustr_replace_cstr () from
> /usr/lib/libustr-1.0.so.1
> #2  0x00007fb03c615846 in replace_all (
>     str=0xac3ab10 "HOME_DIR/.+\tsystem_u:object_r:user_home_t",
>     repl=0x7fff5d711cd0) at genhomedircon.c:442
> #3  0x00007fb03c615ad8 in write_home_dir_context (s=0x7fff5d711df0,
>     out=0x10301f50, tpl=0xe2dc170, user=0xe25cec0 "user_u",
>     seuser=0xe25cec0 "user_u", home=0xe2913d3 "/home/[^/]*",
>     role_prefix=0xe261d30 "user", level=0x0) at genhomedircon.c:509
> #4  0x00007fb03c616b50 in write_context_file (s=0x7fff5d711df0,
> out=0x10301f50)
>     at genhomedircon.c:942
> #5  0x00007fb03c616df0 in semanage_genhomedircon (sh=0x228b790,
>     policydb=0xaab4370, usepasswd=1) at genhomedircon.c:1017
> #6  0x00007fb03c611baa in semanage_direct_commit (sh=0x228b790)
>     at direct_api.c:1008
> #7  0x00007fb03c617c44 in semanage_commit (sh=0x228b790) at handle.c:435
> #8  0x0000000000402471 in main ()
> (gdb)
>
> I didn't go further than that.
>
> Thanks,
> Harry
>
>
>> From: russell@coker.com.au
>> To: eparis@parisplace.org
>> Subject: Re: Toolchain is broken?
>> Date: Mon, 29 Aug 2011 21:28:50 +1000
>> CC: harrytaurus2002@hotmail.com; selinux@tycho.nsa.gov
>>
>> On Sat, 27 Aug 2011, Eric Paris <eparis@parisplace.org> wrote:
>> > Must have come from this patch.
>> >
>> > commit d784fd71b56cb8f57d5b9fcd784094e004bf7c6a
>> > Author: Russell Coker <russell@coker.com.au>
>> > Date: Wed Jan 5 19:30:25 2011 +1100
>> >
>> > libsemanage: patch for MCS/MLS in user files
>> >
>>
>> What do you think of the attached patch?
>>
>> --
>> My Main Blog http://etbe.coker.com.au/
>> My Documents Blog http://doc.coker.com.au/
>


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Toolchain is broken?
@ 2011-08-27  7:45 HarryCiao
  0 siblings, 0 replies; 8+ messages in thread
From: HarryCiao @ 2011-08-27  7:45 UTC (permalink / raw)
  To: selinux

[-- Attachment #1: Type: text/plain, Size: 927 bytes --]


Hi,

When I am improving my patchset to discard unused branches of tunable conditionals these days, I run into a new segfault issue that seems has nothing to do with my patchset. After I checked back to the master branch for both toolchain and refpolicy and pulled the latest codes, the segfault still exist.

Turns out the problem lies in genhomedircon.c, the level argument passed to set_fallback_user is NULL, and strdup(NULL) would segfault in the end. Below is the debug message I've seen:

genhomedircon.c Entered set_fallback_user, user = user_u, prefix = user, level = (null)
Passing NULL to strdup would segfault
make: *** [load] Segmentation fault

Has anyone else also run into the same problem? I didn't run into it before Aug 23rd, if this is a real problem, then it must have been introduced after that date.

So far I am pretty new to the semanage code, any idea to fix this issue?

Thanks,
Harry


 		 	   		  

[-- Attachment #2: Type: text/html, Size: 1188 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-09-07 21:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-27  7:45 Toolchain is broken? HarryCiao
2011-08-27  8:00 ` HarryCiao
2011-08-27 13:46   ` Eric Paris
2011-08-29  5:41     ` HarryCiao
2011-08-29 11:28     ` Russell Coker
2011-08-30  5:40       ` HarryCiao
2011-09-07 21:39         ` Eric Paris
  -- strict thread matches above, loose matches on Subject: below --
2011-08-27  7:45 HarryCiao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.