Live data from Hacker News

Am I a Good C Programmer?

gavinhoward.com

1–10 of 39 posts

Re: Am I a Good C Programmer?

#2
It doesn't look like bc uses fuzzing? It'd be interesting to see the outcome there since even in mature projects it consistently leads to novel memory safety bugs every few days [1]. Fuzzing find a lot of really weird and unintuitive bugs in my experience, especially as it relates to use-after-frees and races.

[1] Linux syzkaller bug tracker https://groups.google.com/g/syzkaller-bugs

Re: Am I a Good C Programmer?

#3

  Those links say 70% of all security bugs, but since my bc/dc does not have the ! command (to spawn processes) and only reads files, not writes them (except stdout), it’s hard to actually turn a memory safety issue into a security bug, even if it’s possible.
Is this quote assuming ASLR, non-executable stack, stack canaries?

I don't really understand what writing files and forking have to do with the security of system? Unless you mean it limits the attack surface from a ROP gadget?

Re: Am I a Good C Programmer?

#4
I was part of a team at a job about 20 years ago that ported an existing C codebase over to (then new) Java. Once we got everything working, a co-worker who was very familiar with the old C codebase remarked that with C it took a lot longer to get things working the first time, but once they were working, they stayed working whereas with Java you could get things working pretty quick, but you'd start to see problems when you actually put load on it.

Re: Am I a Good C Programmer?

#5

It doesn't look like bc uses fuzzing? It'd be interesting to see the outcome there since even in mature projects it consistently leads to novel memory safety bugs every few days [1]. Fuzzing find a lot of really weird and unintuitive bugs in my experience, especially as it relates to use-after-frees and races. [1] Linux syzkaller bug tracker https://groups.google.com/g/syzkaller-bugs

Author here.

My bc does use fuzzing. [1]

I love fuzzing. In my new project, fuzzing generates my test suite that I then go through by hand and verify.

In bc, if I change the source code before a release, I run a fuzzer for two weeks on both bc and dc.

[2] and [3] are directories of error tests, almost all of which were found by AFL(++).

If you run the following on my bc repo:

    commits1=$(git log --oneline --grep=afl)
    commits2=$(git log --oneline --grep=AFL)
    printf '%s\n%s\n' "$commits1" "$commits2" | uniq | wc -l
You will get 148 as of 53832b884b5c. Not all of those are bugs found by AFL(++) because some are tending to my fuzzing infrastructure, but at least 2/3 probably are.

[1]: https://git.gavinhoward.com/gavin/bc/src/branch/master/tests...

[2]: https://git.gavinhoward.com/gavin/bc/src/branch/master/tests...

[3]: https://git.gavinhoward.com/gavin/bc/src/branch/master/tests...

Re: Am I a Good C Programmer?

#6
post #3

Those links say 70% of all security bugs, but since my bc/dc does not have the ! command (to spawn processes) and only reads files, not writes them (except stdout), it’s hard to actually turn a memory safety issue into a security bug, even if it’s possible. Is this quote assuming ASLR, non-executable stack, stack canaries? I don't really understand what writing files and forking have to do with the security of system…

Author here.

It means that you have to find input that triggers a memory bug to do something malicious.

If my dc had the `!` command, then you, as an attacker with low privileges, might be able to modify a dc script to spawn another command that you know can be exploited to get root. Without it, you have to exploit my dc for ROP or some other attack.

Of course, then you would just target a shell, right? And that's the point: I've put in enough work, and my bc/dc are locked down enough, that attackers would probably find other ways in.

Re: Am I a Good C Programmer?

#7

I was part of a team at a job about 20 years ago that ported an existing C codebase over to (then new) Java. Once we got everything working, a co-worker who was very familiar with the old C codebase remarked that with C it took a lot longer to get things working the first time, but once they were working, they stayed working whereas with Java you could get things working pretty quick, but you'd start to see problems…

Author here.

This is my experience, though I started in Java and transitioned to C.

My C code also does not need to be updated for language changes and such.

Re: Am I a Good C Programmer?

#10
post #8

This is the usual argument, "I am a good careful driver, only the other ones do mistakes, so we don't need seat belts".

I think comparing an activity that can result in loss of life to one that doesn't is probably on the dishonest side.

What language is used to control critical devices like pacemakers?
Post reply on HN