News for hackers. Stuff that matters.
Re:Rethinking the filesystem as global mutable state, the ro... by mnw21cam on Tuesday June 11, 2019 @09:15AM (#20155080)
As anyone who has put together a chroot knows, it isn't as simple as just preventing a process from accessing the filesystem. Most programs need to access a filesystem, just so they can load libc and the various other libraries it might need.
Re:Rethinking the filesystem as global mutable state, the ro... by AstralStorm on Tuesday June 11, 2019 @10:30AM (#20155718)
Do they now? Usually, the linker does all the loading, also known in Linux as ld.so. (even when you use dlopen)

Lazy loading can thunk through kernel so that ld.so service loads things into the process - and preferably strict loading should be used.

Re:Rethinking the filesystem as global mutable state, the ro... by mnw21cam on Tuesday June 11, 2019 @10:32AM (#20155737)
Indeed. But ld.so runs in the context of the process that is starting up, so if it doesn't have access to anything, it can't.
Re:Rethinking the filesystem as global mutable state, the ro... by AstralStorm on Tuesday June 11, 2019 @10:34AM (#20155763)
It doesn't actually have to, but you'd need a fun bit of stub code in place of unloaded function pointers etc.
Re:Rethinking the filesystem as global mutable state, the ro... by pjc50 on Tuesday June 11, 2019 @10:37AM (#20155797)
Not a useful distinction, since it needs to be visible inside the chroot either way. Not only that but libc via getpwnam() and friends needs to access PAM and thence all the libpam modules.
Re:Rethinking the filesystem as global mutable state, the ro... by mnw21cam on Tuesday June 11, 2019 @10:47AM (#20155894)
That also depends. I have a chroot set up here to run sftp-server for incoming ssh connections, and it has 55 files in it, 40 of which appear to be libraries - none of them having anything to do with PAM.
Re:Rethinking the filesystem as global mutable state, the ro... by hlandau on Tuesday June 11, 2019 @01:07PM (#20157327)
Author here. This is the case with *nix but doesn't need to be.

As far as I'm aware, it's quite common in microkernel-based OSes to implement even ELF loading, dynamic linking, etc. inside system libraries loaded inside the process creating the new process. So the parent process basically constructs the child process, which means you could easily design an OS such that the parent needs access to the library files, but the child doesn't.

Re:Rethinking the filesystem as global mutable state, the ro... by nemaar on Tuesday June 11, 2019 @12:54PM (#20157199)
I think the idea that the program can load files as code is insane in itself. There shouldn't be such a mechanism in an ideal world. The operating system would decide what you can actually load and load it for you.
Re:Rethinking the filesystem as global mutable state, the ro... by anoncake on Tuesday June 11, 2019 @01:26PM (#20157508)
How would you prevent that? If programs can load files into memory and execute data loaded into memory as code, they can load files as code. The former is necessary for obvious reasons, the latter for JIT.

It's also pointless. If a program can cause damage by loading harmful code it can also cause damage directly.

Restricting what programs can do is a great way to prevent experimentation and hinder progress.

Re:Rethinking the filesystem as global mutable state, the ro... by la_barba on Tuesday June 11, 2019 @02:17PM (#20158044)
You can prevent that by using the NX or the XD bit. Its a CPU feature and I believe the support was added over 15 years ago in most popular OSs. Here's the commit for Linux https://git.kernel.org/pub/scm/linux/kernel/git/history/hist...

>It's also pointless. If a program can cause damage by loading harmful code it can also cause damage directly.

It is not pointless, but it is also not perfect. That's why we have defense in depth. Where instead of having one perfect moat to protect the castle, you also have alligators and witches that turn people into frogs. :P

Re:Rethinking the filesystem as global mutable state, the ro... by anoncake on Wednesday June 12, 2019 @05:48AM (#20163084)
The OS can prevent it, but can it do so without making JIT impossible?
Re:Rethinking the filesystem as global mutable state, the ro... by andrekandre on Wednesday June 12, 2019 @03:38PM (#20168459)
well, if you can’t make pages executable you can “just in time” it by interpreting and writing it to an optimized interpreter format i suppose (but it will be much slower)... as an example, see WKWebView vs UIWebView (from iOS)
Re:Rethinking the filesystem as global mutable state, the ro... by anoncake on Thursday June 13, 2019 @01:57AM (#20172174)
You can do that but slow JIT kind of misses the point.
Re:Rethinking the filesystem as global mutable state, the ro... by la_barba on Tuesday June 11, 2019 @02:08PM (#20157941)
>I think the idea that the program can load files as code is insane in itself. There shouldn't be such a mechanism in an ideal world.

What do you mean by loading files "as code". Do you mean setting the execute bit on memory pages? You need to have the appropriate permissions to do that, and a locked down system wide policy can prevent programs from doing that as well.