Skip to contentSkip to conversation

kernel stack challenge

DISCUSSION Sergiy Lozovsky 18 participants 61 messages Apr 4, 2004 – Apr 9, 2004 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

I have a stack hungry code in the kernel. It hits the end of stack from time to time. I wrote function to which I pass pointers to function and memory area which should be used as stack for function execution. (I just load pointer to new stack area into esp register). This function works just fine in user space and memory area provided by me is used as stack.

This function doesn't work in the kernel (system hungs instantly when my function is called). Does antbody have any idea what the reason can be? Some special alignment? Special memory segment? In what direction should I look?

(sure I tried some magic with alignment like - __attribute__ ((aligned (8192))) - no any effect)

(there was some patch to increase stack size kernelwide, but I don't want to affect all the system).

Thanks,

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#1 lore raw
Quoted 16 lines · Sergiy Lozovsky

Hi,

I have a stack hungry code in the kernel. It hits the end of stack from time to time. I wrote function to which I pass pointers to function and memory area which should be used as stack for function execution. (I just load pointer to new stack area into esp register). This function works just fine in user space and memory area provided by me is used as stack.

This function doesn't work in the kernel (system hungs instantly when my function is called). Does antbody have any idea what the reason can be? Some special alignment? Special memory segment? In what direction should I look?

Quoted 6 lines

(sure I tried some magic with alignment like - __attribute__ ((aligned (8192))) - no any effect)

(there was some patch to increase stack size kernelwide, but I don't want to affect all the system).

You aren't supposed to need much stack for anything in the kernel. Consider rewriting your function to use allocated memory instead of stack, this isn't all that hard.

Helge Hafting

#2 lore raw
Quoted 2 lines

Consider rewriting your function to use allocated memory instead of stack, this isn't all that hard.

I put LISP interpreter inside the Kernel -
http://vxe.quercitron.com

It works, but it use a lot of stack memory. It's impossible to rewrite it easily, though I'll investigate why exactly it uses so much of stack memory (though it's nature of LISP). There are no serious kernel memory allocation (as of my interpreter code review, only function calls; recursions in LISP application itself are eliminated for sure), but I'll trace stack usage more thouroughly.

Serge.

Quoted 32 lines · --- Helge Hafting
Quoted 3 lines · Sergiy Lozovsky

Hi,

I have a stack hungry code in the kernel. It hits

the

Quoted 1 line

end of stack from time to time. I wrote function

to

Quoted 2 lines

which I pass pointers to function and memory area which should be used as stack for function

execution.

Quoted 2 lines

(I just load pointer to new stack area into esp register). This function works just fine in user

space

Quoted 3 lines

and memory area provided by me is used as stack.

This function doesn't work in the kernel (system

hungs

Quoted 1 line

instantly when my function is called). Does

antbody

Quoted 2 lines

have any idea what the reason can be? Some special alignment? Special memory segment? In what

direction

Quoted 8 lines

should I look?

(sure I tried some magic with alignment like - __attribute__ ((aligned (8192))) - no any effect)

(there was some patch to increase stack size kernelwide, but I don't want to affect all the system).

Quoted 7 lines

You aren't supposed to need much stack for anything in the kernel.
Consider rewriting your function to use allocated memory instead of stack, this isn't all that hard.

Helge Hafting

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#3 lore raw
Quoted 2 lines · Sergiy Lozovsky

I put LISP interpreter inside the Kernel -

I'm dying to know why you need a LISP interpreter inside the kernel.

#4 lore raw
Quoted 11 lines · --- Timothy Miller
Quoted 2 lines · Sergiy Lozovsky

I put LISP interpreter inside the Kernel -

I'm dying to know why you need a LISP interpreter
inside the kernel.

It is explained at my project home page -
http://vxe.quercitron.com

Basically there are two reasons.

1. Give system administrator possibility to change security policy easy enough without C programminig inside the kernel (we should not expect system administartor to be a kernel guru). Language of higher lavel make code more compact (C - is too low level, that's why people use PERL for example or LISP). Lisp was chosen because of very compact VM - around 100K.

2. Protect system from bugs in security policy created by system administrator (user). LISP interpreter is a LISP Virtual Machine (as Java VM). So all bugs are incapsulated and don't affect kernel. Even severe bugs in this LISP kernel module can cause termination of user space application only (except of stack overflow
- which I can address). LISP error message will be printed in the kernel log.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#5 lore raw
Quoted 7 lines · Sergiy Lozovsky

1. Give system administrator possibility to change security policy easy enough without C programminig inside the kernel (we should not expect system administartor to be a kernel guru). Language of higher lavel make code more compact (C - is too low level, that's why people use PERL for example or LISP). Lisp was chosen because of very compact VM - around 100K.

Didn't seem to slow the SELinux crowd down any...

You may not need the exact SELinux config language, but it does address the issue of making something fairly easy for the sysadmin to write while not requiring a large interpreter in the kernel (the kernel side of the selinuxfs pseudo-filesystem is all of 14K, the loadpolicy is about a 4K binary and a 60K shared library, and the policy compiler is about 100K and the shared lib).

So you're including a much bigger interface for little gain. The total footprint of the two solutions is about the same, but SELinux the vast majority of it is in userspace, and only costs you when you're actually compiling/ loading a new policy, whereas yours takes up 100K of kernel space all the time....

Quoted 8 lines

2. Protect system from bugs in security policy created by system administrator (user). LISP interpreter is a LISP Virtual Machine (as Java VM). So all bugs are incapsulated and don't affect kernel. Even severe bugs in this LISP kernel module can cause termination of user space application only (except of stack overflow
- which I can address). LISP error message will be printed in the kernel log.

If you think that "all bugs are encapsulated" actually means anything in the context of the Linux kernel, you're in for a very big surprise.

For example - your Lisp error messages go through the kernel log, so you're using printk() and friends. Note that it *is* possible for a buggy call to printk() to cause problems for the kernel.

#6 lore raw
Quoted 7 lines · [email protected] wrote:

So you're including a much bigger interface for little gain. The total footprint of the two solutions is about the same, but SELinux the vast majority of it is in userspace, and only costs you when you're actually compiling/ loading a new policy, whereas yours takes up 100K of kernel space all the time....

The key concept here is "in userspace".

#7 lore raw
In reply to Sergiy Lozovsky
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Sergiy" == Sergiy Lozovsky <[email protected]> writes:

Sergiy> Basically there are two reasons.

Sergiy> 1. Give system administrator possibility to change security Sergiy> policy easy enough without C programminig inside the kernel Sergiy> (we should not expect system administartor to be a kernel Sergiy> guru). Language of higher lavel make code more compact (C - is Sergiy> too low level, that's why people use PERL for example or Sergiy> LISP). Lisp was chosen because of very compact VM - around Sergiy> 100K.

Why in god's name does this need to be in the kernel? This is purely a userspace issue, and the tool for managing the security policy should be completely in userspace.

Under this design, /bin/ls would be a kernel module, and not a userspace tool!

If you ever want to even think about getting this project into the kernel, you'll have to re-design what you're doing here, since there's absolutely no need for anything like this in the kernel.

Sergiy> 2. Protect system from bugs in security policy created by Sergiy> system administrator (user).

C'mon, GIGO will kill you from user space or from kernel space. What makes you think LISP will protect you?

Sergiy> LISP interpreter is a LISP Virtual Machine (as Java VM). So Sergiy> all bugs are incapsulated and don't affect kernel.

Then *WHY* does the LISP interpreter need to be in the kernel in the first place? Hint, you just said you wanted to protect the kernel...

Sergiy> Even severe bugs in this LISP kernel module can cause Sergiy> termination of user space application only (except of stack Sergiy> overflow - which I can address). LISP error message will be Sergiy> printed in the kernel log.

Hah! You just gave the number one reason why you don't want or need a LISP interpreter in the kernel yourself.

John
John Stoffel - Senior Unix Systems Administrator - Lucent Technologies

	 [email protected] - http://www.lucent.com - 978-952-7548
#8 lore raw
Quoted 19 lines · --- John Stoffel
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Sergiy" == Sergiy Lozovsky

<[email protected]> writes:

Sergiy> Basically there are two reasons.

Sergiy> 1. Give system administrator possibility to change security
Sergiy> policy easy enough without C programminig inside the kernel
Sergiy> (we should not expect system administartor to be a kernel
Sergiy> guru). Language of higher lavel make code more compact (C - is
Sergiy> too low level, that's why people use PERL for example or
Sergiy> LISP). Lisp was chosen because of very compact VM - around
Sergiy> 100K.

Quoted 5 lines

Why in god's name does this need to be in the
kernel? This is purely
a userspace issue, and the tool for managing the
security policy
should be completely in userspace.

UNIX security policy is already implemented in the Kernel, or should we move checking of root priveleges and file permissions to the userspace? I just extended existing security features.

Quoted 3 lines

Under this design, /bin/ls would be a kernel module, and not a
userspace tool!

No :-) What you suggest is kernel should receive system call from user space. Instead of handling it - kernel should forward it back to userspace, than it should be forwarded back to the kernel. Looks not very nice to me. Why not to handle security policy inside the kernel as it is done for the file permissions and root priveleges?

Quoted 13 lines

Sergiy> 2. Protect system from bugs in security
policy created by
Sergiy> system administrator (user).

C'mon, GIGO will kill you from user space or from
kernel space. What
makes you think LISP will protect you?

Sergiy> LISP interpreter is a LISP Virtual Machine (as Java VM). So
Sergiy> all bugs are incapsulated and don't affect kernel.

Quoted 4 lines

Then *WHY* does the LISP interpreter need to be in the kernel in the
first place? Hint, you just said you wanted to protect the kernel...

All LISP errors are incapsulated within LISP VM.

Quoted 11 lines

Sergiy> Even severe bugs in this LISP kernel module can cause
Sergiy> termination of user space application only (except of stack
Sergiy> overflow - which I can address). LISP error message will be
Sergiy> printed in the kernel log.

Hah! You just gave the number one reason why you
don't want or need a
LISP interpreter in the kernel yourself.

What reason you have in mind? All available security models have predefined stack usage, so it is completely safe to use them.

For those who want to define their security model (not security policy!) - they shoud respect stack limitations for now. Which sounds reasonable. Using existing security models it is impossible to cause stack overflow. (depth of subroutine calls is constant).

Serge.

Quoted 4 lines

John
John Stoffel - Senior Unix Systems Administrator
- Lucent Technologies
[email protected] - http://www.lucent.com -

978-952-7548

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#9 lore raw
Quoted 4 lines · Sergiy Lozovsky

All LISP errors are incapsulated within LISP VM.

A LISP VM is a big, giant, bloated.... *CHOKE* *COUGH* *SPUTTER* *SUFFOCATE* ... thing which SHOULD NEVER be in the kernel.

If you want to use a more abstract language for describing kernel security policies, fine. Just don't use LISP.

The right way to do it is this:

- A user space interpreter reads text-based config files and converts them into a compact, easy-to-interpret code used by the kernel.

- A VERY TINY kernel component is fed the security policy and executes it.

Move as much of the processing as reasonable into user space. It's absolutely unnecessary to have the parser into the kernel, because parsing of the config files is done only when the ASCII text version changes.

It's absolutely unnecessary to have something as complex as LISP to interpret it, when something simple and compact could do just as well.

Why do you choose LISP? Don't you want to use a language that sysadmins will actually KNOW?

#10 lore raw
Quoted 10 lines · Timothy Miller
Quoted 4 lines · Sergiy Lozovsky

All LISP errors are incapsulated within LISP VM.

A LISP VM is a big, giant, bloated.... *CHOKE* *COUGH* *SPUTTER* *SUFFOCATE* ... thing which SHOULD NEVER be in the kernel.

Ah your thinking of the days when 1 meg of memory was a lot and LISP was considered huge.. With 4 gigs of memory today, it shouldnt be a problem :). Actually a LISP vm can fit into a small amount of memory depending on what you want it to do...

I think in the end, this is a 'When all you know is to hammer, everything is a nail.' They know LISP.

Quoted 2 lines

Why do you choose LISP? Don't you want to use a language that sysadmins will actually KNOW?

Because how else can you get emacs to the only thing to run?

Signature · 4 lines
Stephen John Smoogen		[email protected]
Los Alamos National Lab  CCN-5 Sched 5/40  PH: 4-0645
Ta-03 SM-1498 MailStop B255 DP 10S  Los Alamos, NM 87545
-- You should consider any operational computer to be a security problem --
#11 lore raw
Quoted 7 lines · Stephen Smoogen
Quoted 4 lines · Timothy Miller
Quoted 1 line · Sergiy Lozovsky
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

All LISP errors are incapsulated within LISP VM.

A LISP VM is a big, giant, bloated.... *CHOKE* *COUGH* *SPUTTER* *SUFFOCATE* ... thing which SHOULD NEVER be in the kernel.

Ah your thinking of the days when 1 meg of memory was a lot and LISP was considered huge.. With 4 gigs of memory today, it shouldnt be a problem :). Actually a LISP vm can fit into a small amount of memory depending on what you want it to do...

People complained about having Athlon-specific fixes in all x86 kernels because of the extra few hundred bytes it would waste for a Pentium kernel.

What makes you think people would accept a LISP interpreter?

#12 lore raw
In reply to Timothy Miller
Quoted 6 lines · --- Timothy Miller
Quoted 2 lines · Sergiy Lozovsky
Quoted 8 lines
Quoted 2 lines

All LISP errors are incapsulated within LISP VM.

A LISP VM is a big, giant, bloated.... *CHOKE* *COUGH* *SPUTTER*
*SUFFOCATE* ... thing which SHOULD NEVER be in the kernel.

It is a smallest interpreter (of all purpose language) I was able to find. My guess is that you refer to the Common Lisp. it is huge and I don't use it.

Quoted 4 lines

If you want to use a more abstract language for describing kernel
security policies, fine. Just don't use LISP.

Point me to ANy langage with VM around 100K.

Quoted 9 lines

The right way to do it is this:

- A user space interpreter reads text-based config files and converts
them into a compact, easy-to-interpret code used by the kernel.

- A VERY TINY kernel component is fed the security policy and executes it.

it is exactly the way it is implemented. Not everyone need to create their own security model (that VERY TINY kernel component you refer to). But even for those who want to modify or create their own VERY TINY kernel component - they don't need to do that in C and debug it in th kernel crashing it.

Quoted 9 lines

Move as much of the processing as reasonable into user space. It's
absolutely unnecessary to have the parser into the kernel, because
parsing of the config files is done only when the ASCII text version
changes.

Quoted 8 lines

It's absolutely unnecessary to have something as complex as LISP to
interpret it, when something simple and compact could do just as well.

Why do you choose LISP? Don't you want to use a language that sysadmins
will actually KNOW?

It was is) the smallest VM I know of.

99% of sysadmins don't need to create their own security models. Security polices are created with web interface very close to the way you described. So sysadmin don't need to know anything about LISP (to use predefined security models).

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#13 lore raw
Quoted 11 lines · Sergiy Lozovsky
Quoted 10 lines · --- Timothy Miller
Quoted 4 lines · Sergiy Lozovsky

All LISP errors are incapsulated within LISP VM.

Quoted 9 lines
Quoted 4 lines

A LISP VM is a big, giant, bloated.... *CHOKE* *COUGH* *SPUTTER*
*SUFFOCATE* ... thing which SHOULD NEVER be in the kernel.

It is a smallest interpreter (of all purpose language) I was able to find. My guess is that you refer to the Common Lisp. it is huge and I don't use it.

How about BF? ;)

I would think something like forth might be a better fit then lisp.

Quoted 62 lines
Quoted 4 lines

If you want to use a more abstract language for describing kernel
security policies, fine. Just don't use LISP.

Point me to ANy langage with VM around 100K.

Quoted 9 lines

The right way to do it is this:

- A user space interpreter reads text-based config files and converts
them into a compact, easy-to-interpret code used by the kernel.

- A VERY TINY kernel component is fed the security policy and executes it.

it is exactly the way it is implemented. Not everyone need to create their own security model (that VERY TINY kernel component you refer to). But even for those who want to modify or create their own VERY TINY kernel component - they don't need to do that in C and debug it in th kernel crashing it.

Quoted 9 lines

Move as much of the processing as reasonable into user space. It's
absolutely unnecessary to have the parser into the kernel, because
parsing of the config files is done only when the ASCII text version
changes.

Quoted 8 lines

It's absolutely unnecessary to have something as complex as LISP to
interpret it, when something simple and compact could do just as well.

Why do you choose LISP? Don't you want to use a language that sysadmins
will actually KNOW?

It was is) the smallest VM I know of.

99% of sysadmins don't need to create their own security models. Security polices are created with web interface very close to the way you described. So sysadmin don't need to know anything about LISP (to use predefined security models).

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#15 lore raw

--- Robin Rosenberg <[email protected]>

Quoted 7 lines · wrote:
Quoted 1 line · Sergiy Lozovsky

Point me to ANy langage with VM around 100K.

There is a Java VM (lejos) för the Lego Mindstorms robot. The hardware
has 32K memory.

Is it Free and Open Source? Where can I get it if it is?

(I don't want to start Holly War :-) but I think, that Java is lower lavel than C, I recognize, that I can be wrong)

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#16 lore raw
Quoted 6 lines · you

--- Robin Rosenberg <[email protected]>

Quoted 3 lines · wrote:

On Monday 05 April 2004 23:30, Sergiy Lozovsky

wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Point me to ANy langage with VM around 100K.

There is a Java VM (lejos) för the Lego Mindstorms robot. The hardware
has 32K memory.

Is it Free and Open Source? Where can I get it if it is?

www.lejos.org. Mozilla License 1.0 (Not sure about GPL compatibility if you were to have wierd plans).

But, it has no GC- I doubt adding GC would add many K's. On the other hand you might want to be careful with GC inside the kernel :-)

-- robin

#17 lore raw
In reply to Sergiy Lozovsky
Quoted 3 lines · Sergiy Lozovsky

(I don't want to start Holly War :-) but I think, that Java is lower lavel than C, I recognize, that I can be wrong)

Yes, you could..., but that's OT. Isn't LISP lower level. Just the names of it's instructions (Content of Address part of Register and Content of Decrement part of Register) imply that. Shudddrdrrddrr. :-)

I like Lisp, it's a hacker language, or was at least.

-- robin

#18 lore raw

--- Robin Rosenberg <[email protected]>

Quoted 14 lines · wrote:
Quoted 1 line · Sergiy Lozovsky

(I don't want to start Holly War :-) but I think,

that

Quoted 1 line

Java is lower lavel than C, I recognize, that I

can be

Quoted 1 line

wrong)

Yes, you could..., but that's OT. Isn't LISP lower level. Just
the names of it's instructions (Content of Address part of Register and
Content of Decrement part of Register) imply that. Shudddrdrrddrr. :-)

Quoted 4 lines

I like Lisp, it's a hacker language, or was at
least.

-- robin

Sounds like music to me :-) If I would not be (very) familiar with LISP prior to that project, I would not chose it probably. It's syntax is so simple (it is a marvel :-) I would think twice to put in the kernel something with more complex syntax.

After all Emacs uses LISP, too :-) Though it is this big one - Common Lisp :-)

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#19 lore raw

On Mon, 5 Apr 2004 20:02:00 -0700 (PDT) Sergiy Lozovsky <[email protected]> wrote:

| 
| --- Robin Rosenberg <[email protected]>
| wrote:
| > On Tuesday 06 April 2004 00:52, Sergiy Lozovsky
| > wrote:
| > > (I don't want to start Holly War :-) but I think,
| > that
| > > Java is lower lavel than C, I recognize, that I
| > can be
| > > wrong)
| > Yes, you could..., but that's OT. Isn't LISP lower
| > level. Just
| > the names of it's instructions (Content of Address
| > part of Register and 
| > Content of Decrement part of Register) imply that.
| > Shudddrdrrddrr. :-)
| > 
| > I like Lisp, it's a hacker language, or was at
| > least.
| > 
| > -- robin
| 
| 
| Sounds like music to  me :-) If I would not be (very)
| familiar with LISP prior to that project, I would not
| chose it probably. It's syntax is so simple (it is a
| marvel :-) I would think twice to put in the kernel
| something with more complex syntax.
| 
| After all Emacs uses LISP, too :-) Though it is this
| big one - Common Lisp :-)

I always knew that emacs was just another OS. 8;}

--
~Randy

#20 lore raw
In reply to Sergiy Lozovsky
Quoted 11 lines · Sergiy Lozovsky
Quoted 9 lines · --- Timothy Miller
Quoted 3 lines · Sergiy Lozovsky

All LISP errors are incapsulated within LISP VM.

Quoted 8 lines
Quoted 3 lines

A LISP VM is a big, giant, bloated.... *CHOKE*
*COUGH* *SPUTTER* *SUFFOCATE* ... thing which SHOULD NEVER be in the kernel.

It is a smallest interpreter (of all purpose language) I was able to find. My guess is that you refer to the Common Lisp. it is huge and I don't use it.

Did you separate out the parser out into a user-space daemon?

Also, if you want a regular programming language with an extremely small interpreter, try Forth.

Learning Forth should be at LEAST as much fun as learning LISP.

Quoted 7 lines
Quoted 4 lines

If you want to use a more abstract language for describing kernel security policies, fine. Just don't use LISP.

Point me to ANy langage with VM around 100K.

I bet a Forth interpreter would be smaller.

And for something specialized like security policy, you could probably develop your own language and interpreter for it, and it would be smaller (and faster) still.

Quoted 12 lines
Quoted 10 lines

The right way to do it is this:

- A user space interpreter reads text-based config
files and converts them into a compact, easy-to-interpret code used by the kernel.

- A VERY TINY kernel component is fed the security policy and executes it.

Quoted 6 lines

it is exactly the way it is implemented. Not everyone need to create their own security model (that VERY TINY kernel component you refer to). But even for those who want to modify or create their own VERY TINY kernel component - they don't need to do that in C and debug it in th kernel crashing it.

You misunderstand. When I say "VERY TINY kernel component", I'm referring to the interpreter. Done properly, the pcode for the policy itself would be microscopic.

Quoted 11 lines
Quoted 11 lines

Move as much of the processing as reasonable into
user space. It's absolutely unnecessary to have the parser into the kernel, because parsing of the config files is done only when the ASCII text version changes.

It's absolutely unnecessary to have something as complex as LISP to interpret it, when something simple and compact could do just as well.

Quoted 5 lines
Quoted 2 lines

Why do you choose LISP? Don't you want to use a
language that sysadmins will actually KNOW?

It was is) the smallest VM I know of.

Forth.

#21 lore raw

I wanted something higher level than C. Forth looks like C to me. I wanted something with build in support of complex structures and automatic memory management.

I see no reason to replace one C with another.

Quoted 2 lines

Did you separate out the parser out into a user-space daemon?

I didn't. It's possible optimization, but it will not give any good. The syntax of LISP is much simpler than Forth (this another reason I chose LISP :-), so parser is very small.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Why do you choose LISP? Don't you want to use a language that sysadmins
will actually KNOW?

At the start of the project I tried to design my own small language (just for security system). At this point I understood that I didn't want to settle with anything less than universal language. The idea to invent some language and write VM for it didn't appeal to me. I wanted to make a security system, not a new language. I wanted language to be as simple as possible. LISP had the simpliest syntax from all languages. So I found small lisp interpreter (kind of real time - without garbage collector which stops execution) added string and bit operations, modified it to be placed in the kernel.

Ok, it was my marketing claim about sysadmins :-) Sysadmins use web interface to configure polices and don't deal with LISP at all.

LISP is for those who want to change security Models only.

Serge.

Quoted 98 lines · --- Timothy Miller
Quoted 11 lines · Sergiy Lozovsky
Quoted 9 lines · --- Timothy Miller
Quoted 3 lines · Sergiy Lozovsky

All LISP errors are incapsulated within LISP VM.

Quoted 7 lines
Quoted 4 lines

A LISP VM is a big, giant, bloated.... *CHOKE* *COUGH* *SPUTTER*
*SUFFOCATE* ... thing which SHOULD NEVER be in the kernel.

It is a smallest interpreter (of all purpose

language)

Quoted 1 line

I was able to find. My guess is that you refer to

the

Quoted 1 line

Common Lisp. it is huge and I don't use it.

Did you separate out the parser out into a user-space daemon?

Also, if you want a regular programming language with an extremely small
interpreter, try Forth.

Learning Forth should be at LEAST as much fun as learning LISP.

Quoted 8 lines
Quoted 5 lines

If you want to use a more abstract language for describing kernel
security policies, fine. Just don't use LISP.

Point me to ANy langage with VM around 100K.

I bet a Forth interpreter would be smaller.

And for something specialized like security policy, you could probably
develop your own language and interpreter for it, and it would be
smaller (and faster) still.

Quoted 7 lines
Quoted 7 lines

The right way to do it is this:

- A user space interpreter reads text-based config files and converts
them into a compact, easy-to-interpret code used

by

Quoted 7 lines
Quoted 4 lines

the kernel.

- A VERY TINY kernel component is fed the security policy and executes it.

it is exactly the way it is implemented. Not

everyone

Quoted 3 lines

need to create their own security model (that VERY TINY kernel component you refer to). But even for those who want to modify or create their own VERY

TINY

Quoted 1 line

kernel component - they don't need to do that in C

and

Quoted 1 line

debug it in th kernel crashing it.

You misunderstand. When I say "VERY TINY kernel component", I'm
referring to the interpreter. Done properly, the pcode for the policy
itself would be microscopic.

Quoted 15 lines
Quoted 15 lines

Move as much of the processing as reasonable into user space. It's
absolutely unnecessary to have the parser into the kernel, because
parsing of the config files is done only when the ASCII text version
changes.

It's absolutely unnecessary to have something as complex as LISP to
interpret it, when something simple and compact could do just as well.

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

Why do you choose LISP? Don't you want to use a language that sysadmins
will actually KNOW?

It was is) the smallest VM I know of.

Forth.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#22 lore raw
In reply to Sergiy Lozovsky
Quoted 11 lines · Sergiy Lozovsky
Quoted 10 lines · --- Timothy Miller
Quoted 4 lines · Sergiy Lozovsky

All LISP errors are incapsulated within LISP VM.

Quoted 8 lines
Quoted 4 lines

A LISP VM is a big, giant, bloated.... *CHOKE* *COUGH* *SPUTTER*
*SUFFOCATE* ... thing which SHOULD NEVER be in the kernel.

It is a smallest interpreter (of all purpose language) I was able to find. My guess is that you refer to the Common Lisp. it is huge and I don't use it.

Nope. Timothy was talking exactly of the same one as you. And I agree with him.

Quoted 5 lines
Quoted 3 lines

If you want to use a more abstract language for
describing kernel
security policies, fine. Just don't use LISP.

Point me to ANy langage with VM around 100K.

Assembler. VM is exactly _zero_ overhead. Or C, for a tiny bit more. That one was already paid for, so you essentially get it for free. Might also hack FORTH, for a few KiB (dunno how much this days, but should be less than 10 for a stripped to the bone package).

Quoted 9 lines
Quoted 9 lines

The right way to do it is this:

- A user space interpreter reads text-based config files and converts
them into a compact, easy-to-interpret code used by the kernel.

- A VERY TINY kernel component is fed the security policy and executes it.

Nodz!

Quoted 1 line

it is exactly the way it is implemented.

And how does an _in kernel_ LISP interpreter fit into this picture? Lost me there...

Quoted 3 lines

Not everyone
need to create their own security model (that VERY TINY kernel component you refer to).

Now we have common ground...

Quoted 4 lines

But even for
those who want to modify or create their own VERY TINY kernel component - they don't need to do that in C and debug it in th kernel crashing it.

... of sorts.

Right, I don't want the security kernel inside the kernel crashing. But then again, I don't want the driver for the hard disk, or the mouse, or even the graphic card, scribbling over memory either. Guess you'd (re)write the whole kernel in some LISP dialect then? Good luck! But this is _certainly_ the worst list to discuss such a design.

[...]

Quoted 5 lines
Quoted 3 lines

Why do you choose LISP? Don't you want to use a
language that sysadmins
will actually KNOW?

It was is) the smallest VM I know of.

You know little...

Quoted 5 lines

99% of sysadmins don't need to create their own security models. Security polices are created with web interface very close to the way you described. So sysadmin don't need to know anything about LISP (to use predefined security models).

OK, so you need the policy to be interpreted in-kernel (dunno why a largeish high-level general purpose language is needed for that, when a tiny interpreter for a specialized language will do very well, and has been shown to work fine), and written in a "high level language" so that your garden variety sysadmin _can_ write her own policy, but it really doesn't matter because she'll never have to do so...

Completely lost me.

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
#23 lore raw
Quoted 8 lines · Horst von Brand

OK, so you need the policy to be interpreted in-kernel (dunno why a largeish high-level general purpose language is needed for that, when a tiny interpreter for a specialized language will do very well, and has been shown to work fine), and written in a "high level language" so that your garden variety sysadmin _can_ write her own policy, but it really doesn't matter because she'll never have to do so...

Completely lost me.

I was getting hung up on that one too, but I didn't know how to say it.
You did a nice job. :)

#24 lore raw
Quoted 13 lines · --- Timothy Miller
Quoted 1 line · Horst von Brand

OK, so you need the policy to be interpreted

in-kernel (dunno why a

Quoted 1 line

largeish high-level general purpose language is

needed for that, when a

Quoted 1 line

tiny interpreter for a specialized language will

do very well, and has been

Quoted 1 line

shown to work fine), and written in a "high level

language" so that your

Quoted 1 line

garden variety sysadmin _can_ write her own

Quoted 8 lines

policy, but it really doesn't

Quoted 3 lines

matter because she'll never have to do so...

Completely lost me.

I was getting hung up on that one too, but I didn't know how to say it.
You did a nice job. :)

Can you guys be more specific? I don't see any technical objections. The only one is that performance would suffer because of use of higher level language than C or Assembler.

There is a reason people use languages like PERL, Java and so on. I would prefer to spend less time writing actual code - this is what these high level languages for. If performance would be most important - people would do everything in Assembler, but they don't. I'd better write a small Assembler subroutine which will handle stack problems for me and benefit from using the high level language after that.

There were times when userland projects were written in Assembler. Now people are using other languages, too. May be it's time to try something new in the kernel, too :-) Or we will not consider that because nobody did that before? Someone should be the first :-)

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#25 lore raw
Quoted 23 lines · Sergiy Lozovsky
Quoted 11 lines · --- Timothy Miller
Quoted 1 line · Horst von Brand

OK, so you need the policy to be interpreted

in-kernel (dunno why a

Quoted 1 line

largeish high-level general purpose language is

needed for that, when a

Quoted 1 line

tiny interpreter for a specialized language will

do very well, and has been

Quoted 1 line

shown to work fine), and written in a "high level

language" so that your

Quoted 8 lines
Quoted 1 line

garden variety sysadmin _can_ write her own

policy, but it really doesn't

Quoted 2 lines

matter because she'll never have to do so...
Completely lost me.

I was getting hung up on that one too, but I didn't know how to say it.
You did a nice job. :)

Quoted 4 lines

Can you guys be more specific? I don't see any technical objections. The only one is that performance would suffer because of use of higher level language than C or Assembler.

That IS one of the objections, but it's not the objection HERE.

The objection here is that we see an inconsistency:

A) You support the idea of using LISP because it's a high-level language that sysadmins can use to develop policies.

B) But then you say that sysadmins won't be developing policies.

Therefore, you invalidate your reason for wanting to use LISP.

Quoted 9 lines

There is a reason people use languages like PERL, Java and so on. I would prefer to spend less time writing actual code - this is what these high level languages for. If performance would be most important - people would do everything in Assembler, but they don't. I'd better write a small Assembler subroutine which will handle stack problems for me and benefit from using the high level language after that.

As a matter of fact, the only reason people object to using LISP is because you want to do it IN THE KERNEL.

If you want the interpreter to live in the kernel, then you have to use something MUCH SIMPLER and something which doesn't eat stack like LISP does.

On the other hand, if you were to put hooks into the kernel so that people could use ANY LANGUAGE THEY WANTED, IN USER SPACE, then people would be very happy with you. This way, you can waste all the memory you want on the interpreter, but it's okay because it's:

(1) extremely optional
(2) extremely replacable (interpretor can be any language)
(3) swappable
(4) can't clobber the kernel
(5) can use as much stack space as it wants
(6) minimally impacts what IS in the kernel, etc.

You down-play the performance impact of using LISP above, but you contradict that by saying you want to put the interpreter in the kernel for performance reasons. You can't have it both ways. Either you're concerned about performance (and you use something efficient and compact), or you're not concenred about performance (and you use whatever high-level language you want IN USERSPACE).

Quoted 7 lines

There were times when userland projects were written in Assembler. Now people are using other languages, too. May be it's time to try something new in the kernel, too :-) Or we will not consider that because nobody did that before? Someone should be the first :-)

The kernel is not the appropriate place for this. An OS kernel exists to provide a minimal set of services necessary for applications to make efficient use of resources. (Microkernels take this to the extreme with their layering.) Only when something CANNOT be accomplished in userspace (or performance in userspace is terrible) should something be put into the kernel.

As I've said before, the overhead of actually interpreting a high-level language is probably great enough that the context-switch overhead you don't want would diminish.

#26 lore raw
Quoted 43 lines · --- Timothy Miller
Quoted 11 lines · Sergiy Lozovsky
Quoted 9 lines · --- Timothy Miller
Quoted 1 line · Horst von Brand

OK, so you need the policy to be interpreted

in-kernel (dunno why a

Quoted 1 line

largeish high-level general purpose language is

needed for that, when a

Quoted 1 line

tiny interpreter for a specialized language will

do very well, and has been

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

shown to work fine), and written in a "high level

language" so that your

Quoted 1 line

garden variety sysadmin _can_ write her own

policy, but it really doesn't

Quoted 2 lines

matter because she'll never have to do so...
Completely lost me.

I was getting hung up on that one too, but I

didn't

Quoted 6 lines
Quoted 2 lines

know how to say it.
You did a nice job. :)

Can you guys be more specific? I don't see any
technical objections. The only one is that

performance

Quoted 1 line

would suffer because of use of higher level

language

Quoted 1 line

than C or Assembler.

That IS one of the objections, but it's not the
objection HERE.

The objection here is that we see an inconsistency:

A) You support the idea of using LISP because it's a high-level language
that sysadmins can use to develop policies.

Quoted 5 lines

B) But then you say that sysadmins won't be
developing policies.

Therefore, you invalidate your reason for wanting to use LISP

If I would say, that policy administrator change security policy (not system administrator :-). Would it be an answer to your question? I don't want this person to be a kernel guru and make him write a C code for Kernel. I don't want errors of this person to affect all the system - which is a case with precompiled loadable C module.

Quoted 17 lines
Quoted 2 lines

There is a reason people use languages like PERL,

Java

Quoted 1 line

and so on. I would prefer to spend less time

writing

Quoted 1 line

actual code - this is what these high level

languages

Quoted 1 line

for. If performance would be most important -

people

Quoted 1 line

would do everything in Assembler, but they don't.

I'd

Quoted 1 line

better write a small Assembler subroutine which

will

Quoted 1 line

handle stack problems for me and benefit from

using

Quoted 1 line

the high level language after that.

Quoted 8 lines

As a matter of fact, the only reason people object to using LISP is
because you want to do it IN THE KERNEL.

If you want the interpreter to live in the kernel, then you have to use
something MUCH SIMPLER and something which doesn't eat stack like LISP does.

What? Give an example. I want something high level, so Forth will not do. Sure, encapsulation is needed, to protect kernel from pointer errors and so on.

Quoted 17 lines

On the other hand, if you were to put hooks into the kernel so that
people could use ANY LANGUAGE THEY WANTED, IN USER SPACE, then people
would be very happy with you. This way, you can waste all the memory
you want on the interpreter, but it's okay because it's:

(1) extremely optional
(2) extremely replacable (interpretor can be any
language)
(3) swappable
(4) can't clobber the kernel
(5) can use as much stack space as it wants
(6) minimally impacts what IS in the kernel, etc.

Quoted 11 lines

You down-play the performance impact of using LISP above, but you
contradict that by saying you want to put the interpreter in the kernel
for performance reasons. You can't have it both ways. Either you're
concerned about performance (and you use something efficient and
compact), or you're not concenred about performance (and you use
whatever high-level language you want IN USERSPACE).

I'm looking for balance. I want to benefit from high level language and have reasonable performance.

Quoted 14 lines
Quoted 4 lines

There were times when userland projects were

written

Quoted 1 line

in Assembler. Now people are using other

languages,

Quoted 2 lines

too. May be it's time to try something new in the
kernel, too :-) Or we will not consider that

because

Quoted 1 line

nobody did that before? Someone should be the

first

Quoted 1 line

:-)

Quoted 7 lines

The kernel is not the appropriate place for this. An OS kernel exists
to provide a minimal set of services necessary for applications to make
efficient use of resources. (Microkernels take this to the extreme with
their layering.)

This is a good explanation, why I use kernel. You admitted that microkernels are extreme. I didn't want to change such basic architectural model of Linux. What you suggest to do is to make microkernel. Sys call goes to kernel, instead of serving this request you suggest to forward this call to the userspace, than get it back and continue to serv it in the kernel. Worse of two worlds - kernels serv syscalls inside, microkernels - outside; you suggest to serv it both - outside and inside.

It was hard for me to predict performance and architectural penalties of such solution. For each syscall perform - task switch (can we predict when scheduler decided to give control to the userspace security server and than back to initial appliaction?), context switch (kernelspace/userspace and back), priority switch - process which issued sys call is with one priority, security server - with another. System behaviour become very complex and forwarding syscalls to userspace affects basic architecture of Linux.

Quoted 11 lines

Only when something CANNOT be
accomplished in
userspace (or performance in userspace is terrible) should something be
put into the kernel.

As I've said before, the overhead of actually
interpreting a high-level
language is probably great enough that the
context-switch overhead you
don't want would diminish.

This overhead is very predictable (having the size of particular security policy and defined security model). So it close to real-time, which is good for kernel. Switching between tasks, environments and priorites during the service of just one system call is not predicatble at all and more complex.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#27 lore raw

hi :)

Quoted 3 lines · Sergiy Lozovsky

What? Give an example. I want something high level, so Forth will not do. Sure, encapsulation is needed, to protect kernel from pointer errors and so on.

who says that the language that's used by your policy administrator is the same as the language interpreted by the kernel?

let your administrator write his policy in java/lisp or whatever, but compile this policy into an easy to interpret and safe bytecode.

Signature · 5 lines
CU,		  / Friedrich-Alexander University Erlangen, Germany
Martin Waitz	//  Department of Computer Science 12      _________
______________/// - - - - - - - - - - - - - - - - - - - - ///
dies ist eine manuell generierte mail, sie beinhaltet    //
tippfehler und ist auch ohne grossbuchstaben gueltig.   /
#28 lore raw

Hi, :-)

Quoted 15 lines · --- Martin Waitz

hi :)

Quoted 1 line · Sergiy Lozovsky

What? Give an example. I want something high

level, so

Quoted 1 line

Forth will not do. Sure, encapsulation is needed,

to

Quoted 1 line

protect kernel from pointer errors and so on.

who says that the language that's used by your
policy administrator
is the same as the language interpreted by the
kernel?

Quoted 5 lines

let your administrator write his policy in java/lisp or whatever,
but compile this policy into an easy to interpret and safe
bytecode.

That will not give any benefits. LISP has internal representation of program and data for sure ('bytecode'), but it is lists. How to unload it to something one can move around? One of the ways - unload it in a text form. But it exactly what initial source code is. Parser of LISP is very small (because syntax is simple), so producing some non standard bytecode make no sense - source code of LISP is very close to it's 'bytecode'.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#29 lore raw
In reply to Sergiy Lozovsky
Quoted 11 lines · Sergiy Lozovsky
Quoted 9 lines · --- Timothy Miller
Quoted 7 lines · Horst von Brand

OK, so you need the policy to be interpreted in-kernel (dunno why a largeish high-level general purpose language is needed for that, when a tiny interpreter for a specialized language will do very well, and has been shown to work fine), and written in a "high level language" so that your garden variety sysadmin _can_ write her own policy, but it really doesn't matter because she'll never have to do so...

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Completely lost me.

I was getting hung up on that one too, but I didn't know how to say it.
You did a nice job. :)

Can you guys be more specific? I don't see any technical objections.

As they say around here "No hay peor ciego que el que no quiere ver" (roughly, "There is no worse blindness than not wanting to see")...

Quoted 3 lines

The only one is that performance
would suffer because of use of higher level language than C or Assembler.

Because the performance and size of kernel code is _critical_, maybe? Because much of the kernel code has been carefully tuned for maximum performance perhaps?

Quoted 2 lines

There is a reason people use languages like PERL, Java and so on.

And there are solid reasons for _not_ writing operating system kernels in them too...

Quoted 7 lines

I would prefer to spend less time writing
actual code - this is what these high level languages for. If performance would be most important - people would do everything in Assembler, but they don't. I'd better write a small Assembler subroutine which will handle stack problems for me and benefit from using the high level language after that.

And then there is the technology of _inventing_ a language tailored to the task at hand... even better than your list of high-level languages.

Quoted 3 lines

There were times when userland projects were written in Assembler. Now people are using other languages, too.

In part because a mediocre compiler these days gives better code than an assembly language coder by hand... and you can compile it for next year's machine too.

Quoted 4 lines

May be it's time to try something new in the
kernel, too :-) Or we will not consider that because nobody did that before? Someone should be the first :-)

It's your time you are wasting... have my blessing.

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
#30 lore raw
Quoted 13 lines · --- Horst von Brand
Quoted 3 lines · Sergiy Lozovsky
Quoted 1 line · --- Timothy Miller

Horst von Brand wrote:

I would prefer to spend less time

writing

Quoted 1 line

actual code - this is what these high level

languages

Quoted 1 line

for. If performance would be most important -

people

Quoted 1 line

would do everything in Assembler, but they don't.

I'd

Quoted 1 line

better write a small Assembler subroutine which

will

Quoted 8 lines
Quoted 1 line

handle stack problems for me and benefit from

using

Quoted 1 line

the high level language after that.

And then there is the technology of _inventing_ a
language tailored to the
task at hand... even better than your list of
high-level languages.

I started exactly with that. I found out shortly that have no idea of functionality needed for such kind of system. It was clear that requirments for this sytem can change rapidly. Only general purpose language can address this problem (if we want to save time of development and introduction of new security models).

Example. Current security policies are 'static'. It seems, that it would be nice to have 'dynamic' policies (with support from security model). Now, policy describes resources available for subsystem. It may be useful to limit the sequence of access to resources - 'behaviour' of subsystem. I'm not sure if I want to implement that right away, but there is commercial system which does exactly that already (it was created later than VXE).

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#31 lore raw
Quoted 1 line · Sergiy Lozovsky

--- Horst von Brand <[email protected]> wrote:

[...]

Quoted 8 lines
Quoted 4 lines

And then there is the technology of _inventing_ a
language tailored to the
task at hand... even better than your list of
high-level languages.

I started exactly with that. I found out shortly that have no idea of functionality needed for such kind of system.

Come back when you have found out.

Quoted 2 lines

It was clear that requirments for this sytem
can change rapidly.

I would not trust anything with "rapidly changing requirements" as security infrastructure.

Quoted 3 lines

Only general purpose language can
address this problem (if we want to save time of development and introduction of new security models).

A security model has to be exhaustively scrutinized, proved correct and complete, and well-tested. The implementation language is completely irrelevant, the hard work is _not_ programming.

Quoted 1 line

Example. Current security policies are 'static'.

In what sense?

Quoted 3 lines

It
seems, that it would be nice to have 'dynamic' policies (with support from security model).

Again, what does this mean?

Quoted 2 lines

Now,
policy describes resources available for subsystem.

No...

Quoted 6 lines

It
may be useful to limit the sequence of access to resources - 'behaviour' of subsystem. I'm not sure if I want to implement that right away, but there is commercial system which does exactly that already (it was created later than VXE).

What is the use of restricting access sequences? If sequence A, B, C is forbidden, chances are that C, B, A (or any of the other 4 permutations) will give an attacker exactly what he wants.

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
#32 lore raw
Quoted 11 lines · --- Horst von Brand
Quoted 1 line · Sergiy Lozovsky

--- Horst von Brand <[email protected]> wrote:

[...]

Quoted 1 line
Quoted 1 line

And then there is the technology of _inventing_

a

Quoted 3 lines
Quoted 3 lines

language tailored to the
task at hand... even better than your list of
high-level languages.

Quoted 7 lines
Quoted 1 line

I started exactly with that. I found out shortly

that

Quoted 1 line

have no idea of functionality needed for such kind

of

Quoted 1 line

system.

Come back when you have found out.

Sorry. I live in the real world. In 1999 I had servers to protect. One of them was hacked and I started to look for tools which could protect servers. I found NOTHING. (there were some Intrusion Detection Systems, which would alert you when your server was ALREADY hacked - it was completely unacceptable for me).

So I created VXE. Problem was solved. I could not sit and think about some perfect design while my servers were in the net unprotected, it's too expensive.

Speed is not most important for me. If I have fast but unprotected server - it is of no use for me.

Quoted 8 lines
Quoted 2 lines

It was clear that requirments for this

sytem

Quoted 1 line

can change rapidly.

I would not trust anything with "rapidly changing
requirements" as security
infrastructure.

VXE worked for me. It was much better than nothing.

Quoted 12 lines
Quoted 1 line

Only general purpose language

can

Quoted 2 lines

address this problem (if we want to save time of development and introduction of new security

models).

A security model has to be exhaustively scrutinized, proved correct and
complete, and well-tested. The implementation language is completely
irrelevant, the hard work is _not_ programming.

Quoted 3 lines
Quoted 1 line

Example. Current security policies are 'static'.

In what sense?

Actually one 'dynamic' feature is implemented in VXE. In ordinary system resource has permissions which allows access or not. For higher security VXE can count number of allowed accesses. For example, we are securing POP server. We allow it to open /etc/passwd, /etc/shadow for reading only once (counter is 1). So, if hacker breaks to POP server after it opened /etc/passwd - there is no way hacker can open this file.

Another 'dynamic' feature is changing policy on the fly. For now POP server can access all mailboxes in /var/spool/mail - it's easy to add ability to modify policy. After POP server authorized user it changes it's UID - at that point we can set access to /var/spool/mail/user_1 only. So POPD couldn't access other files in all mailbox directories.

Quoted 20 lines
Quoted 1 line

It

Quoted 2 lines

seems, that it would be nice to have 'dynamic' policies (with support from security model).

Again, what does this mean?

Quoted 2 lines

Now,
policy describes resources available for

subsystem.

No...

Quoted 1 line

It

Quoted 2 lines

may be useful to limit the sequence of access to resources - 'behaviour' of subsystem. I'm not sure

if

Quoted 2 lines

I want to implement that right away, but there is commercial system which does exactly that already

Quoted 8 lines

(it

Quoted 1 line

was created later than VXE).

What is the use of restricting access sequences? If sequence A, B, C is
forbidden, chances are that C, B, A (or any of the other 4 permutations)
will give an attacker exactly what he wants.

VXE can have counters assigned to syscall parameters. More sophisticated way is to have determined sequence of syscalls. So, if hackers broke in the system (sendmail for example) he can just follow logic of the system - do the work of sendmail for you :-)

I can't say how easy to use this, but the company (my competitors :-) which created this is entercept.com - it seems, that they were very successful - I went to their site right now and was redirected to Network Associates - they were bought out, my guess.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#33 lore raw
Quoted 2 lines · Sergiy Lozovsky
Quoted 1 line · --- Horst von Brand

Sergiy Lozovsky <[email protected]> said:

[...]

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

I started exactly with that. I found out shortly that have no idea of functionality needed for such kind of system.

Quoted 8 lines
Quoted 1 line

Come back when you have found out.

Sorry. I live in the real world. In 1999 I had servers to protect. One of them was hacked and I started to look for tools which could protect servers. I found NOTHING. (there were some Intrusion Detection Systems, which would alert you when your server was ALREADY hacked - it was completely unacceptable for me).

We had an unwellcome visitor in 2001... scrapped SomeOtherUnix shortly thereafter (a "security fix" installed a "remote administration facility" (complete with an extremely nice, well-known hole), which the cracker then used to "remotely administer" our machine...), no further trouble since it is all Linux now. Just be careful in what you install, how you configure, and keep patches up to date.

I.e., a bit of common sense and care goes a _long_ way. Security is mostly a _people_ affair, and has much to do with being careful and attention to detail, it is not at all technical. Trying to solve such a people problem with (misguided) technical measures gets you nowhere.

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
#34 lore raw
Quoted 37 lines · --- Horst von Brand
Quoted 2 lines · Sergiy Lozovsky
Quoted 1 line · --- Horst von Brand

Sergiy Lozovsky <[email protected]> said:

[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line

I started exactly with that. I found out

shortly that

Quoted 1 line
Quoted 1 line
Quoted 1 line

have no idea of functionality needed for such

kind of

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

system.

Come back when you have found out.

Sorry. I live in the real world. In 1999 I had

servers

Quoted 1 line

to protect. One of them was hacked and I started

to

Quoted 1 line

look for tools which could protect servers. I

found

Quoted 1 line

NOTHING. (there were some Intrusion Detection

Systems,

Quoted 2 lines

which would alert you when your server was ALREADY hacked - it was completely unacceptable for me).

We had an unwellcome visitor in 2001... scrapped SomeOtherUnix shortly
thereafter (a "security fix" installed a "remote administration facility"
(complete with an extremely nice, well-known hole), which the cracker then
used to "remotely administer" our machine...), no further trouble since it
is all Linux now. Just be careful in what you install, how you configure,
and keep patches up to date.

Quoted 8 lines

I.e., a bit of common sense and care goes a _long_ way. Security is mostly
a _people_ affair, and has much to do with being careful and attention to
detail, it is not at all technical. Trying to solve such a people problem
with (misguided) technical measures gets you nowhere.

I completely agree with you on that. Security is not only technical issues. I was an owner of the company when our server was hacked, so I did all explanations for down time with our customers. (Downtime was significant - server was collocated in another country and it took quite a while for reinstall Linux - different time zone, nobody on 24x7 duty...).

Advice to apply all new patches is good, one should do that. But there are problems:

1. One should monitor patch development constantly and be paid for that job (additional expenses).
2. Will be patch available in time and would it be possible to find it - there are questions.
3. Some patches are created after security hole was exploited. I don't want to be among these first sites :-)

So, even if you patched everything - there are security holes anyway (patches will be developed in the future). If it is not production server - not a big deal. If it is production - downtimes should be minimal and stealing of sensitive information is unacceptable. If kernel is slow - I'll buy faster hardware with SMP if needed - it's not an issue at all. Not enough - I'll install cluster, but I can't allow system to be compromised.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#35 lore raw
In reply to Sergiy Lozovsky
Quoted 9 lines · Sergiy Lozovsky

Actually one 'dynamic' feature is implemented in VXE. In ordinary system resource has permissions which allows access or not. For higher security VXE can count number of allowed accesses. For example, we are securing POP server. We allow it to open /etc/passwd, /etc/shadow for reading only once (counter is 1). So, if hacker breaks to POP server after it opened /etc/passwd - there is no way hacker can open this file.

Unless he finds an already open file descriptor for it and uses read()/write()/mmap()/etc - did you audit your POP server to make *really* sure that endpwent() is called at all the right times, and that said function actually is guaranteed to close() the file descriptor, and can't be forced into failing? (Note that this can be caused by either close() syscall failing, or the attacker managing to hijack the function entry point for either endpwent() or close()....)

Unless he finds a copy of the file on the process heap (more than one information leakage issue has come from THAT sort of problem)

Unless he opens a new file on the system, and writes a binary into it, chmod's it to executable, and does a pipe/fork/exec and use that program's quota of opens to read it...

And that's just the *obvious* end runs. As somebody else noted, writing the code is the easy part....

#36 lore raw
Quoted 17 lines · --- [email protected] wrote:
Quoted 1 line · Sergiy Lozovsky

Actually one 'dynamic' feature is implemented in

VXE.

Quoted 3 lines

In ordinary system resource has permissions which
allows access or not. For higher security VXE can
count number of allowed accesses. For example, we

are

Quoted 1 line

securing POP server. We allow it to open

/etc/passwd,

Quoted 1 line

/etc/shadow for reading only once (counter is 1).

So,

Quoted 3 lines

if hacker breaks to POP server after it opened /etc/passwd - there is no way hacker can open this file.

Quoted 15 lines

Unless he finds an already open file descriptor for it and uses
read()/write()/mmap()/etc - did you audit your POP server
to make *really* sure that endpwent() is called at all the right
times, and that said function actually is guaranteed to close()
the file descriptor, and can't be forced into failing? (Note that
this can be caused by either close() syscall failing, or the attacker
managing to hijack the function entry point for either endpwent()
or close()....)

Most common way of hacking a box looks much easier. Usual way of stack problems was - to run shell using security hole. Change root password or create new account with root UID. All these usually done with tools available at the system.

VXE use word Environment (description of available resources), some systems use word Domain. There is no shell, ls, vi and so on in POPD Environment. So, most of attackers will just go away. One should be really motivated to master unique binary code to hack VXE protected system. Let's see what is possible even in that case.

Let's assume there is a security hole in POPD. One should create custom binary code to inspect RAM. How to communicate information back to hacker? There should be enough code to do that. This code should not destroy POPD to such extent that it will end (or core dumped), because hacker's code will end too. (POPD doesn't need exec or fork for its work, so hacker can't call these syscalls). So, in theory it is possible to do some damage to particular subsystem, but it's nearly impossible to compromise all system.

Quoted 4 lines

Unless he finds a copy of the file on the process
heap (more than
one information leakage issue has come from THAT
sort of problem)

If you have limited number syscalls (with limited parameters you can call allowed syscalls) - it's VERY hard to do. Purpose of VXE is to protect subsystems, which can have security holes. In real life nobody can gurantee, that there are no security holes in a given system. Some time ago they constantly were finding bugs in sendmail. Nevertheless people were using it.

Quoted 5 lines

Unless he opens a new file on the system, and writes a binary into
it, chmod's it to executable, and does a pipe/fork/exec and use
that program's quota of opens to read it...

POPD doesn't use chmod/fork/exec, so that wouldn't work - there are no these syscalls in POPD Environment. Let's assume some file was created by hacker in /var/spool/mailbox, so what? How that can damage the system. (it's the only directory where POPD can create/modify files).

Quoted 3 lines

And that's just the *obvious* end runs. As somebody else noted,
writing the code is the easy part....

So, in theory it is possible to make some damage to hacked subsystem (POPD for example and damaged can be only mailboxes), but the rest of the system will be intact (and there is a lot of stuff in the system except POPD). But in practice with such striped environment - without shell, editors, limited set of syscalls - generic hackers tools will not work. Only if someone will dedicate efforts to create custom tools for your particular site - he can damage mailboxes at most (in case of POPD). I think, that it is a pretty good result.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#37 lore raw
Quoted 14 lines · Sergiy Lozovsky

Usual way of stack problems was - to run shell using security hole. Change root password or create new account with root UID. All these usually done with tools available at the system.

VXE use word Environment (description of available resources), some systems use word Domain. There is no shell, ls, vi and so on in POPD Environment. So, most of attackers will just go away. One should be really motivated to master unique binary code to hack VXE protected system. Let's see what is possible even in that case.

Quoted 10 lines

Let's assume there is a security hole in POPD. One should create custom binary code to inspect RAM. How to communicate information back to hacker? There should be enough code to do that. This code should not destroy POPD to such extent that it will end (or core dumped), because hacker's code will end too. (POPD doesn't need exec or fork for its work, so hacker can't call these syscalls). So, in theory it is possible to do some damage to particular subsystem, but it's nearly impossible to compromise all system.

Why shouldn't it?

It can just replace the entire code with itself. and since you cannot prevent the use of mmap (which is used to load the runtime libraries AND the executable) it can still do that.

Quoted 5 lines
Quoted 4 lines

Unless he finds a copy of the file on the process
heap (more than
one information leakage issue has come from THAT
sort of problem)

Quoted 7 lines

If you have limited number syscalls (with limited parameters you can call allowed syscalls) - it's VERY hard to do. Purpose of VXE is to protect subsystems, which can have security holes. In real life nobody can gurantee, that there are no security holes in a given system. Some time ago they constantly were finding bugs in sendmail. Nevertheless people were using it.

And they were fixing it. Not trying to make VERY kluged work arounds in the kernel.

Quoted 6 lines
Quoted 5 lines

Unless he opens a new file on the system, and writes a binary into
it, chmod's it to executable, and does a pipe/fork/exec and use
that program's quota of opens to read it...

Quoted 6 lines

POPD doesn't use chmod/fork/exec, so that wouldn't work - there are no these syscalls in POPD Environment. Let's assume some file was created by hacker in /var/spool/mailbox, so what? How that can damage the system. (it's the only directory where POPD can create/modify files).

You don't need to use chmod/fork/exec. It is entire possible to replace the executable just by using mmap. I've already written programs that deliberately do that (though I did use dlopen). I've written a single binary that do anything. Including running previously build applications.

After all - ld.so does just that during the initial load an execed binary. All exec does is start ld.so with different parameters... and nothing says that can't be done again.

And just not having a shell program on disk is silly - It can be created rather easily. After all, that is what root kits do routinely.

Quoted 4 lines
Quoted 3 lines

And that's just the *obvious* end runs. As somebody else noted,
writing the code is the easy part....

Quoted 11 lines

So, in theory it is possible to make some damage to hacked subsystem (POPD for example and damaged can be only mailboxes), but the rest of the system will be intact (and there is a lot of stuff in the system except POPD). But in practice with such striped environment - without shell, editors, limited set of syscalls - generic hackers tools will not work. Only if someone will dedicate efforts to create custom tools for your particular site - he can damage mailboxes at most (in case of POPD). I think, that it is a pretty good result.

It would be better to use a chroot environment.

#38 lore raw
In reply to Sergiy Lozovsky
Quoted 7 lines · * Sergiy Lozovsky ([email protected]) wrote:

No :-) What you suggest is kernel should receive system call from user space. Instead of handling it - kernel should forward it back to userspace, than it should be forwarded back to the kernel. Looks not very nice to me. Why not to handle security policy inside the kernel as it is done for the file permissions and root priveleges?

All this can be done w/out having a LISP interpretter coming along for the ride, that's the point of the other posters. With LSM you have a framework for implementing your own security model and enforcing your own policies.

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
#39 lore raw
Quoted 14 lines · --- Chris Wright
Quoted 2 lines · * Sergiy Lozovsky ([email protected]) wrote:

No :-) What you suggest is kernel should receive
system call from user space. Instead of handling

it -

Quoted 1 line

kernel should forward it back to userspace, than

it

Quoted 1 line

should be forwarded back to the kernel. Looks not

very

Quoted 1 line

nice to me. Why not to handle security policy

inside

Quoted 1 line

the kernel as it is done for the file permissions

and

Quoted 1 line

root priveleges?

Quoted 7 lines

All this can be done w/out having a LISP interpretter coming along for the
ride, that's the point of the other posters. With LSM you have a
framework for implementing your own security model and enforcing your own
policies.

LSM use another way of doing similar things :-) I'm not sure that it is nice to forward system calls back to userspace where they came from in the first place :-) VXE use high level language to create security models.

And what are the problems with technology used by VXE? File permissions are checked in the kernel and everybody are happy with that. VXE just extends security features already available in the kernel.

There is a historic part to all that, too - VXE was created (1999) before SELinux was available.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#40 lore raw
Quoted 5 lines · * Sergiy Lozovsky ([email protected]) wrote:

LSM use another way of doing similar things :-) I'm not sure that it is nice to forward system calls back to userspace where they came from in the first place :-) VXE use high level language to create security models.

There's no requirement in LSM to forward syscalls back to userspace for access control check. At any rate, seems you like your solution, just wanted to make sure you were aware of alternatives.

Quoted 1 line

And what are the problems with technology used by VXE?

It's the LISP interpreter that's problematic. As you've already seen with the kernel stack limitations.

Quoted 3 lines

File permissions are checked in the kernel and everybody are happy with that. VXE just extends security features already available in the kernel.

And LSM checks are done in kernel.

Quoted 2 lines

There is a historic part to all that, too - VXE was created (1999) before SELinux was available.

Ah, the real truth ;-)

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
#41 lore raw
In reply to Sergiy Lozovsky
Quoted 8 lines · Sergiy Lozovsky

LSM use another way of doing similar things :-) I'm not sure that it is nice to forward system calls back to userspace where they came from in the first place :-) VXE use high level language to create security models.

"Kernel space -> user space -> kernel space" is nothing compared to the overhead of a LISP interpreter.

Doing interpretation of LISP is a monster compared to some piddly context switches.

#42 lore raw
Quoted 9 lines · --- Timothy Miller
Quoted 3 lines · Sergiy Lozovsky

LSM use another way of doing similar things :-)

I'm

Quoted 1 line

not sure that it is nice to forward system calls

Quoted 8 lines

back

Quoted 1 line

to userspace where they came from in the first

place

Quoted 3 lines

:-) VXE use high level language to create security models.

"Kernel space -> user space -> kernel space" is

To be more precise "user space -> kernel space -> user space -> kernel space -> user space"

against ordinary "user space -> kernel space -> user space"

So, what happens - task makes system calls and blocks; request goes to a user space security server. Will it process request right away? No, it will wait for scheduler to chose it for execution. Ok server got CPU and returns results to the kernel. Will initial task continue? No, it will wait for be chosen by scheduler. This is what I call overhead (though i understand, that can be wrong). My system (VXE) doesn't involve scheduler at all.

So we should not just look into length of this chain at the picture. - "user space -> kernel space -> user space -> kernel space -> user space" - we should remember that it involves to mandatory task switches to accomplish jus one system call.

Quoted 2 lines

nothing compared to the
overhead of a LISP interpreter.

LISP code, is very small actually. And nobody can just kill it. I know it's not a real protection, but intent was to place a security system in such place where it will be more protected by itself. I placed additional security mechanisms in the place where designers of UNIX placed theirs (file permissions an so on) - in the kernel.

Quoted 3 lines

Doing interpretation of LISP is a monster compared to some piddly
context switches.

When people say LISP they mean Common LISP, which is a monster and I agree with you. VXE uses stripped down version of LISP and syntax of LISP is far simpler than C for example.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#43 lore raw
Quoted 26 lines · Sergiy Lozovsky
Quoted 11 lines · --- Timothy Miller
Quoted 1 line · Sergiy Lozovsky

LSM use another way of doing similar things :-)

I'm

Quoted 1 line

not sure that it is nice to forward system calls

back

Quoted 1 line

to userspace where they came from in the first

Quoted 7 lines

place

Quoted 3 lines

:-) VXE use high level language to create security

models.

"Kernel space -> user space -> kernel space" is

To be more precise "user space -> kernel space -> user space -> kernel space -> user space"

against ordinary "user space -> kernel space -> user space"

Quoted 9 lines

So, what happens - task makes system calls and blocks; request goes to a user space security server. Will it process request right away? No, it will wait for scheduler to chose it for execution. Ok server got CPU and returns results to the kernel. Will initial task continue? No, it will wait for be chosen by scheduler. This is what I call overhead (though i understand, that can be wrong). My system (VXE) doesn't involve scheduler at all.

Depends on what the requirement is. In some cases you MUST do this - otherwise the tables required for making the decision would be WAY too large for the kernel.

Some models even require reference to remote hosts for validation. The current Kerberos authentication requires this. So do AFS requests.

Other requests can be satisfied by a cached table entry without waiting.

Quoted 5 lines

So we should not just look into length of this chain at the picture. - "user space -> kernel space -> user space -> kernel space -> user space" - we should remember that it involves to mandatory task switches to accomplish jus one system call.

It only depends on the request. If the entire security context is local, then this is not required.

Quoted 10 lines
Quoted 2 lines

nothing compared to the
overhead of a LISP interpreter.

LISP code, is very small actually. And nobody can just kill it. I know it's not a real protection, but intent was to place a security system in such place where it will be more protected by itself. I placed additional security mechanisms in the place where designers of UNIX placed theirs (file permissions an so on) - in the kernel.

LISP code (if compiled machine code) IS small. LISP VM is not - when you combine it with the lisp code, the heap management, and garbage collector. And you can STILL have memory leaks out the wazoo. To prevent the memory leaks you have to have a mark and sweep GC. Which still doesn't prevent circular loop leaks. Then you need a memory pool allocator to relocate all valid references. The combination is NOT small. BTW, the JVM suffers from circular loop leaks too, since all it uses is reference counting (for speed).

Quoted 8 lines
Quoted 3 lines

Doing interpretation of LISP is a monster compared to some piddly
context switches.

When people say LISP they mean Common LISP, which is a monster and I agree with you. VXE uses stripped down version of LISP and syntax of LISP is far simpler than C for example.

No - they mean the VM + garbage collector + error handler + the lisp pcode.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): mit.lcs.mail.linux-kernel/[email protected]

#46 lore raw
Quoted 2 lines · Jesse Pollard

To prevent the memory leaks you have to have a mark and sweep GC. Which still doesn't prevent circular loop leaks.

What are you talking about? A mark/sweep GC certainly DOES collect circular data structures.

Perhaps you are thinking of reference counting GCs?

Quoted 2 lines

Then you need a memory pool allocator to relocate all valid references.

Now you seem to talking about stop and copy, which is something else again. And it is not required to avoid memory leaks, although it does fix fragmentation.

Quoted 2 lines

The combination is NOT small. BTW, the JVM suffers from circular loop leaks too, since all it uses is reference counting (for speed).

Which JVM are you talking about? Every JVM I know of uses a real garbage collector, not some reference counting hack.

Perhaps you are thinking of Perl?

Sergiy is right: A Lisp interpreter and runtime can be quite small and efficient. And it can provide a secure "sandbox" for running questionable code safely.

Whether it is a good idea in this context is another question. My concern is that it is hard (impossible?) to bound the memory consumption, both stack AND heap, of a Lisp program statically. I would expect such bounds to be important for an implementation of a security model. With a Lisp program, you cannot be sure under what conditions it will exceed whatever space you have alloted for it. Which means that, although it cannot crash the kernel, it cannot be used to build a reliable system, either...

- Pat

#47 lore raw
Quoted 9 lines · Patrick J. LoPresti

Whether it is a good idea in this context is another question. My concern is that it is hard (impossible?) to bound the memory consumption, both stack AND heap, of a Lisp program statically. I would expect such bounds to be important for an implementation of a security model. With a Lisp program, you cannot be sure under what conditions it will exceed whatever space you have alloted for it. Which means that, although it cannot crash the kernel, it cannot be used to build a reliable system, either...

I think 100K is rather large for an interpretor to be included in the kernel, but putting that aside...

It's a limited number of people who would actually write these policies.
If those people follow certain coding rules, then we CAN have such
bounds, by convention. Yes, those bounds could be violated, but if the programmer (not sysadmin -- they would never write these things in LISP) breaks something, it's just a bug.

Mostly it would be kernel programmers who write the policies, and those would appear in some /etc directory, put there by Red Hat, and selectable by admins using some GUI.

Someone writing a policy which caused the VM to explode would be no different from nVidia writing a kernel driver which did it more directly.

The advantage of scripting the policy (which is essentially what this is) is that they could be switchable more dynamically, and they could refer to kernel structures more abstractly.

#48 lore raw
Quoted 2 lines · Timothy Miller

I think 100K is rather large for an interpretor to be included in the kernel, but putting that aside...

I think we are all putting that aside for the moment. :-)

Quoted 5 lines

It's a limited number of people who would actually write these policies. If those people follow certain coding rules, then we CAN have such bounds, by convention. Yes, those bounds could be violated, but if the programmer (not sysadmin -- they would never write these things in LISP) breaks something, it's just a bug.

Fair enough. But then I wonder how many of Lisp's advantages you would lose. I am having trouble imagining "statically bounded Lisp" without being so stylized as to hardly be Lisp at all.

- Pat

#49 lore raw
Quoted 11 lines · Patrick J. LoPresti
Quoted 5 lines

It's a limited number of people who would actually write these policies. If those people follow certain coding rules, then we CAN have such bounds, by convention. Yes, those bounds could be violated, but if the programmer (not sysadmin -- they would never write these things in LISP) breaks something, it's just a bug.

Fair enough. But then I wonder how many of Lisp's advantages you would lose. I am having trouble imagining "statically bounded Lisp" without being so stylized as to hardly be Lisp at all.

Given that the original author admits that the sysadmins using this would never actually write any LISP code, I too fail to see why LISP would be of any help here.

If you want to be compact and efficient, some really simple pseudo-language would do the job well enough. Optimize for speed of execution and compactness of both interpreter and policy code, not for easy of writing in the language.

I mean, by choosing LISP, "ease of writing in the language" was thrown out the window to begin with! :)

I think this points us in the direction of something like Forth. Take OpenBoot for example. I wrote Forth-like interpreters in Pascal when I was in highschool.

But if you DO want sysadmins to be able to write this, then something resembling shell script would be better. It wouldn't be quite like shell scripting, but it would LOOK like it, and it would have to be compiled (by the program that you run to load the policy) into something compact and easy to interpret before being fed to the kernel.

Another possibility is to develop a set of tools that compile policies written in C into modules that are loaded/unloaded into the kernel dynamically. :) The compile process would be transparent to the user, because the "insert this policy" tool would run it through GCC (unless the cached .ko was already up to date, etc.).

#50 lore raw
In reply to Patrick J. LoPresti
Quoted 8 lines · Patrick J. LoPresti
Quoted 2 lines · Jesse Pollard

To prevent the memory leaks you have to have a mark and sweep GC. Which still doesn't prevent circular loop leaks.

What are you talking about? A mark/sweep GC certainly DOES collect circular data structures.

Perhaps you are thinking of reference counting GCs?

Ummm. I wasn't precise, sorry. some of the structures I was thinking of must be imported from outside the LISP vm. Think inode data, skb structures, parts of the security context. These are not allocated by the LISP vm, and are not supported by it. And these may be lost by it. I say may, since some security aspects of these structures must be allocated by it (the VM), and then passed externally to provid tracking capabilities.

Deallocation via mark/sweep would cause dangling pointers in these external structures. And if you don't pass allocated structures to these kernel objects then you must search for the corresponding structures to the objects when a security decision must be made (more overhead - which was why the LSM added security blob pointers to the various structures).

The pure LISP structures are recovered - I was actually thinking about the overhead of the mark/sweep causing significant amounts of fragmentation until the mark/sweep is completed, which can still leave a LOT of fragmentation behind.

Quoted 6 lines
Quoted 2 lines

Then you need a memory pool allocator to relocate all valid references.

Now you seem to talking about stop and copy, which is something else again. And it is not required to avoid memory leaks, although it does fix fragmentation.

Yup. And it is hard. But even mark/sweep algorithms require that the LISP interpreter stop. This was one of the problems with early LISP machines - they would stop for 3-10 seconds during the mark/sweep - their
solution: two processors, and memory pools.

Quoted 5 lines
Quoted 2 lines

The combination is NOT small. BTW, the JVM suffers from circular loop leaks too, since all it uses is reference counting (for speed).

Which JVM are you talking about? Every JVM I know of uses a real garbage collector, not some reference counting hack.

Most JVM used (at least the ones I've run across) are not designed for server use. These are very small JVMs, and they use reference counting. Once the applet terminates, so does the JVM, and when restarted, it resets memory allocations (aka memory pool).

Quoted 1 line

Perhaps you are thinking of Perl?

Nope. I have seen some small LISP interpreters use reference counting
- even wrote one of my own.

Quoted 3 lines

Sergiy is right: A Lisp interpreter and runtime can be quite small and efficient. And it can provide a secure "sandbox" for running questionable code safely.

Provided you don't depend on a GC, and have a way to prevent failure (aborts) from causing system wide failure - which is a problem with security reference monitors.

Quoted 8 lines

Whether it is a good idea in this context is another question. My concern is that it is hard (impossible?) to bound the memory consumption, both stack AND heap, of a Lisp program statically. I would expect such bounds to be important for an implementation of a security model. With a Lisp program, you cannot be sure under what conditions it will exceed whatever space you have alloted for it. Which means that, although it cannot crash the kernel, it cannot be used to build a reliable system, either...

It is impossible to guarantee memory bounds without eliminating most of the capability of LISP (specific applications + data can be proven bounded, but the general case cannot). The inherent recursive structure forces the memory to be unbound (especially the stack) in presence of multiple function interactions. Sometimes (many times?) the recursive structure can be eliminated by a very good optimizer, but this takes both time and overhead - and is aimed at generating "just in time" machine code, not LISP pcode.

#51 lore raw
In reply to Sergiy Lozovsky
Quoted 8 lines · Sergiy Lozovsky

1. Give system administrator possibility to change security policy easy enough without C programminig inside the kernel (we should not expect system administartor to be a kernel guru). Language of higher lavel make code more compact (C - is too low level, that's why people use PERL for example or LISP). Lisp was chosen because of very compact VM - around 100K.

And you expect your sysadmins to know LISP? I would hardly think of LISP as any kind of simplification to anything.

I mean, I like the language and all, but it is in no way "simpler" than C and it's definately not appropriate for in-kernel stuff.

Quoted 9 lines

2. Protect system from bugs in security policy created by system administrator (user). LISP interpreter is a LISP Virtual Machine (as Java VM). So all bugs are incapsulated and don't affect kernel. Even severe bugs in this LISP kernel module can cause termination of user space application only (except of stack overflow
- which I can address). LISP error message will be printed in the kernel log.

In theory, we could develop the kernel in a language that does all sorts of protection, garbage collection, run-time checking, etc. Kernel developers choose not to because the performance hit would be HORRIBLE.

Now... that doesn't mean you can't do kernel-level stuff in LISP. You just don't do it _in_ the kernel. Given the absolutely MASSIVE overhead you're already incurring by using a LISP interpreter, having to context-switch into user space won't hurt in the least. So, what you do is have a C-based stub in the kernel which passes stuff off to the user-space LISP daemon which calls back into the kernel for accessing devices, etc.

THAT would be a much better way of doing this.

#52 lore raw
In reply to Sergiy Lozovsky
Quoted 6 lines · Sergiy Lozovsky
Quoted 2 lines

Consider rewriting your function to use allocated memory instead of stack, this isn't all that hard.

I put LISP interpreter inside the Kernel -
http://vxe.quercitron.com

Quoted 9 lines

It works, but it use a lot of stack memory. It's impossible to rewrite it easily, though I'll investigate why exactly it uses so much of stack memory (though it's nature of LISP). There are no serious kernel memory allocation (as of my interpreter code review, only function calls; recursions in LISP application itself are eliminated for sure), but I'll trace stack usage more thouroughly.

Consider this. We're currently experimenting with a transition from 8k to 4k stacks on x86, and that is considered a very good thing. Allocating a single- page stack is easy, two (contigous) pages might fail.

So a bigger kernel stack is out.

As for rewriting code so it doesn't use stack - it _is_ easy, but it might be a lot of _work_.

The simple approach is to replace all (big) stack allocations with an explicit stack structure that you manages on the heap. There'll be more code, but it won't be slower because all the extra code is stuff that happen automatically with the hw stack. (I.e. stuff the compiler normally take care of.)

There is some more work if your interpreter also does deep recursion. It involves making one big function of those that do the recursion and manage the "calls" yourself with an array and a switch statement. Again, not particularly hard, but it could take some time to implement.

Helge Hafting

#53 lore raw

If stack will shrink - i'll come up with something. Rearchitecture of LISP interpreter - is too much work. (and I'm lazy - I prefer computer to do a work, not me :-)

I checked what is going on with the stack - it is used to pass parameters, some functions have one or two local variables (4 bytes each) and that's it.

I like to develop tools and general solutions :-) To solve the stack problem in a way which will not cause big changes in any existing code - I can make stack virtualization. API can be different, but idea is the same. Task has some memory allocated by malloc (vstack) which is used for saving data from real stack. One of the APIs - scall function:

scall(pointer_to_vstack, number_of_arguments, pointer_to_function_to_call, arg1, arg2,...)

scall checks if real stack is full enough - it stores it's content in the vstack and moves %esp to the bottom of the real stack. When user function returns - information from vstack moves to the real one (one movl instruction at Intel x86).

In case of LISP there is only one place where it will be enough to use scall - eval function.

In other subsystems - it can be needed to call in a few places. But in such way a new 4K stack could be used without serious rewriting of existing code.

vstack can grow dynamically if needed (within defined limit).

Serge.

Quoted 53 lines · --- Helge Hafting
Quoted 1 line · Sergiy Lozovsky
Quoted 1 line

Consider rewriting your function to use

allocated

Quoted 1 line
Quoted 1 line

memory instead of stack, this isn't all that

hard.

Quoted 9 lines

I put LISP interpreter inside the Kernel -
http://vxe.quercitron.com

It works, but it use a lot of stack memory. It's impossible to rewrite it easily, though I'll investigate why exactly it uses so much of stack memory (though it's nature of LISP). There are no serious kernel memory allocation (as of my

interpreter

Quoted 1 line

code review, only function calls; recursions in

LISP

Quoted 1 line

application itself are eliminated for sure), but

I'll

Quoted 2 lines

trace stack usage more thouroughly.

Consider this. We're currently experimenting with a transition from 8k to 4k stacks on x86, and that is considered a very good thing. Allocating a single- page stack is easy, two (contigous) pages might fail.

So a bigger kernel stack is out.

As for rewriting code so it doesn't use stack - it _is_ easy, but it might be a lot of _work_.

The simple approach is to replace all (big) stack allocations with an explicit stack structure that you manages
on the heap. There'll be more code, but it won't be slower
because all the extra code is stuff that happen automatically
with the hw stack. (I.e. stuff the compiler normally take
care of.)

There is some more work if your interpreter also does deep recursion.
It involves making one big function of those that do the recursion
and manage the "calls" yourself with an array and a switch statement.
Again, not particularly hard, but it could take some time to implement.

Quoted 1 line

Helge Hafting

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#54 lore raw
Quoted 1 line · Sergiy Lozovsky

If stack will shrink - i'll come up with something.

Good luck! When it is done shrinking, there won't be much (if any) left for you to play with.

Quoted 1 line

Rearchitecture of LISP interpreter - is too much work.

Implement a kernel-side LISP interpreter isn't...

Quoted 2 lines

(and I'm lazy - I prefer computer to do a work, not me :-)

Nodz. But even better is _not_ doing it at all ;-)

Quoted 3 lines

I checked what is going on with the stack - it is used to pass parameters, some functions have one or two local variables (4 bytes each) and that's it.

Why do you think it has been 2 pages (8KiB) for as long as I remember (essentially forever in Linux), and it has taken a _lot_ of work to shrink it to 4KiB (- size of *current)?

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
#55 lore raw
Quoted 7 lines · --- Horst von Brand

Sergiy Lozovsky <[email protected]> said:

Why do you think it has been 2 pages (8KiB) for as long as I remember
(essentially forever in Linux), and it has taken a _lot_ of work to shrink
it to 4KiB (- size of *current)?

I described the possible solution (virtual stack) which can easily take care of this problem for some subsystems, or am I wrong. If code doesn't allocate big buffers in stack my solution can make conversion of existing code possible without _lot_ of work. (I'm lazy - remember :-)

What do you think about my solution? Despite some additional overhead, but I don't think that it is significant.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#56 lore raw
Quoted 10 lines · Sergiy Lozovsky
Quoted 7 lines · --- Horst von Brand

Sergiy Lozovsky <[email protected]> said:

Why do you think it has been 2 pages (8KiB) for as long as I remember
(essentially forever in Linux), and it has taken a _lot_ of work to shrink
it to 4KiB (- size of *current)?

Quoted 6 lines

I described the possible solution (virtual stack) which can easily take care of this problem for some subsystems, or am I wrong. If code doesn't allocate big buffers in stack my solution can make conversion of existing code possible without _lot_ of work. (I'm lazy - remember :-)

You know, to me the combination of lazy programmer rhymes poorly with well-written code and security audits.

Quoted 3 lines

What do you think about my solution? Despite some additional overhead, but I don't think that it is significant.

Personally, I think this proposal would be worthy for the patch-of-the-month award.

Regards: David Weinehall

Signature · 3 lines
 /) David Weinehall <[email protected]> /) Northern lights wander      (\
//  Maintainer of the v2.0 kernel   //  Dance across the winter sky //
\)  http://www.acc.umu.se/~tao/    (/   Full colour fire           (/
#57 lore raw
Quoted 2 lines · David Weinehall

Personally, I think this proposal would be worthy for the patch-of-the-month award.

I dunno...the proposal to rewrite the kernel and libc in assembly is pretty high up there....

Chris

#58 lore raw
Quoted 9 lines · --- Chris Friesen
Quoted 1 line · David Weinehall

Personally, I think this proposal would be worthy

for the

Quoted 1 line

patch-of-the-month award.

I dunno...the proposal to rewrite the kernel and
libc in assembly is
pretty high up there....

My proposal gives ability to avoid rewriting of code and saves time. If there is a time to rewrite code - it can be rewritten. For parts we don't have time to rewrite - virtual stack can be used without serious code modifications.

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#59 lore raw
In reply to David Weinehall
Quoted 20 lines · --- David Weinehall
Quoted 5 lines · Sergiy Lozovsky
Quoted 3 lines · --- Horst von Brand

Sergiy Lozovsky <[email protected]> said:

Why do you think it has been 2 pages (8KiB) for

as

Quoted 2 lines
Quoted 2 lines

long as I remember
(essentially forever in Linux), and it has taken

a

Quoted 5 lines
Quoted 2 lines

_lot_ of work to shrink
it to 4KiB (- size of *current)?

I described the possible solution (virtual stack)
which can easily take care of this problem for

some

Quoted 1 line

subsystems, or am I wrong. If code doesn't

allocate

Quoted 1 line

big buffers in stack my solution can make

Quoted 8 lines

conversion

Quoted 1 line

of existing code possible without _lot_ of work.

(I'm

Quoted 1 line

lazy - remember :-)

You know, to me the combination of lazy programmer rhymes poorly with
well-written code and security audits.

Don't take my non technical comments too seriously. Life is too short to be serious all the time. If I was not successful in making a joke - sorry.

(there was an old joke that programmers are very lazy people - they don't like to work, so they write programs and computers work for them; I just quoted this joke).

Serge.

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

#60 lore raw
In reply to Horst von Brand
Quoted 9 lines · Horst von Brand
Quoted 1 line · Sergiy Lozovsky

If stack will shrink - i'll come up with something.

Good luck! When it is done shrinking, there won't be much (if any) left for you to play with.

Quoted 1 line

Rearchitecture of LISP interpreter - is too much work.

Implement a kernel-side LISP interpreter isn't...

It's a userland (and leaky, at that) LISP interpreter plus some glue and duct tape to make it kinda-sorta work in kernel mode - enough for a demo, in any case. BTW, the LISP dialect implemented by that interpreter is unimpressive, to put it mildly. Even aside of atrocious "GC" and lexer (BTW, have the author of RefLISP ever heard of arcane technics known as "checking the return value of malloc"?), semantics of his EVAL would be a shame even in 70s (at any point after Landin's papers, actually). Sigh...

#61 lore raw
In reply to Helge Hafting
Quoted 3 lines · Helge Hafting

The simple approach is to replace all (big) stack allocations with an explicit stack structure that you manages on the heap.

Maybe Stackless Python is a better fit for this kernel project?

:) [1/2 serious]

-- Jamie

#62 lore raw

You want these guys to fry me? :-) Do you like it well done? :-)

Serge.

Quoted 4 lines · --- Jamie Lokier
Quoted 2 lines · Helge Hafting

The simple approach is to replace all (big) stack
allocations with an explicit stack structure that

you manages

Quoted 8 lines
Quoted 1 line

on the heap.

Maybe Stackless Python is a better fit for this
kernel project?

:) [1/2 serious]

-- Jamie

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/