All of lore.kernel.org
 help / color / mirror / Atom feed
* suggestion to help transition to selinux: dynamic loading of libselinux
@ 2004-05-15 23:26 Luke Kenneth Casson Leighton
  2004-05-17 19:10 ` Russell Coker
  2004-05-18 16:34 ` Stephen Smalley
  0 siblings, 2 replies; 18+ messages in thread
From: Luke Kenneth Casson Leighton @ 2004-05-15 23:26 UTC (permalink / raw)
  To: selinux

dear nsa et al,

love selinux principle.  it's _got_ to be made easier.

idea: make all the modifications to e.g. coreutils, login etc.
compile with the header files but not necessarily _need_
libselinux at run-time.

way to do that is the same way that libdvdcss is loaded by
libdvdread: dynamically [there are plenty of other programs
that use the same technique].

the suggestion is based on the premise that if you have a
non-selinux kernel, and no libselinux installed, the programs
(pam, coreutils, login etc.) will attempt to dynamically load
libselinux (with dlopen), find it missing, _won't care_
and will adapt and proceed knowing that there's no security
enhancements - i.e. as if they had never been patched to
deal with selinux in the first place;

whilst if they _do_ detect that libselinux is available, an
init function is called which returns a pointer to a vector
table of all the functions needed, which are then used;

and i presume that if such programs are compromised, and someone
attempts to _stop_ libselinux from being loaded, well then
those programs will not be capable of making domain transitions
etc. and they will be useless [am i right?]


the technique of having one function available from a dynamic
library, which returns a table of all functions available in
the library, and which is accessed via dlsym is very common,
i am sure you have heard of it:

/* change all functions listed in this vector table from
   extern to static: they are made accessible _only_ through
   the vector table, instead
 */

static libselinux_vector_table fns =
{
    is_selinux_enabled,
	freecon,
	freeconary,
	getcon,
	getpidcon,
	getprevcon,
	getexeccon,
	....
	....
	fsetfilecon
}


extern libselinux_vector_table *libselinux_init_fn(void);


then you do this, in every program that requires access to
libselinux functions:

void *handle = dlopen("/usr/lib/libselinux.so", blah);
void *(void) fn = dlsym(handle, "libselinux_init_fn");

libselinux_vector_table *sel = (libselinux_vector_table*)(*fn)();

then, for example, in the patch to coreutils,
http://selinux.lemuria.org/newselinux/coreutils/coreutils.diff

in coreutils-5.0.91/src/copy.c line 1444 approx, instead of
++#ifdef WITH_SELINUX
++	if (x->preserve_security_context) 
++	  setfscreatecon(NULL);
++#endif

you have:

if (sel != NULL && x->preserve_security_context)
	sel->setfscreatecon(NULL);


yes, correct: no #ifdef WITH_SELINUX :)


i.e. you must compile always with the header files, but you must NOT
require the library libselinux to be present in order for the program
to actually work.

this is a standard programming technique, i am sure that someone could
provide better examples of how it is deployed.

the advantage of deploying it is that at present there is
completely justifiable resistance upstream in accepting
patches to the core functionality of linux useability that
makes it impossible to use the core utilities for a non-selinux
environment (!), and this suggestion makes the reason for that
resistance go away.


i hope that you will consider adapting libselinux for use in this
manner, because the sooner the dual-maintenance of the "alternate"
versions of the core utils disappears, the better.

sincerely,

l.

p.s. please ask me for clarifications if needed or even for
patches rather than go "uhn?  weirdo, weird language, can't
even touch a shift key, don't talk to him".  i _want_ selinux
to be adapted mainstream by debian, quickly, so talk to me.

-- 
-- 
expecting email to be received and understood is a bit like
picking up the telephone and immediately dialing without
checking for a dial-tone; speaking immediately without listening
for either an answer or ring-tone; hanging up immediately and
believing that you have actually started a conversation.
--
<a href="http://lkcl.net">      lkcl.net      </a> <br />
<a href="mailto:lkcl@lkcl.net"> lkcl@lkcl.net </a> <br />


--
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] 18+ messages in thread
* Re: suggestion to help transition to selinux: dynamic loading of    libselinux
@ 2004-05-18  6:20 Chris Babcock
  0 siblings, 0 replies; 18+ messages in thread
From: Chris Babcock @ 2004-05-18  6:20 UTC (permalink / raw)
  To: selinux

> idea: make all the modifications to e.g. coreutils, login etc.
> compile with the header files but not necessarily _need_
> libselinux at run-time.
>
...
> the suggestion is based on the premise that if you have a
> non-selinux kernel, and no libselinux installed, the programs
> (pam, coreutils, login etc.) will attempt to dynamically load
> libselinux (with dlopen), find it missing, _won't care_
> and will adapt and proceed knowing that there's no security
> enhancements - i.e. as if they had never been patched to
> deal with selinux in the first place;
>
> whilst if they _do_ detect that libselinux is available, an
> init function is called which returns a pointer to a vector
> table of all the functions needed, which are then used;
>
Does this sound dangerous to anybody else?

This seems pretty harmless on a working se system, but on a non-se system,
I suspect this dependency could be exploited.





--
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] 18+ messages in thread
* Re: suggestion to help transition to selinux: dynamic loading of libselinux
@ 2004-05-18  9:50 Les Bell
  2004-05-18 11:44 ` Luke Kenneth Casson Leighton
  2004-05-18 14:07 ` Russell Coker
  0 siblings, 2 replies; 18+ messages in thread
From: Les Bell @ 2004-05-18  9:50 UTC (permalink / raw)
  To: Chris Babcock; +Cc: selinux


"Chris Babcock" <cbabcock@luthresearch.com> wrote:

>>
Does this sound dangerous to anybody else?
<<

Does the design of SELinux depend on the state machine theory of security,
i.e. if a system starts in a secure state, and all transitions are secure,
then the system will remain secure? This design would seem unable to
support that theory, i.e. until the selinux library is loaded, there are no
constraints on the state of the machine. Just a thought. . .

Best,

--- Les Bell, RHCE, CISSP
[http://www.lesbell.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] 18+ messages in thread

end of thread, other threads:[~2004-05-18 19:53 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-15 23:26 suggestion to help transition to selinux: dynamic loading of libselinux Luke Kenneth Casson Leighton
2004-05-17 19:10 ` Russell Coker
2004-05-17 21:56   ` Luke Kenneth Casson Leighton
2004-05-18  0:45     ` Russell Coker
2004-05-18  0:45     ` Valdis.Kletnieks
2004-05-17 22:02   ` Luke Kenneth Casson Leighton
2004-05-18  0:43     ` Russell Coker
2004-05-18 11:31   ` Stephen Smalley
2004-05-18 13:46     ` Russell Coker
2004-05-18 16:34 ` Stephen Smalley
2004-05-18 19:11   ` Luke Kenneth Casson Leighton
2004-05-18 19:52   ` Russell Coker
  -- strict thread matches above, loose matches on Subject: below --
2004-05-18  6:20 Chris Babcock
2004-05-18  9:50 Les Bell
2004-05-18 11:44 ` Luke Kenneth Casson Leighton
2004-05-18 14:07 ` Russell Coker
2004-05-18 14:19   ` Chris Babcock
2004-05-18 14:49     ` Russell Coker

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.