flak rss random

documentation is thoroughly hard

Documentation is good, so therefore more documentation must be better, right? A few examples where things may have gotten out of control.

more...

Posted 18 May 2017 20:24 by tedu Updated: 19 May 2017 02:48
Tagged: openbsd software

meaningful short names

Why don’t unix commands have any vowels in the name? cp and mv are obviously devoweled standins for copy and move. But they’re less intuitive for new users. The user wants to copy a file. Why shouldn’t the name of the command be exactly the operation the user wants to perform?

What exactly does the user want to do? Instead of copying files, maybe I want to link two files. What does that mean? In unix, we have hard links and symbolic links. If I replace the “original” file, do I want the link to refer to the original file or the replacement? Or maybe what I mean by link two files is to combine two object files into an executable. Do we call that loading instead? ln is the name of a command, but link is the name of a concept. And sometimes the concept evolves over time. The linker is called ld because it used to be the loader. (I think.)

grep is a remarkably useful tool, but with a most unintuitive name. Why not call it find like Windows does? I want to find some text, I run find. So obvious. But some users may want to find files in the filesystem, not strings in a file. What command do they run? Probably locate.

There may be a great deal of historical accident in the names of commands (what if the inventors of awk had different initials?), but that doesn’t mean we can’t recognize the value of unique and precise identifiers.

Posted 03 Mar 2017 02:31 by tedu Updated: 14 Jun 2017 22:55
Tagged: rants software

RC40 card cipher

The Solitaire cipher is perhaps the best known encryption algorithm implemented with a deck of cards. Ignoring security, it has a few drawbacks. It’s pretty complicated. I can never quite remember the rules. Sure, with practice it’s possible to memorize, but ideally we want something easy to teach. It’s also pretty slow. Even with practice, the shuffling and cutting manipulations take time.

more...

Posted 10 Feb 2017 14:27 by tedu Updated: 10 Feb 2017 14:27
Tagged: gadget security

it's hard work printing nothing

It all starts with a bug report to LibreSSL that the openssl tool crashes when it tries to print NULL. This bug doesn’t manifest on OpenBSD because libc will convert NULL strings to “(null)” when printing. However, this behavior is not required, and as observed, it’s not universal. When snprintf silently accepts NULL, that simply leads to propagating the error.

more...

Posted 08 Aug 2016 17:00 by tedu Updated: 10 Oct 2016 19:46
Tagged: c openbsd programming

random failures

Lots of examples of random numbers failing, leading to cryptographic failure.

more...

Posted 05 Aug 2016 18:15 by tedu Updated: 19 Aug 2016 04:19
Tagged: gadget security software

who hacked madam?

The second season of Madam Secretary devotes several episodes to the hacking of the flight controls on Air Force One and the ensuing cyberwar. It’s fiction because nobody in real life is hot as Téa Leoni. Therefore it is totally unrelated to current events.

The trouble begins when AFO disappears over the Pacific. Madam must become Acting President for approximately forty minutes, just long enough to sign a pardon for a wrongfully imprisoned journalist before the episode ends.

Later, we learn that the plane was hacked by some very sophisticated malware. It penetrated three firewalls. Nevertheless, it gives up its secrets under the careful study of the president’s cyber czar, Oliver, who’s basically a black mudge.

The malware was indubitably created by Dash, who’s basically a blackhat mudge. He’s the worst kind of hacker, one who will work for anyone. Russia, China, Iran. Basically anybody as long they’re not a democracy. He gets paid in Bitcoin. The very worst.

Dash is tracked to somewhere unimportant and far away by Oliver, because Oliver is a badass. Seal Team 1776 is sent in to make the capture. Alas, the Russians got there first and gave him some of their polonium secret sauce. Now he looks like this.

dash husk

Bad luck. At least we know it was the Russians.

Oliver goes to work hardening all the country’s infrastructure. Basically apt-get update everything I guess. That mostly happens off screen but it’s all very smooth. So now the president orders a counter cyber strike (or is it a cyber counter strike?) and shuts down the Moscow power grid. That’ll teach ‘em to fuck with my ride.

The Russians retaliate by turning off an oil pipeline, as in literally turning great big wheels to seal the pipe. Decidedly non cyber. But why did they cyber terrorize the plane? Where did their mad hacking skills go?

False flag! It was really the Ukraine who hired Dash, to incite the US to attack Russia. Very sneaky.

I think the lesson to be learned is that if you’re going to hire mercenaries to go up against POTUS, Hessians are always the best choice.

Posted 30 Jul 2016 01:08 by tedu Updated: 30 Jul 2016 01:08
Tagged: moviereview politics

broken features aren't used

One of the difficulties in removing a feature is identifying all the potential users. A feature here could be a program bundled with an operating system, or a command line option, or maybe just a function in a library. If we remove a feature, users that depend on it will be sad. Unfortunately, absence of evidence is not evidence of absence. I’ve never heard of anybody running ls -p but it’s not impossible that somebody does.

The reasons why we want to remove an existing feature can vary. Sometimes it’s old code that interferes with maintenance. Sometimes a nearly complete rewrite can improve performance. In other cases, the feature in question is really more of a misfeature. It may have security implications, where the existence of the feature can be used to facilitate the exploitation of other vulnerabilities, and removing the feature will help mitigate the exploit.

There’s no general test that can be used, but there is one test that works in many cases. Test that the feature works. If the feature doesn’t work, that’s compelling evidence that nobody is using it, because nobody can be using it. You don’t need to fix it. You can just remove it.

(If you’ll pardon the heresy, this may be an argument against exhaustive unit tests. Many times a feature will start life in a functional state, but over time falls out of use and then gets broken by subsequent changes. Nobody notices and life goes on. If you have a perfect test suite, you’ll never have broken features, making it harder to identify the unused ones.)

Posted 29 Jul 2016 21:32 by tedu Updated: 30 Jul 2016 01:27
Tagged: programming software

rss table manners

I provide an RSS feed for flak. I also wrote a simplistic RSS feed reader for myself. The design of the latter was influenced by observing the behavior of existing readers.

There’s a small wave of fetchers that appear every five and ten minutes, converging with larger waves every fifteen minutes. These coalesce with a tidal wave at the top of every hour. My log file shows a whole lot of quiet interspersed with feeding frenzies at regular intervals.

This isn’t a problem, per se, because the total number of feeders is low, and the feed itself is very lightweight. But it’s easy to imagine a more popular blog with more content requiring an outsize investment in capacity to handle such an uneven request distribution.

What can a reader do to avoid such rude behavior? Check feeds at irregular times. For me, this was implemented as a check deadline for each feed. Each time the feed is checked, the deadline is incremented by a random amount between two and four hours. (One to two would work great, too. I’ve fluctuated a bit.) This means that not only is my fetcher not synced with other fetchers, but it’s not possible for it to even accidentally fall into lock step.

If everyone did things this way, that’s all that would be needed. But in a world populated with lock step feeders, there’s one more wrinkle. The fetch process is initiated by cron every five minutes, but the very first thing it does is sleep a random amount between one and three minutes before checking for expired deadlines, ensuring that we never hit a server during a hot minute.

I do this mostly because being polite to servers is the right thing to do, but clients benefit from being nice too. Requests to an idle server are more likely to succeed and faster. If multiple clients are sharing a link (or proxy), they can suffer the same kinds of congestion that busy servers do.

One can imagine that RSS feeds are not the only problem domain which benefits by decoupling a regular activity from a fixed time.

Posted 27 Jul 2016 18:00 by tedu Updated: 27 Jul 2016 18:00
Tagged: software web

one reason to hate openbsd

The gcc-local man page, which documents local changes to the compiler has this to say.

The -O2 option does not include -fstrict-aliasing, as this option
causes issues on some legacy code.  -fstrict-aliasing is very unsafe
with code that plays tricks with casts, bypassing the already weak
type system of C.

What does this mean and why should you care? The first part is easy to answer. Long ago, in the dark ages when legacy code was written, people used to write functions like this:

float
superbad(float f)
{
    int *x = (int *)&f;

    *x = 0x5f3759df - ( *x >> 1 );
    return f;
}

The C standard clearly says that objects are not to be accessed through incompatible pointers, but people did it anyway. Fucking idiots.

As for why one should care about the default setting of the compiler, the best answer I can give is that if you’re in a position to care, you probably know more than enough to form your own opinion and don’t need me to explain it to you. Otherwise, nobody cares except to the extent it confirms one’s own biases.

The strict aliasing optimization is disabled in gcc 4.2 because it was disabled in gcc 3.3. It was disabled in gcc 3.3 because it was disabled in gcc 2.95. It was disabled in gcc 2.95 because it was the year 1999.

The gcc-local man page continues with even more stupid options.

The -O2 option does not include -fstrict-overflow, as this option
causes issues on some legacy code.  -fstrict-overflow can cause
surprising optimizations to occur, possibly deleting security
critical overflow checks.

Lame.

The Strict Aliasing Situation Is Pretty Bad.

Posted 25 Jul 2016 12:52 by tedu Updated: 08 Sep 2016 13:06
Tagged: c openbsd rants

turn up the hope

I’m at the HOPE XI conference. Or I was. It’s kind of overcrowded, which is both great and not so great. I haven’t been to a HOPE since The Last HOPE, but I don’t recall it being as crowded. Perhaps it was. In any case, the logistics of getting in to see each talk in person is exhausting. Some of the talks I wanted to see today are definitely the big name headliners, and I can’t imagine it will be less crowded. Better to watch online. Some thoughts on the talks I did see.

more...

Posted 23 Jul 2016 16:39 by tedu Updated: 23 Jul 2016 16:39
Tagged: event