Page 3 of 10

Re: Os and implementing good gpu drivers(nvidia)

Posted: Mon Nov 02, 2015 6:02 pm
by Rusky
There's an enormous difference between proving code and its translation is bug-free (impossible) and proving that it's memory-safe (quite possible and already done in many languages and implementations).

Re: Os and implementing good gpu drivers(nvidia)

Posted: Mon Nov 02, 2015 6:23 pm
by Brendan
Hi,
AlexHully wrote:SASOS is also able to reduce management cost.
You say SASOS reduces management costs but don't say why. I say you owe me a million dollars and I won't say why. Because you didn't provide an explanation I have no choice but to assume you were unable to provide a reason, and therefore must be wrong about SASOS management costs. Because I didn't provide an explanation you might want to assume I'm wrong about that million dollars.
AlexHully wrote:You say that a system can consume electricity, and that it is not a concern. It is. No matter how fast it is done.
I don't remember saying these things. If you think electricity consumption is a concern but performance isn't; then I can teach you how to build a computer from hydraulics that doesn't use or consume electricity at all (but will consume energy, and will be very slow).
AlexHully wrote:And context switches are among those things (stack, permission management) that cost cpu cycles and add up. No matter how fast they are.
The problem isn't task switch speed (which is the same regardless of how many TLB misses occur after the task switch). The problem is switching from one process' working set to another process' working set; where all caches (including TLB) are full of data for the previous process and contain nothing useful for the new process. SASOS doesn't help in almost all cases (excluding artificial "ping ping" micro-benchmarks, and silly micro-kernels that use synchronous messaging and need multiple tasks switches that can't be avoided/postponed any time anything trivial needs to be done). What does help is doing task switches less often (intelligent scheduling algorithms and asynchronous communication).
AlexHully wrote:I propose to post a benchmark sasos and the normal way in real conditions. If proven wrong, i would have wasted a few days. Otherwise.. Actually, the only thing I can do is timing during an hour in the exact same conditions and use performance monitor to make an overall -and possibly flacky- decision.
You'd be running existing software without "compiler guaranteed safety" which will make your SASOS plans seem better than they would be in practice. Also; I very much doubt that the kernel or the user-space software will be optimal for SASOS (e.g. where things like shared memory and IPC can be done in much more efficient ways) which will make your SASOS plans seem worse than they would be in practice.
AlexHully wrote:But still. It will not take ten years to create. Single address space is just a few days of work (when you specialize your context).
Let me guess. You're going to spend 2 days modifying Linux for SASOS, then 10 days implementing the compiler required to "guarantee" safety and competitive performance, and by the end of November you'll have the GUI, web browser, office apps, 3D games, etc all ported to and/or rewritten in your new language. Then you'll spend the first half of December doing beta testing; and the entire OS will be completed and entirely usable in time for the end of year holiday period?


Cheers,

Brendan

Re: Os and implementing good gpu drivers(nvidia)

Posted: Mon Nov 02, 2015 6:41 pm
by Brendan
Hi,
AlexHully wrote:What is the difference between a tagged tlb after a context switch in a "normal" system and a sasos?

When there is a miss, you end up doing the exact same thing possibly at the exact same rate. Same thing for a hit.
But you don't change the stacks don't make permission checks.
For a normal OS, tagged TLB allows you to invalidate an entire virtual address space cheaply, without invalidating all virtual address spaces. This means that (when you know a process can't be running on another CPU) you can skip the multi-TLB shootdown and invalidate the process' virtual address space on the other CPU if/when the other CPU actually does switch to that process.

For SASOS tagged TLB is useless because everything is in one address space and would all have the same tag; and so you can't invalidate part of that "everything combined" address space cheaply. For SASOS you can't avoid multi-CPU TLB shootdown because (once you consider things like shared memory, speculative execution, hardware prefetching, etc) there's no practical alternative.


Cheers,

Brendan

Re: Os and implementing good gpu drivers(nvidia)

Posted: Mon Nov 02, 2015 7:06 pm
by Brendan
Hi,
embryo2 wrote:
Brendan wrote:If you can (e.g.) inject malicious code into the native executable that was created during installation...
And what is the difference between managed and unmanaged OS in case of malicious code injected in some sensitive area? Are you trying to tell us that there's nothing absolutely secure? Yes, there's nothing. But it's senseless to discuss issues like "A-bomb can melt any armor". It's better to discuss why a particular thing is better. Are "unmanaged" OSes protected from code injection? No. So, why you are using such argument against "managed" OS? I miss your point here.
For a normal (unmanaged) OS malicious code can be injected into trusted pieces (e.g. the kernel itself). This is why everyone is moving towards things like Secure Boot (so that hardware and/or firmware can guarantee that those trusted pieces have not been tampered with).
Rusky wrote:
Brendan wrote:Haven't we been through this before? A "managed environment" is an environment where software is relied on to provide protection/isolation at run-time. A "managed language" is something designed for a managed environment (but that's entirely irrelevant because nothing prevents code written in a managed language from being executed in an unmanaged environment, and nothing prevents code written in an unmanaged language from being executed in an managed environment).
Then I guess we're not talking about a managed environment or language. Call it something else if it makes you happy. The point is that you could enforce a particular verifiable program representation that is at least as fast (more, once you start doing optimizations like inlining between applications and the kernel) and just as secure as a hardware-protected system running unverified code.
I was only using this to explain the difference between "managed environment" and "unmanaged environment". The obvious solution to prevent this is cryptography (e.g. auto-create a digital signature or secure hash when the compiler generates the "safe" native code).

Optimizations like inlining kernel code into applications in SASOS sounds as plausible as inlining functions from dynamically linked libraries during process start-up in traditional OSs.


Cheers,

Brendan

Re: Os and implementing good gpu drivers(nvidia)

Posted: Mon Nov 02, 2015 7:19 pm
by Brendan
Hi,
Rusky wrote:There's an enormous difference between proving code and its translation is bug-free (impossible) and proving that it's memory-safe (quite possible and already done in many languages and implementations).
You can't do the latter without also doing the former; unless you insert run-time checks.

For a trivial example consider:

Code: Select all

int foo(int bar) {
    return lookup_table[bar];
}
To guarantee this is safe at compile time (without run-time checks) you have to ensure that all callers pass a value for bar that is acceptable and that the translation of all callers' code was correct.

The only other option is to remove support for arrays; but there's similar problems for linked lists, and tries, and recursion, and... By the time you've nerfed the language to oblivion it'll be impossible to use it for any practical purpose.


Cheers,

Brendan

Re: Os and implementing good gpu drivers(nvidia)

Posted: Mon Nov 02, 2015 8:46 pm
by Rusky
The only thing you have to prove about the compiler's output is that it doesn't access memory it doesn't own. That is a significantly smaller and more tractable problem than proving program correctness. You don't have to unconditionally insert runtime checks or do whole-program analysis or nerf the language to do that, though it helps if the source program includes some annotations for ownership or number ranges.

Re: Os and implementing good gpu drivers(nvidia)

Posted: Mon Nov 02, 2015 9:16 pm
by Brendan
Hi,
Rusky wrote:The only thing you have to prove about the compiler's output is that it doesn't access memory it doesn't own. That is a significantly smaller and more tractable problem than proving program correctness. You don't have to unconditionally insert runtime checks or do whole-program analysis or nerf the language to do that, though it helps if the source program includes some annotations for ownership or number ranges.
For "myArray" you have to prove that i is correct, and to do that you have to prove that everything that directly influenced i is correct, and to do that you have to prove that everything that indirectly influenced i is correct.

You can't forget about the correctness of the addition operator and hope nobody does "myArray[1+2]". You can't forget about the correctness of multiplication and hope nobody does "myArray[1*2]". You can't forget about the correctness of normal functions and hope nobody does "myArray[ fn(x) ];". There isn't a single part of the entire language (operators, statements, etc) that you don't have to care about because as soon as you screw up any rare corner case someone is going to take advantage of your flaw and pawn the entire OS.

Note that annotations for ownership or number ranges are completely useless for security because a programmer who is intentionally writing malicious source code will not use them "safely".


Cheers,

Brendan

Re: Os and implementing good gpu drivers(nvidia)

Posted: Mon Nov 02, 2015 10:02 pm
by Rusky
Brendan wrote:For "myArray" you have to prove that i is correct, and to do that you have to prove that everything that directly influenced i is correct, and to do that you have to prove that everything that indirectly influenced i is correct.
Right, you have to prove that the compiler's output corresponds to the input that it verified. But even this is not impossible, especially if you do the verification on a simplified bytecode rather than a whole human-centric programming language. A translation at that scale can be (and has been) mathematically proven correct.
Brendan wrote:Note that annotations for ownership or number ranges are completely useless for security because a programmer who is intentionally writing malicious source code will not use them "safely".
Not a problem if the install-time compiler enforces them.

But yes, everything does come down to trusting something. In a typical system from today, that's the hardware and the kernel and the drivers. The idea behind software-based protection is to either reduce the amount of necessary trust, or to provide an alternative failsafe for another layer of protection.

Re: Os and implementing good gpu drivers(nvidia)

Posted: Tue Nov 03, 2015 3:53 am
by AlexHully
Brendan wrote: You must assume that the compiler is unable to guarantee that the code it compiled is safe.
Are you talking about existing compilers? Why limit the scope to it?

We managed to "steal" a lot from the llvm project as far as optimizations are concerned, and implement our logic.
if the code is not safe, then it is rejected. Simple as that.
We still have to polish everything, that is right. It is a never ending project. That is right.

BUT
Brendan wrote:The difference between you and me is that I've spent time researching what is/isn't possible and I know that getting a rating of 100 on that scale is impossible, and you probably haven't even started thinking about how you're going to achieve it
I guess you make too many assumptions and you are too pretentious here. Many people are smart enough to think as well as you do. I hate to talk about it (and never did anywhere else), but as your tone is despising: I have a "pretty" high IQ myself, even if not as experienced as you are because I fell in computer science quite late. But, I have a need and a plan for it.

Checklist:
1) Does it serve a purpose? Yes.
2) Does it have to happen quickly? Yes.
3) Can you use it for further research, based on practical experience? Yes.
4) Does it involve more work than just installing.. say Debian? Obviously.
5) Will it fit M. X and Mrs Y who want to run it everywhere? Not quite. Why? Security of third parties cannot be assured.
6) Do you expect it to fit some embedded projects? Yes.
7) Will it please people who love the pure elegance of creating something new which will have hard time to ring the bell to the industry because so much money is already involved in recycling as much as possible the hardware? No.
8 ) Will you face major insults? Yes.
9) Do you expect it to be used everywhere? No. At first in our ecosystem. The time will tell.
10) Are you proud? No. We just manage to seriously modify existing code and add our own. Not exactly as pretty as starting from scratch.
11) Where are you now on this project? it boots but crashes because we have to implement the new system space (imagine a huge gap in the code -> obviously crash)
12) Did you recode scheduler, compiler, linker, loaders? scheduler; compiler is cowardly stealed from llvm and adapted to our needs (WIP); and linker just needs a little code change to understand the boundaries of the program (WIP).

13) Wouldn't you prefer to take time with your friends and party? No.

Please don't get me wrong. Making it work in so little time is already a challenge in itself.

Re: Os and implementing good gpu drivers(nvidia)

Posted: Tue Nov 03, 2015 5:39 am
by Brendan
Hi,
AlexHully wrote:
Brendan wrote: You must assume that the compiler is unable to guarantee that the code it compiled is safe.
Are you talking about existing compilers? Why limit the scope to it?
No I'm not talking about existing compilers. I'm talking about overall code quality. The industry average varies (depending on things like how much effort is spent on unit testing, etc) but is around 10 to 50 errors per 1000 lines of code. In a normal application this isn't really good, but there's almost always "something" to shield the OS from bugs in a normal application. For things like kernels, and for your compiler, nothing shields the OS from these bugs.

A compiler like GCC is about 7 million lines of code. If you add "safety guarantees" (all the complexity of things I've mentioned previously, like tracking ranges and precision in every single variable; plus things I haven't mentioned yet, like detecting race conditions in multi-threaded code) you might end up with around 8 million lines of code (including LLVM if that's what you're using as a back-end - not necessarily 8 million lines of code that you've written yourself). 8 million lines of code with an average of 10 to 50 errors per 1000 lines of code implies that there will be between 80000 and 400000 errors in the compiler.

Your entire OS's security will depend on this compiler. Your entire OS's security will depend on something that's expected to have between 80000 and 400000 errors.

If this doesn't scare you, it should.


Cheers,

Brendan

Re: Os and implementing good gpu drivers(nvidia)

Posted: Tue Nov 03, 2015 8:21 am
by AlexHully
Ok,

At this point, the discussion is going nowhere.

I propose something: I will not argue anymore because it takes me a lot of time; instead, I'll keep working.
We will have practical facts to discuss and compare then. Because right now, it is just -interesting but useless- hand wavings.

When you will see my post again with a DL link, you know I will be ready for an argumentation war.

:)

Re: Os and implementing good gpu drivers(nvidia)

Posted: Tue Nov 03, 2015 9:25 am
by embryo2
Brendan wrote:That brings me to unsolvable problems. What does the compiler do if it can't possibly determine if a piece of code is safe or not?

The only thing it can do is "false negatives".
Wrong. It can inject safety checks (as you already know, but refuse to consider this option).

The whole thing of your argumentation is revolved around the great deal of complexity. But if a compiler doesn't know an actual value then it just injects some checks. So, until the compiler knows the value, it can be as efficient as any unmanaged compiler. And when compiler doesn't know the value, it still produces safe code, but with some speed penalty. As you can see there's just no place for complexity. A developer can think about next problem as long as it takes and compiler still produces fast and safe code. After a developer found solution for the current problem, the compiler is extended and now can produce even faster code. No stop at the way to the greatest quality. And all your talks about complexity now are just obsolete.

Re: Os and implementing good gpu drivers(nvidia)

Posted: Tue Nov 03, 2015 9:27 am
by embryo2
Brendan wrote:Your entire OS's security will depend on this compiler. Your entire OS's security will depend on something that's expected to have between 80000 and 400000 errors.
It is common problem for all software, would it be managed or not. So, let's forget about this common thing while talking about managed vs unmanaged.

Re: Os and implementing good gpu drivers(nvidia)

Posted: Tue Nov 03, 2015 9:35 am
by embryo2
Ready4Dis wrote:The point was, that using a managed compiler doesn't really offer security to the operating system if every single process has access to every other processes (and kernels) memory. It just means someone can write a program in an unmanaged language and compromise you kernel, where if you separated things out into their own memory address spaces, they are more secure.
The same is true for both worlds - managed and unmanaged. Because unmanaged OS has to have privileged code and this code can be compromised. But to compromise the code with safety checks injected, most probably you need to inject your code right into the privileged part of the managed OS (in it's compiler). And while there's no difference between kernel compromising problem for managed and unmanaged we safely can assume this argument has nothing against managed OS in discussion about managed vs unmanaged.

Re: Os and implementing good gpu drivers(nvidia)

Posted: Tue Nov 03, 2015 11:32 am
by Ready4Dis
embryo2 wrote:
Ready4Dis wrote:The point was, that using a managed compiler doesn't really offer security to the operating system if every single process has access to every other processes (and kernels) memory. It just means someone can write a program in an unmanaged language and compromise you kernel, where if you separated things out into their own memory address spaces, they are more secure.
The same is true for both worlds - managed and unmanaged. Because unmanaged OS has to have privileged code and this code can be compromised. But to compromise the code with safety checks injected, most probably you need to inject your code right into the privileged part of the managed OS (in it's compiler). And while there's no difference between kernel compromising problem for managed and unmanaged we safely can assume this argument has nothing against managed OS in discussion about managed vs unmanaged.
No, it's two different things... in the imaginary unmanaged OS, the kernel runs in kernel space, and the user app runs in user space. If I run a .exe file (or .com or elf, whatever) I assume it's out to get me and make sure that it can't access things that it shouldn't (like other processes memory).
In a managed OS, you need to be sure that the .exe/.com/elf or whatever was compiled with your 'safe' compiler, if it wasn't, then there are absolutely no guaranties that it won't do something and there is nothing stopping it from taking over the entire PC. So, you need another layer in the managed OS in order to confirm each program. You also need to verify that there is no way it can generate code on the fly (in ram) and then execute it, thereby bypassing the security of the compiler (or ensure that code/data segments are separated, code segments can't be written, and data segments can't be executed).

Again, I am not saying it's impossible, just improbable to make something secure and fast at the same time, as those two are normally mutually exclusive. The two questions for most people is, "How much security am I willing to sacrifice for speed" and "How much speed am I willing to sacrifice for security".
If you put array bounds checking around each array access that uses a variable that can't be determined at run time, then any complex program is going to end up with a lot of run time checks. I'm not saying it's good or bad, I'm saying it is what it is for your goals. I am more interested in OS dev than compiler design, if I wanted to design a compiler I could/would prove my compiler design before putting it into my own OS.