Live data from Hacker News

Uncovering a 24-year-old bug in the Linux Kernel (2021)

engineering.skroutz.gr

21–30 of 84 posts

Re: Uncovering a 24-year-old bug in the Linux Kernel (2021)

#21
This was a cool example of a class of bugs that are both hard to find with no active example, and hard to prevent in complex systems. The optimization that was added many years ago for performance didn't update something that had a use case that was incompatible with not being updated in a very small number of circumstances.

It is an interesting thought experiment to consider what kind of tool or automated detection could have found this. Some type of dependency linking between variables might have shed some light, but I'm not sure that would have really highlighted this kind of issue.

Great description of both the bug and the path to the solution!

Re: Uncovering a 24-year-old bug in the Linux Kernel (2021)

#22

Could someone provide link(s) on how regular snapshots of databases can be taken like this? (Googling didn't help much, maybe I'm googling for the wrong keywords.) For me, backing up the database is a few-hour-long process. Restoring it for a developer again is a few hours process. I read about snapshots before but haven't realized they could be this effective.

for mariadb :

0) make sure the the database data volume is on lvm or zfs

in a sql prompt:

  1) BACKUP STAGE START; BACKUP STAGE BLOCK_COMMIT;
  2) \! the shell command to take the snapshot
  3) BACKUP STAGE END;
you can now mount your snapshot, copy it offsite and delete it. The restore procedure is left as an exercise!

Re: Uncovering a 24-year-old bug in the Linux Kernel (2021)

#23

Earlier quoted context omitted.

> We need more people and companies like this, who are willing to go beyond "oh it fails randomly sometimes" and track down the underlying issues. I absolutely disagree. Most capable engineers I know have this urge to go down rabbit holes and fix any issue, this is nothing special. Everyone wants to be the hero that found a bug deep in the stack, make a glorious pull request, and be celebrated in the community. I muc…

Eh, right, many bugs we have don't really matter. Oh what is that you say, security vulnerabilities are also just bugs that get exploited? Oh well...

[deleted]

Re: Uncovering a 24-year-old bug in the Linux Kernel (2021)

#24

As someone who thrives on tracking down rare but annoying bugs in a debugger, I love stories like this. It is not just bugs that cause real failures which can be headaches; but also bugs that just slow things down unexpectantly. They can sometimes go undetected for decades like this one. I wrote an article this past year that talks about silent bugs that slowly eat resources and collectively can be very expensive in…

Okay but where's the bug story? Did I miss the story?

Re: Uncovering a 24-year-old bug in the Linux Kernel (2021)

#25
Okay so I got to the wrap-up at the end, about "why did nobody else find this", the author sets up some logical dominoes but doesn't knock them down. Allow me to try:

Earlier in the article, the author mentions that they recently upgraded some network hardware, and the problem seemed to become more frequent after that.

Packet loss or other network issues would force the stack to fall out of fast-path and update the counter, avoiding the bug.

Running over ssh would avoid the bug. The only time you'd run rsync not over ssh would be within your own network.

So it sounds like (this is my conjecture here) this would only appear to someone running rsync internally, over a high-performance network with no packet loss, and upgrading the switches might've finally gotten the network good enough to expose the bug?

Re: Uncovering a 24-year-old bug in the Linux Kernel (2021)

#27

This was a cool example of a class of bugs that are both hard to find with no active example, and hard to prevent in complex systems. The optimization that was added many years ago for performance didn't update something that had a use case that was incompatible with not being updated in a very small number of circumstances. It is an interesting thought experiment to consider what kind of tool or automated detection…

Probably the only way to prevent this type of issue in an automated fashion is to change your perspective from proving that a bug exists, to proving that it doesn't exist. That is, you define some properties that your program must satisfy to be considered correct. Then, when you make optimizations such as bulk receiver fast-path, you must prove (to the static analysis tool) that your optimizations to not break any of the required properties. You also need to properly specify the required properties in a way that they are actually useful for what people want the code to do.

All of this is incredibly difficult, and an open area of research. Probably the biggest example of this approach is the Sel4 microkernel. To put the difficulty in perspective, I checkout out some of the sel4 repositories did a quick line count.

The repository for the microkernel itself [0] has 276,541

The testsuite [1] has 26,397

The formal verification repo [2] has 1,583,410, over 5 times as much as the source code.

That is not to say that formal verification takes 5x the work. You also have to write your source-code in such a way that it is ammenable to being formally verified, which makes it more difficult to write, and limits what you can reasonably do.

Having said that, this approach can be done in a less severe way. For instance, type systems are essentially a simple form of formal verification. There are entire classes of bugs that are simply impossible in a properly typed programs; and more advanced type systems can eliminate a larger class of bugs. Although, to get the full benefit, you still need to go out of your way to encode some invariant into the type system. You also find that mainstream languages that try to go in this direction always contain some sort of escape hatch to let the programmer assert a portion of code is correct without needing to convince the verifier.

[0] https://github.com/seL4/seL4

[1] https://github.com/seL4/sel4test

[2] https://github.com/seL4/l4v

Re: Uncovering a 24-year-old bug in the Linux Kernel (2021)

#28

Okay so I got to the wrap-up at the end, about "why did nobody else find this", the author sets up some logical dominoes but doesn't knock them down. Allow me to try: Earlier in the article, the author mentions that they recently upgraded some network hardware, and the problem seemed to become more frequent after that. Packet loss or other network issues would force the stack to fall out of fast-path and update the c…

That sounds plausible. But also, most software (browsers, web service SDKs, RPC frameworks) treat TCP connections as fallible by setting read/write timeouts and aggressively reopening broken connections. So, I’m totally not surprised this issue went unnoticed for this many years.

Re: Uncovering a 24-year-old bug in the Linux Kernel (2021)

#29

Could someone provide link(s) on how regular snapshots of databases can be taken like this? (Googling didn't help much, maybe I'm googling for the wrong keywords.) For me, backing up the database is a few-hour-long process. Restoring it for a developer again is a few hours process. I read about snapshots before but haven't realized they could be this effective.

Because it isn't a backup. They put the database into a quiescent state on disk, take a file system snapshot, let the dbms resume working, and send the snapshot data via rsync.

This requires the cooperation of the dbms software to get the on-disk data quiesced. Then your snapshot has to go fast enough that the dbms doesn't end up with too many spinning plates before you let it start writing normally.

Re: Uncovering a 24-year-old bug in the Linux Kernel (2021)

#30
post #26

This is a good case for formal verification.

I struggle because I want to upvote these comments, because that's the world I want to live in. But the opposite side of that coin is who is going to author the incredibly arcane specification of TCP against which any such implementation is formally verified?

Maybe TCP stacks are one of the few cases where that make sense, but I'd suspect if it was "worth the cost" it would have already been done

Post reply on HN