Skip to contentSkip to conversation

viewprinting: what format should views be stored in?

DISCUSSION Hans Reiser 2 participants 12 messages Aug 16, 2004 – Aug 18, 2004 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

It is very important that we have something simple that reuses code for this purpose, and it also needs to be scalable. That is, we need to be able to determine in insignificant time whether a file passes through a mask consisting of a million files.

One approach would be to use a format similar to that for chroot, that is, to keep the format we use for directory trees now, and use it for storing the mask. This raises the question: how would the format for the mask differ from that of the underlying filesystem.

Another approach is to use stem compressed names, or some other unique within the fs format for the mask.

We need to be able to support specifying a mask that allows any file within a given directory to be visible. That is, we need to support dirname/* but we don't yet need to support dirname/foo.*

We probably don't want to allow symbolic links to be followed unless where they point to is within the mask.

I want minimal code but I want it to be treelike in its performance scalability.

Ideas?

#1 lore raw

First a little (*/tentatively/*) suggested terminology---translation of (/tentatively/) I stand behind it until I begin to suspect I've made a mistake and then I change sides ;-) :

1) A *mask *consists of a set of *prescriptions *(trying to avoid rule) which defines a / subset/ of permissible functionality for a file system.

2) The *permissible functionality *of a file system is roughly speaking, the ACLs for all the objects in the file system.

Actually, I think this is a good place to start, because the type
"permissible
functionality" is in fact what the mask is applied to and what is
returned.
Grant you evaluation is done lazily as the execution of an
application requires it.

3) A user and group instantiated mask forms an *operational set of functionality*.

What is important here is to recognize that a given executable may have different apparent functionality based on who is running it.

To make this concept clearer, consider the possibility that group
write access
to a file might be elided (masked away) by the some prescription
for a user
who otherwise might have add access---but the user's privileges are
limited
by the executable.

Quoted 1 line · Hans Reiser

It is very important that we have something simple that reuses code for this purpose, and it also needs to be scalable. That is, we need to be able to determine in insignificant time whether a file passes through a mask consisting of a million files.

A million files or a million rules? A single rule may give access to a million files and
require only constant time to evaluate.

Quoted 3 lines

One approach would be to use a format similar to that for chroot, that is, to keep the format we use for directory trees now, and use it for storing the mask. This raises the question: how would the format for the mask differ from that of the underlying filesystem.

Another approach is to use stem compressed names, or some other unique within the fs format for the mask.

Can you elaborate on this for a newbie

Quoted 2 lines

We need to be able to support specifying a mask that allows any file within a given directory to be visible. That is, we need to support dirname/* but we don't yet need to support dirname/foo.*

NB. Hans and I had discussed limiting access to 'hidden files' informally: '..' in particular needs some special attention although it would be best not to have a special case if we can avoid it.

Quoted 2 lines

We probably don't want to allow symbolic links to be followed unless where they point to is within the mask.

Agreed.

Quoted 3 lines

I want minimal code but I want it to be treelike in its performance scalability.

Ideas?

Well, for the moment only more questions:

Suppose we have a file system and a mask. If we were to create a chroot by copying just the file system accessible through the mask and run the application in that environment would the semantics of running the application on the original file system with the mask by equivalent. By equivalent I mean no observable difference in the instructions executed at the user level or the output generated.

Does the question make sense?

#2 lore raw
Quoted 10 lines · George Beshers

First a little (*/tentatively/*) suggested terminology---translation of (/tentatively/) I stand behind it until I begin to suspect I've made a mistake and then I change sides ;-) :

1) A *mask *consists of a set of *prescriptions *(trying to avoid rule) which defines a / subset/ of permissible functionality for a file system.

2) The *permissible functionality *of a file system is roughly speaking, the ACLs for all the objects in the file system.

Quoted 7 lines

Actually, I think this is a good place to start, because the type
"permissible
functionality" is in fact what the mask is applied to and what is
returned.
Grant you evaluation is done lazily as the execution of an
application requires it.

Yes.

Quoted 5 lines

3) A user and group instantiated mask forms an *operational set of functionality*.

What is important here is to recognize that a given executable
may have
different apparent functionality based on who is running it.

I think not in our particular niche. We do process oriented security, and that is all for now. Later we can make it more complex.

Quoted 11 lines

To make this concept clearer, consider the possibility that group
write access
to a file might be elided (masked away) by the some prescription
for a user
who otherwise might have add access---but the user's privileges
are limited
by the executable.

Quoted 5 lines
Quoted 1 line · Hans Reiser

It is very important that we have something simple that reuses code for this purpose, and it also needs to be scalable. That is, we need to be able to determine in insignificant time whether a file passes through a mask consisting of a million files.

A million files or a million rules

filenames actually.

Quoted 8 lines

A single rule may give access to a million files and
require only constant time to evaluate.

Quoted 3 lines

One approach would be to use a format similar to that for chroot, that is, to keep the format we use for directory trees now, and use it for storing the mask. This raises the question: how would the format for the mask differ from that of the underlying filesystem.

Another approach is to use stem compressed names, or some other unique within the fs format for the mask.

Can you elaborate on this for a newbie

fired
fireman
fireplace
get stored as
fired
!4man
!4place
if we use classic stem compression, if we use a tree that branches where the names diverge (I forget, is that a radix tree or?) then we have another structure.

Quoted 5 lines
Quoted 2 lines

We need to be able to support specifying a mask that allows any file within a given directory to be visible. That is, we need to support dirname/* but we don't yet need to support dirname/foo.*

NB. Hans and I had discussed limiting access to 'hidden files' informally: '..' in particular needs some special attention although it would be best not to have a special case if we can avoid it.

We can treat .. the same as we treat symboplic links.

Quoted 5 lines
Quoted 2 lines

We probably don't want to allow symbolic links to be followed unless where they point to is within the mask.

Agreed.

Quoted 8 lines
Quoted 3 lines

I want minimal code but I want it to be treelike in its performance scalability.

Ideas?

Well, for the moment only more questions:

Suppose we have a file system and a mask. If we were to create a chroot by copying just the file system

semantic tree (not files, just filenames)

Quoted 4 lines

accessible through the mask and run the application in that environment would the semantics of running the application on the original file system with the mask by equivalent. By equivalent I mean no observable difference in the instructions executed at the user level or the output generated.

No, because new files might be made visible through the mask without the new file creator even being aware that there was a mask.

Quoted 3 lines

Does the question make sense?

#3 lore raw
Quoted 7 lines · Hans Reiser
Quoted 5 lines
Quoted 2 lines

Another approach is to use stem compressed names, or some other unique within the fs format for the mask.

Can you elaborate on this for a newbie

Quoted 8 lines

fired
fireman
fireplace
get stored as
fired
!4man
!4place
if we use classic stem compression, if we use a tree that branches where the names diverge (I forget, is that a radix tree or?) then we have another structure.

Trie I think is what you mean. http://www.nist.gov/dads/HTML/trie.html

#4 lore raw
In reply to Hans Reiser
Quoted 5 lines · Hans Reiser
Quoted 3 lines · George Beshers

2) The *permissible functionality *of a file system is roughly speaking, the ACLs for all the objects in the file system.

Quoted 8 lines
Quoted 7 lines

Actually, I think this is a good place to start, because the type
"permissible
functionality" is in fact what the mask is applied to and what is
returned.
Grant you evaluation is done lazily as the execution of an
application requires it.

Yes.

I have started re-reading withe Single UNIX Specification with getting a working definition of permissible functionality in mind. Have not gotten to Usenix papers yet or a careful search of ACM.

Does anyone think there is a better starting point? Or things that are particularly important to consider?

Quoted 9 lines
Quoted 6 lines

3) A user and group instantiated mask forms an *operational set of functionality*.

What is important here is to recognize that a given executable
may have
different apparent functionality based on who is running it.

I think not in our particular niche. We do process oriented security, and that is all for now. Later we can make it more complex.

We can't avoid it at some level without re-writing Linux security. Take a moment to consider the set-UID bit on a file which is an executable and I think you will see what I am driving at.

That said, all we need to do is make our specification conform to the smallest code change for the time being, e.g., the identity mask---what was happening before is what you get.

NB. I understand that the overriding goal of the first 3 months is devising and demonstrating that we have a strategy that scales to file systems containing millions of files---but I don't think we can lose any semantics as fundamental as user/group permissions without inviting criticism.

Quoted 12 lines
Quoted 8 lines

Well, for the moment only more questions:

Suppose we have a file system and a mask. If we were to create a chroot by copying just the file system

semantic tree (not files, just filenames)

Quoted 7 lines
Quoted 4 lines

accessible through the mask and run the application in that environment would the semantics of running the application on the original file system with the mask by equivalent. By equivalent I mean no observable difference in the instructions executed at the user level or the output generated.

No, because new files might be made visible through the mask without the new file creator even being aware that there was a mask.

I don't think my question was very clear ...

For any process, could that process determine if it was running

* on a reiser4 file system that is really the root
* on a reiser4 file system with a mask, or
* on a reiser4 file system with chroot

/exclusively/ by making calls to the reiser4 file system?

Quoted 4 lines
Quoted 3 lines

Does the question make sense?

Uh no... :-[

#5 lore raw
Quoted 8 lines · George Beshers
Quoted 8 lines
Quoted 6 lines

3) A user and group instantiated mask forms an *operational set of functionality*.

What is important here is to recognize that a given executable
may have
different apparent functionality based on who is running it.

Quoted 4 lines
Quoted 1 line

I think not in our particular niche. We do process oriented security, and that is all for now. Later we can make it more complex.

We can't avoid it at some level without re-writing Linux security. Take a moment to consider the set-UID bit on a file which is an executable and I think you will see what I am driving at.

I don't see what you are saying. Our mask does process oriented security. The underlying security remains a user/object/permission mapping.

Quoted 3 lines

That said, all we need to do is make our specification conform to the smallest code change for the time being, e.g., the identity mask---what was happening before is what you get.

Well, we should just pass things through the mask to whatever is below.

Quoted 5 lines

NB. I understand that the overriding goal of the first 3 months is devising and demonstrating that we have a strategy that scales to file systems containing millions of files---but I don't think we can lose any semantics as fundamental as user/group permissions without inviting criticism.

We are not losing, we are residing above and masking them.

Quoted 20 lines
Quoted 20 lines
Quoted 10 lines

Well, for the moment only more questions:

Suppose we have a file system and a mask. If we were to create a chroot by copying just the file system

semantic tree (not files, just filenames)

Quoted 4 lines

accessible through the mask and run the application in that environment would the semantics of running the application on the original file system with the mask by equivalent. By equivalent I mean no observable difference in the instructions executed at the user level or the output generated.

Quoted 8 lines
Quoted 1 line

No, because new files might be made visible through the mask without the new file creator even being aware that there was a mask.

I don't think my question was very clear ...

For any process, could that process determine if it was running

* on a reiser4 file system that is really the root

the root filesystem?

Quoted 7 lines

*

* on a reiser4 file system with a mask, or
* on a reiser4 file system with chroot

/exclusively/ by making calls to the reiser4 file system?

Hmm, sounds like the answer requires carefully traversing the code.;-)

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

Does the question make sense?

Uh no... :-[

#6 lore raw
Quoted 8 lines · Hans Reiser
Quoted 2 lines · George Beshers

We can't avoid it at some level without re-writing Linux security. Take a moment to consider the set-UID bit on a file which is an executable and I think you will see what I am driving at.

I don't see what you are saying. Our mask does process oriented security. The underlying security remains a user/object/permission mapping.

The issue is how the mask might change the semantics of sys_execve(). I have spent some time starting to trace code around, but more work is required.

For the moment I think we are safe if the setuid and setgroup can not be altered by the mask.

We only change the semantics if the real/effective uid or gid is different at some point in the processes execution because of the mask---begging situations where a call to setuid happens only if a certain file is not available.

I want to get back to understanding your second proposed strategy.

Quoted 1 line
#12 lore raw
In reply to a message not in the archive
Quoted 29 lines · George Beshers
Quoted 5 lines · Hans Reiser
Quoted 5 lines
Quoted 3 lines

No, because new files might be made visible through the mask without the new file creator even being aware that there was a mask.

Quoted 7 lines
Quoted 6 lines

I don't think my question was very clear ...

For any process, could that process determine if it was running

* on a reiser4 file system that is really the root

the root filesystem?

Yes, as understood by the OS.

Quoted 10 lines
Quoted 8 lines

*

* on a reiser4 file system with a mask, or
* on a reiser4 file system with chroot

/exclusively/ by making calls to the reiser4 file system?

Quoted 6 lines
Quoted 1 line

Hmm, sounds like the answer requires carefully traversing the code.;-)

of course :-)

But what would we like the answer to be?

Ah, so that is the question....

Quoted 11 lines

I will take the position that "no the process can not tell" as being useful
because it makes running with a mask a better test environment. Also, I don't see how cluing the process in that a mask is in place can
improve security whereas knowing that the mask is in place might encourage someone to try to work around it (beyond the filesystem semantics).

Yes, you are right I think, but you should ask on the mailing list what information about what is the root filesystem is used for by the OS

#7 lore raw
In reply to George Beshers
Quoted 11 lines · George Beshers
Quoted 7 lines · Hans Reiser
Quoted 2 lines · George Beshers

We can't avoid it at some level without re-writing Linux security. Take a moment to consider the set-UID bit on a file which is an executable and I think you will see what I am driving at.

Quoted 6 lines
Quoted 2 lines

I don't see what you are saying. Our mask does process oriented security. The underlying security remains a user/object/permission mapping.

The issue is how the mask might change the semantics of sys_execve(). I have spent some time starting to trace code around, but more work is required.

For the moment I think we are safe if the setuid and setgroup can not be altered by the mask.

Ok.

Quoted 4 lines

We only change the semantics if the real/effective uid or gid is different at some point in the processes execution because of the mask---begging situations where a call to setuid happens only if a certain file is not available.

Say more.

Quoted 8 lines

I want to get back to understanding your second proposed strategy.

Quoted 1 line
#8 lore raw

First, rereading my e-mails I realize that there was some thinking behind my questions which was only partially articulated. Going back to my earlier position which I will restate here as:

/Use of a mask should never corrupt the semantics defined by the Single Unix
Specification /*or*/ its practical derivations and extensions, e.g., BSD and Linux./

That is,/ ideally/ if I created a standalone system that "looked" like the system the mask provides then the process would behave equivalently. I emphasize ideally because to actually make that the case would require something closer to a virtual machine---which is clearly beyond the scope of this project.

So I am looking for potential semantic anomalies which could be introduced by a mask over a reiser4 file system, i.e., border cases where some upfront awareness and attention may save re-design and re-writing later on.

Quoted 8 lines · Hans Reiser
Quoted 5 lines

The issue is how the mask might change the semantics of sys_execve(). I have spent some time starting to trace code around, but more work is required.

For the moment I think we are safe if the setuid and setgroup can not be altered by the mask.

Ok.

For the moment I will focus on how the uid (and assume the group id will be similar) of a process and how the mask might lead to a different uid than would be expected under standard semantics.

So we agree that the process has an associated user: actually there is the concept of real and effective uid also.

I believe the statement above to be true if the process never makes a setuid() system's call of one flavor or another because the uid is inherited from the process calling execev() or is determined by the owner of the executable if the executable's file set-uid permission bit is turned on via chmod.

Quoted 7 lines
Quoted 4 lines

We only change the semantics if the real/effective uid or gid is different at some point in the processes execution because of the mask---begging situations where a call to setuid happens only if a certain file is not available.

Say more.

If the process has the code like

   if (stat("/etc/foobar.conf", statbuf)  < 0) {
        if (setuid(3) < 0) {   /* Try to become sys */
       }
       /* Do something here */
   }

And the mask hides "/etc/foobar.conf" then in fact the uid will change but *not unexpectedly*, IMO. The mask is creating a changed environment but the behavior is understandable from the source code.

Put this another way, the semantics still seem correct to me because you are getting the behavior of "/etc/foobar.conf" actually not being there.

Now that I think about it masking a named pipe or a lock file is perhaps more likely to cause problems then the setuid bit. More cogitation required... :-)

#9 lore raw
Quoted 10 lines · George Beshers

First, rereading my e-mails I realize that there was some thinking behind my questions which was only partially articulated. Going back to my earlier position which I will restate here as:

/Use of a mask should never corrupt the semantics defined by the Single Unix
Specification /*or*/ its practical derivations and extensions, e.g., BSD and Linux./

I expect to turn those semantics on their head within 3-5 years when we do the semantic enhancements.

I think you should rephrase it as: we should not break any existing program without getting something sufficiently worthwhile as a result, and doing it with care.

Quoted 19 lines

That is,/ ideally/ if I created a standalone system that "looked" like the system the mask provides then the process would behave equivalently. I emphasize ideally because to actually make that the case would require something closer to a virtual machine---which is clearly beyond the scope of this project.

So I am looking for potential semantic anomalies which could be introduced by a mask over a reiser4 file system, i.e., border cases where some upfront awareness and attention may save re-design and re-writing later on.

Quoted 7 lines · Hans Reiser
Quoted 5 lines

The issue is how the mask might change the semantics of sys_execve(). I have spent some time starting to trace code around, but more work is required.

For the moment I think we are safe if the setuid and setgroup can not be altered by the mask.

Quoted 6 lines
Quoted 1 line

Ok.

For the moment I will focus on how the uid (and assume the group id will be similar) of a process and how the mask might lead to a different uid than would be expected under standard semantics.

I don't think you need to support the mask changing uids. Nice feature, but let's keep it minimal for now. I think the whole issue of uid can be sidestepped and ignored. You can, however, put 3 paragraphs in our report discussing it as a theoretical issue, if you find it interesting to ponder.

Quoted 29 lines

So we agree that the process has an associated user: actually there is the concept of real and effective uid also.

I believe the statement above to be true if the process never makes a setuid() system's call of one flavor or another because the uid is inherited from the process calling execev() or is determined by the owner of the executable if the executable's file set-uid permission bit is turned on via chmod.

Quoted 7 lines
Quoted 4 lines

We only change the semantics if the real/effective uid or gid is different at some point in the processes execution because of the mask---begging situations where a call to setuid happens only if a certain file is not available.

Say more.

If the process has the code like

    if (stat("/etc/foobar.conf", statbuf)  < 0) {
         if (setuid(3) < 0) {   /* Try to become sys */
        }
        /* Do something here */
    }

And the mask hides "/etc/foobar.conf" then in fact the uid will change but *not unexpectedly*, IMO. The mask is creating a changed environment but the behavior is understandable from the source code.

Quoted 8 lines

Put this another way, the semantics still seem correct to me because you are getting the behavior of "/etc/foobar.conf" actually not being there.

Now that I think about it masking a named pipe or a lock file is perhaps more likely to cause problems then the setuid bit. More cogitation required... :-)

It is not our task to ensure the mask causes no problems due to a faulty specification of it. It is merely our task to ensure that creating a correct mask is well automated and easy.

George, trust me, the project will be a LOT more fun if we implement the bare minimum and get it done early, and then after that spend the rest of the time doing what amuses us.

For me, the big issue to decide at the start is, should a view specification be implemented with a format that is as if it is a subdirectory of the masked executable, and that the executable gets chrooted to, and that uses all the semantic tree traversal code already written by us.

I think the answer is yes, but I am going to think about it as I jog for an hour. Please come up with arguments for and against it.

Hans

#10 lore raw

Re: viewprinting: what format should views be stored in? (let me quickly correct an imprecision)

Let me instead of the previous email, say:

For me, the big issue to decide at the start is, should a view specification be implemented with a format that is as if it is a subdirectory of the masked executable, and which we then take the filenames used by the executable and traverse the subdirectory as though it was root, and if we reach a valid fall through point, then allow we traverse from the real filesystem root, and if not, we issue a suitable error.

This would let us use all the semantic tree traversal code already written by us.

It would however require us to add such plugins as "fall through points", and "prints", etc. If really lucky, you could have some working plugins in 4 months, and maybe have masking software done by the end of the contract.

I think the answer is yes, we want to do it this way, but I am going to think about it as I jog for an hour. Please come up with arguments for and against it.

Quoted 3 lines

Hans