123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <!DOCTYPE html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><meta name="keywords" content="GNU, Emacs, Libre Software, Hurd, Guile, Guix" /><meta name="description" content="GNUcode.me is a website focusing on libre software projects, especially the GNU project." /><link type="application/atom+xml" rel="alternate" title="GNUcode.me -- Feed" href="/feed.xml" /><a rel="me" href="https://fosstodon.org/@thegnuguy"></a><link type="text/css" href="css/footer.min.css" rel="stylesheet"></link><link type="text/css" href="css/header.min.css" rel="stylesheet"></link><link type="text/css" href="css/main.min.css" rel="stylesheet"></link><title>OpenBSD's Philosophy — GNUcode.me</title></head><body><header><nav><ul><li><a href="index.html">GNUcode.me</a></li><li><a href="services.html">Services</a></li><li><a href="about.html">About</a></li><li><a href="business-ideas.html">Business-ideas</a></li></ul></nav></header><h1>OpenBSD's Philosophy</h1><main><section class="basic-section-padding"><article><h3>by Joshua Branson — April 17, 2024</h3><div><p>I have talked about OpenBSD before in this blog, and I recently
- watched a talk by OpenBSD's leader Theo de Raadt about <code>pledge ()</code> and
- <code>arc4random()</code>. He described OpenBSD's design philosophy so well, that
- I wanted to write it down. You should definitely take some time to
- hear Theo speak. He's entertaining, and his talks are super awesome!</p><p>So a long time ago (early 90s ?), a cracker (1) broke into Theo's
- OpenBSD's syslog. This got Theo to examine OpenBSD's source code to
- fix any lingering bugs, and he found a lot. He realized that trying
- to constantly examine source code to prevent bugs is a never ending
- process. He wanted to ensure code quality got better over time. He
- envision an operating system that that enforced code correctness like
- the below ASCII art shows.</p><pre><code>__________________________
- | Poorly written programs |
- | crash on OpenBSD. |
- | ---------------------- |
- | | Correctly written | |
- | | programs run well | |
- | | on OpenBSD. | |
- | ---------------------- |
- ---------------------------</code></pre><p>He wondered if he could create features to slightly narrow the things
- that applications could do. When poorly written programs run on
- OpenBSD, they crash in deterministic ways, but correct programs work
- just fine. Theo also made sure that "mitigations", or checks to ensure
- a program's correctness, <em>cannot</em> be turned off on OpenBSD. If a user
- or a project manager has a problem with an application not working on
- OpenBSD due to a toggleable security feature, then the user or project
- manager will just turn off the feature. So to ensure that programs
- abide by the mitigations, OpenBSD enforces their security policies.</p><p>OpenBSD also makes it easy to use their security features. If they
- introduce a policy that is manatory, they try to make the API easy to
- use. If you create a security policy that is hard for the programmer
- to use, then the security policy won't be used.</p><p>When OpenBSD creates a new mitigation, their application porters port
- 3rd party software packages to OpenBSD. Typically these changes find
- their way into the upstream packages. What's awesome is that usually
- other operating systems start to use OpenBSD mitigations on their
- systems 5 years after OpenBSD introduced them. Windows, Mac, and
- Linux applications all benefit from the strict standards that OpenBSD
- creates. Theo's talks gave two examples for this: <code>pledge ()</code> and
- <code>arc4random ()</code>.</p><p>Here's a question for you. How do you get random data? Well you read
- <code>/dev/random</code> of course. Simple. Easy. Done. That used to be how
- things were handled. Apparently reading from <code>/dev/random</code> has some
- limitations that Theo mentioned. Can you read from <code>/dev/random</code>
- inside the kernel? Inside a library? In your libc? Reading from
- <code>/dev/random</code> is not perfect. Theo wanted to make something better.</p><p>OpenBSD created <code>arc4random ()</code> as a better source of entropy. It is
- a C function that almost any application can call (even the kernel),
- most of the time. This lets many applications, libraries, etc. easily
- use random numbers. What's surprizing to me is that many operating
- systems use <code>arc4random ()</code> or a function like it, so that more
- applictions can easily request random data. This function (or one
- like it) exists on your Android phone, iPhone, iMac, and sort of on
- Linux thanks to OpenBSD.</p><p>What's <code>pledge ()</code> ? Oh ho, let me tell you! Let's take a look at a
- typical program.</p><pre><code class="language-C">int main () {
- initialize_stuff();
-
- for (;;) {
- ;; let's run the program
- }
- }</code></pre><p>Most programs have an initialization phase followed by a loop, in
- which the application runs. The OpenBSD team realized that the
- initialize phase uses most of the system calls. After the initialize
- phase, the program typically needs less system calls. OpenBSD's
- <code>pledge ()</code> was created in response to this pattern present in most
- programs.</p><p><code>pledge ()</code> is a security call, by which an application tells the
- kernel, "I pledge to only do these things and no other." For example,
- "I pledge to only output text". Or "I pledge to only access the
- internet and output text." If the application tries to do something
- that it has pledged not to do, then OpenBSD kills the application.</p><p>A really interesting blog post that talks about this is at
- <a href="https://justine.lol/pledge/">justine's blog</a>.</p><p>After watching two of Theo's talks, I am fairly convinced that his
- design goals are slowly working to make all POSIX operating systems
- more correct and secure. I used to dual boot Guix System and OpenBSD,
- but unfortunately my spare SSD busted. So for now I am only using
- Guix System. I personally prefer to use Guix System for my linode
- server (that powers this blog), because Guix makes it easy to manage
- servers.</p><p>I wish that the Guix developers could one day create Guix OpenBSD
- System, but I have been told that Guix System assumes your libc is
- <code>glibc</code> and that OpenBSD cannot currently make isolated build
- environments as well as Linux can. Also fun fact OpenBSD is not
- currently working on reproducible builds. :)</p><p>My two only minor complaints with OpenBSD currently are:</p><ul><li>I wish OpenBSD supported Wayland. This may happen in 6 months to a
- year. Fingers crossed.</li><li>A better filesystem: OpenBSD's FFS (fast file system) works, but it
- is possible to lose data in a crash. Filesystems are <em>really</em> hard
- to get right. Kent Overstreet has been working on bcachefs for
- almost a decade now, and it might soon become one of Linux's best
- filesystems (my opinion), so I don't blame OpenBSD for not trying to
- create a new next generational filesystem. Anybody want to spend 10
- years of their life creating an awesome filesystem that will
- probably only work well on OpenBSD? One might be able to port
- HammerFS to OpenBSD, and a basic read-only port does exist.</li></ul><p>If you want to try OpenBSD, give it a shot! It works really well on
- most lenovo laptops and most desktop machines.</p><ol><li>Nerdy computer people like me use the word "hacker" to mean someone
- who builds computer programs, and a "cracker" is someone who breaks
- into computer systems.</li></ol></div></article></section></main><footer><p>© 2020 Joshua Branson. The text on this site is free culture under the Creative Commons Attribution Share-Alike 4.0 International license.</p><p>This website is build with Haunt, a static site generator written in Guile Scheme. Source code is <a href="https://notabug.org/jbranso/gnucode.me">available.</a></p><p>The color theme of this website is based off of the famous <a href="#3f3f3f" target="_blank">zenburn</a> theme.</p></footer></body>
|