Live data from Hacker News

The Linux Backdoor Attempt of 2003 (2013)

freedom-to-tinker.com

11–20 of 144 posts

Re: The Linux Backdoor Attempt of 2003 (2013)

#11
post #4

I think that this might be an typo or at least it has plausible deniability. I have changed my coding style to always put constant on left side just to avoid such an error (such typo gave me a few days of debugging multithreaded code and I have just said "Never again!!" :D)

If you are using gcc you can use the -Wparentheses flag to turn on warnings for this: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#inde...

Re: The Linux Backdoor Attempt of 2003 (2013)

#13
post #6

Something as important as "uid" should be "const".

I mean... my first reading of that is "what a dumb idea, the reason it isn't const is that there are legit reasons to switch userid".

But then I have used exactly this pattern, and it looks something like:

struct protected_stuff { int userid; ... };

void set_userid(const struct protected_stuff prot, int newuserid) { struct protected_stuff backdoor = (struct protected_stuff *)prot; backdoor->userid = newuserid; }

and then the compiler complains if you go fiddling with userid outside this function where you deliberately opened a backdoor to write to it. (and you can wrap pragmas around that function to turn off warnings).

Re: The Linux Backdoor Attempt of 2003 (2013)

#14
post #4

I think that this might be an typo or at least it has plausible deniability. I have changed my coding style to always put constant on left side just to avoid such an error (such typo gave me a few days of debugging multithreaded code and I have just said "Never again!!" :D)

A typo is possible if it had been submitted to normal code review, but hacking into a server to secretly modify code all but rules out an accident.

Re: The Linux Backdoor Attempt of 2003 (2013)

#17

I admit that I read the code and completely overlooked the single equals sign. Makes me wonder why it would be so easy to change the userid. Shouldn’t there be some safeguards in place to stop the userid from being updated from unsafe places.

You make a good point, but in a monolithic kernel the kernel is the “safe place.” Most likely the effect of this would be subtle and not necessarily long lived.

Re: The Linux Backdoor Attempt of 2003 (2013)

#18
post #6

Something as important as "uid" should be "const".

I mean... my first reading of that is "what a dumb idea, the reason it isn't const is that there are legit reasons to switch userid". But then I have used exactly this pattern, and it looks something like: struct protected_stuff { int userid; ... }; void set_userid(const struct protected_stuff prot, int newuserid) { struct protected_stuff backdoor = (struct protected_stuff *)prot; backdoor->userid = newuserid; } and…

Compilers will produce slower code for this construction.

Re: The Linux Backdoor Attempt of 2003 (2013)

#19

Earlier quoted context omitted.

I mean... my first reading of that is "what a dumb idea, the reason it isn't const is that there are legit reasons to switch userid". But then I have used exactly this pattern, and it looks something like: struct protected_stuff { int userid; ... }; void set_userid(const struct protected_stuff prot, int newuserid) { struct protected_stuff backdoor = (struct protected_stuff *)prot; backdoor->userid = newuserid; } and…

Compilers will produce slower code for this construction.

The nice thing is, it's a pretty rare call hopefully, so that's not a big deal so long as they aren't slowing down the much more common reads.

Re: The Linux Backdoor Attempt of 2003 (2013)

#20
post #5

I think code like this shouldn't even compile like in other languages >Operator '&&' cannot be applied to operands of type 'bool' and 'int'

That would require some pretty big changes in the C programming language. Static analysis should detect it though, and probably does.
Post reply on HN