Skip to contentSkip to conversation

core dump

PATCH In review Stefanos Harhalakis 3 participants 8 messages Feb 6, 2007 SELinux security module

lore
Share & tools
lore
#0 lore raw

I had this issue today:

# semodule -i logging.pp 
Segmentation fault (core dumped)

I traced this a bit and it seems that this is because of libsepol. The core dump is the result of lines 602:603 of link.c:

(gdb) bt

#0  0xb7f732fd in sens_copy_callback (key=0x848c2a0 "s15", datum=0x848c290, data=0xbfde3854) at link.c:602
#1  0xb7f6f8a1 in hashtab_map (h=0x846cbf0, apply=0xb7f731d1 <sens_copy_callback>, args=0xbfde3854) at hashtab.c:214
#2  0xb7f75528 in copy_identifiers (state=0xbfde3854, src_symtab=0x843cc74, dest_decl=0x0) at link.c:1323
#3  0xb7f77c72 in link_modules (handle=0x804c710, b=0x80525b8, mods=0x863ce18, len=19, verbose=0) at link.c:2178
#4  0xb7f7a2c9 in sepol_link_packages (handle=0x804c710, base=0x8053060, modules=0x80543c8, num_modules=19, verbose=0) at module.c:302

Where:

(gdb) l
597 state->cur_mod_name);
598 return -SEPOL_LINK_NOTSUP;
599 }
600 }
601
602 state->cur->map[SYM_LEVELS][level->level->sens - 1] =
603 base_level->level->sens;
604
605 return 0;
606 }

Because of:

(gdb) p base_level
$1 = (level_datum_t *) 0x0

The last 'if' checks for !base_level, but inside the 'if' block, only !scope and scope->scope==SCOPE_DECL are checked.

This core dump is caused by:

(gdb) p scope->scope
$2 = 1

Which is noted as:

/* Required for this decl */
#define SCOPE_REQ 1

in libsepol/include/sepol/policydb/policydb.h

Hope this helps...

<<V13>>

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 42 lines · Stefanos Harhalakis

I had this issue today:

# semodule -i logging.pp 
Segmentation fault (core dumped)

I traced this a bit and it seems that this is because of libsepol. The core dump is the result of lines 602:603 of link.c:

(gdb) bt

#0  0xb7f732fd in sens_copy_callback (key=0x848c2a0 "s15", datum=0x848c290, data=0xbfde3854) at link.c:602
#1  0xb7f6f8a1 in hashtab_map (h=0x846cbf0, apply=0xb7f731d1 <sens_copy_callback>, args=0xbfde3854) at hashtab.c:214
#2  0xb7f75528 in copy_identifiers (state=0xbfde3854, src_symtab=0x843cc74, dest_decl=0x0) at link.c:1323
#3  0xb7f77c72 in link_modules (handle=0x804c710, b=0x80525b8, mods=0x863ce18, len=19, verbose=0) at link.c:2178
#4  0xb7f7a2c9 in sepol_link_packages (handle=0x804c710, base=0x8053060, modules=0x80543c8, num_modules=19, verbose=0) at module.c:302

Where:

(gdb) l
597 state->cur_mod_name);
598 return -SEPOL_LINK_NOTSUP;
599 }
600 }
601
602 state->cur->map[SYM_LEVELS][level->level->sens - 1] =
603 base_level->level->sens;
604
605 return 0;
606 }

Because of:

(gdb) p base_level
$1 = (level_datum_t *) 0x0

The last 'if' checks for !base_level, but inside the 'if' block, only !scope and scope->scope==SCOPE_DECL are checked.

This core dump is caused by:

(gdb) p scope->scope
$2 = 1

Quoted 8 lines

Which is noted as:

/* Required for this decl */
#define SCOPE_REQ 1

in libsepol/include/sepol/policydb/policydb.h

Hope this helps...

Looks like your logging.pp policy module has a requires on sensitivity s15 but your base module doesn't declare it. Naturally, that should show up as an unfulfilled requirement rather than a seg fault.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw

PATCH 1/1 libsepol: check for unmet requires on sensitivities and categories (Was: Re: core dump)

Quoted 48 lines · Stephen Smalley
Quoted 47 lines · Stefanos Harhalakis

I had this issue today:

# semodule -i logging.pp 
Segmentation fault (core dumped)

I traced this a bit and it seems that this is because of libsepol. The core dump is the result of lines 602:603 of link.c:

(gdb) bt

#0  0xb7f732fd in sens_copy_callback (key=0x848c2a0 "s15", datum=0x848c290, data=0xbfde3854) at link.c:602
#1  0xb7f6f8a1 in hashtab_map (h=0x846cbf0, apply=0xb7f731d1 <sens_copy_callback>, args=0xbfde3854) at hashtab.c:214
#2  0xb7f75528 in copy_identifiers (state=0xbfde3854, src_symtab=0x843cc74, dest_decl=0x0) at link.c:1323
#3  0xb7f77c72 in link_modules (handle=0x804c710, b=0x80525b8, mods=0x863ce18, len=19, verbose=0) at link.c:2178
#4  0xb7f7a2c9 in sepol_link_packages (handle=0x804c710, base=0x8053060, modules=0x80543c8, num_modules=19, verbose=0) at module.c:302

Where:

(gdb) l
597 state->cur_mod_name);
598 return -SEPOL_LINK_NOTSUP;
599 }
600 }
601
602 state->cur->map[SYM_LEVELS][level->level->sens - 1] =
603 base_level->level->sens;
604
605 return 0;
606 }

Because of:

(gdb) p base_level
$1 = (level_datum_t *) 0x0

The last 'if' checks for !base_level, but inside the 'if' block, only !scope and scope->scope==SCOPE_DECL are checked.

This core dump is caused by:

(gdb) p scope->scope
$2 = 1

Which is noted as:

/* Required for this decl */
#define SCOPE_REQ 1

Quoted 7 lines
Quoted 3 lines

in libsepol/include/sepol/policydb/policydb.h

Hope this helps...

Looks like your logging.pp policy module has a requires on sensitivity s15 but your base module doesn't declare it. Naturally, that should show up as an unfulfilled requirement rather than a seg fault.

Patch below for the stable branch.

src/link.c +14 -0
Index: libsepol/src/link.c
===================================================================
@@ -597,6 +597,13 @@
 			    state->cur_mod_name);
 			return -SEPOL_LINK_NOTSUP;
 		}
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s:  Sensitivity %s not declared by base.\n",
+			    state->cur_mod_name, id);
+			return -SEPOL_LINK_NOTSUP;
+		}
 	}
 
 	state->cur->map[SYM_LEVELS][level->level->sens - 1] =
@@ -628,6 +635,13 @@
 			    state->cur_mod_name);
 			return -SEPOL_LINK_NOTSUP;
 		}
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s:  Category %s not declared by base.\n",
+			    state->cur_mod_name, id);
+			return -SEPOL_LINK_NOTSUP;
+		}
 	}
 
 	state->cur->map[SYM_CATS][cat->s.value - 1] = base_cat->s.value;
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw

Re: [patch -trunk] libsepol: check for unmet requires on sensitivities and categories (Was: Re: core dump)

Quoted 49 lines · Stephen Smalley
Quoted 48 lines · Stephen Smalley
Quoted 47 lines · Stefanos Harhalakis

I had this issue today:

# semodule -i logging.pp 
Segmentation fault (core dumped)

I traced this a bit and it seems that this is because of libsepol. The core dump is the result of lines 602:603 of link.c:

(gdb) bt

#0  0xb7f732fd in sens_copy_callback (key=0x848c2a0 "s15", datum=0x848c290, data=0xbfde3854) at link.c:602
#1  0xb7f6f8a1 in hashtab_map (h=0x846cbf0, apply=0xb7f731d1 <sens_copy_callback>, args=0xbfde3854) at hashtab.c:214
#2  0xb7f75528 in copy_identifiers (state=0xbfde3854, src_symtab=0x843cc74, dest_decl=0x0) at link.c:1323
#3  0xb7f77c72 in link_modules (handle=0x804c710, b=0x80525b8, mods=0x863ce18, len=19, verbose=0) at link.c:2178
#4  0xb7f7a2c9 in sepol_link_packages (handle=0x804c710, base=0x8053060, modules=0x80543c8, num_modules=19, verbose=0) at module.c:302

Where:

(gdb) l
597 state->cur_mod_name);
598 return -SEPOL_LINK_NOTSUP;
599 }
600 }
601
602 state->cur->map[SYM_LEVELS][level->level->sens - 1] =
603 base_level->level->sens;
604
605 return 0;
606 }

Because of:

(gdb) p base_level
$1 = (level_datum_t *) 0x0

The last 'if' checks for !base_level, but inside the 'if' block, only !scope and scope->scope==SCOPE_DECL are checked.

This core dump is caused by:

(gdb) p scope->scope
$2 = 1

Which is noted as:

/* Required for this decl */
#define SCOPE_REQ 1

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

in libsepol/include/sepol/policydb/policydb.h

Hope this helps...

Looks like your logging.pp policy module has a requires on sensitivity s15 but your base module doesn't declare it. Naturally, that should show up as an unfulfilled requirement rather than a seg fault.

Second patch below for the trunk (I also stripped the extraneous \n characters from the first patch locally).

src/link.c +14 -0
Index: libsepol/src/link.c
===================================================================
@@ -598,6 +598,13 @@
 			    state->cur_mod_name);
 			return SEPOL_ENOTSUP;
 		}
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s: Sensitivity %s not declared by base.",
+			    state->cur_mod_name, id);
+			return SEPOL_ENOTSUP;
+		}
 	}
 
 	state->cur->map[SYM_LEVELS][level->level->sens - 1] =
@@ -629,6 +636,13 @@
 			    state->cur_mod_name);
 			return SEPOL_ENOTSUP;
 		}
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s: Category %s not declared by base.",
+			    state->cur_mod_name, id);
+			return SEPOL_ENOTSUP;
+		}
 	}
 
 	state->cur->map[SYM_CATS][cat->s.value - 1] = base_cat->s.value;
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw

Re: [patch -trunk] libsepol: check for unmet requires on sensitivities and categories (Was: Re: core dump)

Quoted 6 lines · Stephen Smalley

On Tue, 2007-02-06 at 08:06 -0500, Stephen Smalley wrote:

Second patch below for the trunk (I also stripped the extraneous \n characters from the first patch locally).

Quoted 23 lines

Index: libsepol/src/link.c
===================================================================

src/link.c +7 -0
@@ -598,6 +598,13 @@
 			    state->cur_mod_name);
 			return SEPOL_ENOTSUP;
 		}
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s: Sensitivity %s not declared by base.",
+			    state->cur_mod_name, id);
+			return SEPOL_ENOTSUP;
+		}
 	}
 
 	state->cur->map[SYM_LEVELS][level->level->sens - 1] =
@@ -629,6 +636,13 @@
 			    state->cur_mod_name);
 			return SEPOL_ENOTSUP;
 		}

src/link.c line 648

Quoted 10 lines
src/link.c +7 -0
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s: Category %s not declared by base.",
+			    state->cur_mod_name, id);
+			return SEPOL_ENOTSUP;
+		}
 	}
 
 	state->cur->map[SYM_CATS][cat->s.value - 1] = base_cat->s.value;

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#5 lore raw

Re: [patch] libsepol: check for unmet requires on sensitivities and categories (Was: Re: core dump)

In reply to Stephen Smalley
Quoted 10 lines · Stephen Smalley

Patch below for the stable branch.

Index: libsepol/src/link.c
===================================================================

src/link.c +0 -0
@@ -597,6 +597,13 @@
 			    state->cur_mod_name);

src/link.c line 607

Quoted 10 lines
src/link.c +7 -0
 			return -SEPOL_LINK_NOTSUP;
 		}
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s:  Sensitivity %s not declared by base.\n",
+			    state->cur_mod_name, id);
+			return -SEPOL_LINK_NOTSUP;
+		}
 	}

May I recomend that an:

assert(0);

been added at the end of the outter if statement or there is no way that another SCOPE_ value will be added in the future. In the latter case, perhaps an enum (for the SCOPE_* values) and a switch() (instead of the ifs) would be better. gcc warns on switch() statements that don't handle all values of an enum.

<<V13>>

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#6 lore raw

Re: [patch] libsepol: check for unmet requires on sensitivities and categories (Was: Re: core dump)

Quoted 24 lines · V13 wrote:
Quoted 10 lines · Stephen Smalley

Patch below for the stable branch.

Index: libsepol/src/link.c
===================================================================

src/link.c +0 -0
@@ -597,6 +597,13 @@
 			    state->cur_mod_name);

src/link.c line 607

Quoted 10 lines
src/link.c +7 -0
 			return -SEPOL_LINK_NOTSUP;
 		}
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s:  Sensitivity %s not declared by base.\n",
+			    state->cur_mod_name, id);
+			return -SEPOL_LINK_NOTSUP;
+		}
 	}

May I recomend that an:

Quoted 3 lines

assert(0);

been added at the end of the outter if statement or there is no way that another SCOPE_ value will be added in the future.

I think this is a good practice in general, but it's not likely that another scope will be added.

In the latter case, perhaps

Quoted 2 lines

an enum (for the SCOPE_* values) and a switch() (instead of the ifs) would be better. gcc warns on switch() statements that don't handle all values of an enum.

Enums aren't used often in libsepol and I'd rather not change to that style now.

Thanks - Karl

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Acked-by on v1 1/1
#7 lore raw

Re: [patch] libsepol: check for unmet requires on sensitivities and categories (Was: Re: core dump)

In reply to Stephen Smalley
Quoted 46 lines · Stephen Smalley
Quoted 45 lines · Stephen Smalley
Quoted 44 lines · Stefanos Harhalakis

I had this issue today:

# semodule -i logging.pp Segmentation fault (core dumped)

I traced this a bit and it seems that this is because of libsepol. The core dump is the result of lines 602:603 of link.c:

(gdb) bt

#0  0xb7f732fd in sens_copy_callback (key=0x848c2a0 "s15", datum=0x848c290, data=0xbfde3854) at link.c:602
#1  0xb7f6f8a1 in hashtab_map (h=0x846cbf0, apply=0xb7f731d1 <sens_copy_callback>, args=0xbfde3854) at hashtab.c:214
#2  0xb7f75528 in copy_identifiers (state=0xbfde3854, src_symtab=0x843cc74, dest_decl=0x0) at link.c:1323
#3  0xb7f77c72 in link_modules (handle=0x804c710, b=0x80525b8, mods=0x863ce18, len=19, verbose=0) at link.c:2178
#4  0xb7f7a2c9 in sepol_link_packages (handle=0x804c710, base=0x8053060, modules=0x80543c8, num_modules=19, verbose=0) at module.c:302

Where:

(gdb) l
597 state->cur_mod_name);
598 return -SEPOL_LINK_NOTSUP;
599 }
600 }
601 602 state->cur->map[SYM_LEVELS][level->level->sens - 1] =
603 base_level->level->sens;
604 605 return 0;
606 }

Because of:

(gdb) p base_level
$1 = (level_datum_t *) 0x0

The last 'if' checks for !base_level, but inside the 'if' block, only !scope and scope->scope==SCOPE_DECL are checked.

This core dump is caused by:

(gdb) p scope->scope
$2 = 1

Which is noted as:

/* Required for this decl */
#define SCOPE_REQ 1

in libsepol/include/sepol/policydb/policydb.h

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Hope this helps...

Looks like your logging.pp policy module has a requires on sensitivity s15 but your base module doesn't declare it. Naturally, that should show up as an unfulfilled requirement rather than a seg fault.

Patch below for the stable branch.

Quoted 23 lines

Index: libsepol/src/link.c
===================================================================

src/link.c +7 -0
@@ -597,6 +597,13 @@
 			    state->cur_mod_name);
 			return -SEPOL_LINK_NOTSUP;
 		}
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s:  Sensitivity %s not declared by base.\n",
+			    state->cur_mod_name, id);
+			return -SEPOL_LINK_NOTSUP;
+		}
 	}
 
 	state->cur->map[SYM_LEVELS][level->level->sens - 1] =
@@ -628,6 +635,13 @@
 			    state->cur_mod_name);
 			return -SEPOL_LINK_NOTSUP;
 		}

src/link.c line 647

Quoted 10 lines
src/link.c +7 -0
+		if (scope->scope == SCOPE_REQ) {
+			/* unmet requirement */
+			ERR(state->handle,
+			    "%s:  Category %s not declared by base.\n",
+			    state->cur_mod_name, id);
+			return -SEPOL_LINK_NOTSUP;
+		}
 	}
 
 	state->cur->map[SYM_CATS][cat->s.value - 1] = base_cat->s.value;

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.