Limitations of code quality to ensure safety of modern software
elana.copperman@...
Hi Pete, See http://www.underhanded-c.org/_page_id_2.html I don't know if this contest is still being supported. But as you can see, it highlights the limitations of C as a programming language. So that ensuring "quality" of any C-based safety critical system is not easy, even before we get to the limitations of Linux and open source. Unfortunately throughout my career I have seen plenty of code examples which, although not malicious in the sense of this contest, comply with accepted development/coding/test processes – but are inherently unsafe, sometimes by design. Regards Elana |
||
|
||
Brink, Peter
Hi Elana,
Not sure why you directed this to me. I have always advocated for product and process quality, of which code quality is just one aspect. The safety of a product, as you say at the end might be compromised by the design, which is why I have been advocating for the quality and safety aspects mentioned above.
Pete
From: Elana Copperman <Elana.Copperman@...>
Sent: Tuesday, June 21, 2022 1:02 AM To: Brink, Peter <Peter.Brink@...>; devel@... Subject: Limitations of code quality to ensure safety of modern software
Hi Pete, See http://www.underhanded-c.org/_page_id_2.html I don't know if this contest is still being supported. But as you can see, it highlights the limitations of C as a programming language. So that ensuring "quality" of any C-based safety critical system is not easy, even before we get to the limitations of Linux and open source. Unfortunately throughout my career I have seen plenty of code examples which, although not malicious in the sense of this contest, comply with accepted development/coding/test processes – but are inherently unsafe, sometimes by design. Regards Elana
|
||
|
||
Aggrwal, Poonam
[AMD Official Use Only - General]
Hi,
I jumped in because I found the topic interesting.
The shortcomings of C in comparison to other type safe languages like Java and Rust are being highlighted in security context too.
Although, I am not sure that today’s automobiles’ SW stacks (AutoSAR, Adaptive AutoSAR) use them. They would be pretty much written in C.
Regards Poonam From: devel@... <devel@...>
On Behalf Of Brink, Peter via lists.elisa.tech
Sent: Tuesday, June 21, 2022 7:30 PM To: Elana Copperman <Elana.Copperman@...>; devel@... Subject: Re: [ELISA Technical Community] Limitations of code quality to ensure safety of modern software
Hi Elana,
Not sure why you directed this to me. I have always advocated for product and process quality, of which code quality is just one aspect. The safety of a product, as you say at the end might be compromised by the design, which is why I have been advocating for the quality and safety aspects mentioned above.
Pete
From: Elana Copperman <Elana.Copperman@...>
Hi Pete, See http://www.underhanded-c.org/_page_id_2.html I don't know if this contest is still being supported. But as you can see, it highlights the limitations of C as a programming language. So that ensuring "quality" of any C-based safety critical system is not easy, even before we get to the limitations of Linux and open source. Unfortunately throughout my career I have seen plenty of code examples which, although not malicious in the sense of this contest, comply with accepted development/coding/test processes – but are inherently unsafe, sometimes by design. Regards Elana
|
||
|
||
elana.copperman@...
Indeed. But the point here is much more subtle: For the code submitted to this contest, I would assume that all of the aspects related to product and process quality, including design, are well covered and would be qualified by any safety standard. But the final result is not safe. The inherent features of C (and, to a lesser extent, C++) enable the clever developer to write qualified unsafe code. And although the contest focuses on security issues (which as noted by Poonam is more highlighted), similar tricks can be implemented to evade safety as well as functional features. The type of testing which would block such code is on a different level altogether.
Bottom line, documented architecture and design; requirements; and classic testing (primarily static); and other aspects dominating safety standards and legacy processes, are not necessarily appropriate mechanisms for ensuring quality and safety of modern software systems, primarily if written in a language such as C.
From: Aggrwal, Poonam <Poonam.Aggrwal@...>
Sent: Tuesday, June 21, 2022 5:51 PM To: Peter.Brink@...; Elana Copperman <Elana.Copperman@...>; devel@... Subject: RE: [ELISA Technical Community] Limitations of code quality to ensure safety of modern software
[AMD Official Use Only - General]
Hi,
I jumped in because I found the topic interesting.
The shortcomings of C in comparison to other type safe languages like Java and Rust are being highlighted in security context too.
Although, I am not sure that today’s automobiles’ SW stacks (AutoSAR, Adaptive AutoSAR) use them. They would be pretty much written in C.
Regards Poonam From:
devel@... <devel@...>
On Behalf Of Brink, Peter via lists.elisa.tech
Hi Elana,
Not sure why you directed this to me. I have always advocated for product and process quality, of which code quality is just one aspect. The safety of a product, as you say at the end might be compromised by the design, which is why I have been advocating for the quality and safety aspects mentioned above.
Pete
From: Elana Copperman <Elana.Copperman@...>
Hi Pete, See http://www.underhanded-c.org/_page_id_2.html I don't know if this contest is still being supported. But as you can see, it highlights the limitations of C as a programming language. So that ensuring "quality" of any C-based safety critical system is not easy, even before we get to the limitations of Linux and open source. Unfortunately throughout my career I have seen plenty of code examples which, although not malicious in the sense of this contest, comply with accepted development/coding/test processes – but are inherently unsafe, sometimes by design. Regards Elana
|
||
|
||
elana.copperman@...
Thanks very much for your comments, agreed – the value of type safe languages such as Rust is well known. But this relates to only one facet of the issues at hand. We need to deal with the current commonly accepted state of software development:
What can be done? Some suggestions (feel free to pitch in here with some more!!):
For safety, we need a similar change in mindset and frameworks for dynamic analysis of a complete system for compliance with safety goals defined for that system. We should continue to focus on the development process (requirements definition; architecture documentation; static analysis; configuration management) in an effective and realistic way, leveraging modern development, build and test tools, without pushing to the extreme of simplistic "waterfall" development processes. And at the same time, build in to our CI systems strong utilities for dynamic configuration management and testing. Elana
From: dmg <dmg@...>
Sent: Thursday, June 23, 2022 12:16 AM To: Elana Copperman <Elana.Copperman@...> Cc: Aggrwal, Poonam <Poonam.Aggrwal@...>; Peter.Brink@...; devel@... Subject: Re: [ELISA Technical Community] Limitations of code quality to ensure safety of modern software
From a theoretical perspective, it is infeasible to build a program that verifies whether a program is bug free. Even if we define "bug-free" as whether the program finishes or ends in a infinite loop.
Thus, computer scientists have worried about the properties of a program that can be verified. In a way, this is the role of the specification of the language and the compiler on enforcing it (and in some cases the run time library).
One of the simplest verifications that can be done in a program is whether there is a type inconsistency: when a value is calculated, the result is placed in a variable that is consistent with the result. (eg a float is not stored in an integer). This is probably the biggest advantage of type-safe programming languages (such as Rust).
The biggest problem is that a checking system has to balance two aspects: completeness and consistency. You can't cover both perfectly. In simple terms, a checking system wants to be consistent (avoid errors) even if it forbids some programs that are correct (the construct is ok, but it looks "unsafe" to the compiler/checker).
C was built in a time where little of this was understood. Rust, on the other hand, implements this theory regarding type safety.
But being type-safe does not guarantee full safety.
In summary:
1. Perfect verification of most interesting properties of a program is theoretically impossible.
2. rust and other modern languages like Scala aim for type safety, which is better than nothing. C does not have type safety.
3. Perfect verification of most interesting properties cannot be achieved (Gödel's Incompleteness Theorems). This means the languages/run-time libraries place restrictions on the programmers (that languages like C do not). There will always be a tradeoff of the benefits of using Rust vs C.
4. The economics of software development are against the programmer. Writing safe code requires more thinking/training from the programmer, slowing her/his down. If I am being evaluated on whether I finish a piece of code or finish 1/2 of a safer piece of code, which one do you think I will choose? Incomplete code is more "unsafe" than "unsafe" finished code (every time I run unfinished code, it crashes :)
I believe that in time, most projects will start using Rust instead of C. But this will take time, as most programmers do not learn the basics that are necessary to understand the Functional Programming foundations of Rust. Also, it will take time for C and C++ libraries to be ported to Rust.
If I remember correctly, Linus discussed (with others) the potential of moving to C++. But his response was (I paraphrase): C is a simpler language, easier to read and to write that C++. I think he also mentioned that more people knew C and C++.
On Tue, Jun 21, 2022 at 8:46 AM elana.copperman via lists.elisa.tech <elana.copperman=mobileye.com@...> wrote:
-- --dmg |
||
|