Hacker News new | ask | show | jobs
by bizarref00l 4652 days ago
My first guess was running package manager checksum verify, like "rpm -V kernel" , for rpm based distro. But i'm not sure if it was the question was aiming for.
1 comments

The question, as written, has no answer. fsck only checks the filesystem. There is no way to check the consistency of the running kernel but a kernel panic is a telltale sign of INconsistency :)
You can check the consistency of the kernel "file" and compare a MD5 / SHA-1 of known good kernel. Assumption here that the kernel is loaded into healthy hardware. Depends on the spirit of the question. I do agree, running kernel looking at itself... chicken::egg.
For corruption, sure, but rootkits can mess that up by changing the md5 binary to always give the tainted kernel a known checksum.

If a malicious attacker can modify a kernel, no process running within the kernel can check it for consistency.

I was very confused on this question as well. Seeing both kernel and filesystem there together with the word consistent made me think of a sort of general health. So my answer would have been `iostat`. That would show me the running kernel, cpu utilization, and disk utilization.
What happens if you try to fsck /proc or /sys?

I presume 'not much' or 'you get an error', but I don't have an instance I'm prepared to sacrifice right now, just in case something hilariously destructive happens.

fsck doesn't run on a directory, it runs on a block device. You can't run it on /proc or /sys because those aren't backed by a block device. /proc only looks like it has a file system because the kernel "pulls" the "files" out of thin air when you try to access them.
You can run fsck in a diagnostic mode that doesn't write any changes.