News for hackers. Stuff that matters.
Re:Don't trust comments by throw10920 on Wednesday February 02, 2022 @04:53PM (#30184590)
Except you can't trust function names either.

Remember the NSO iMessage exploit?[1] copyGifFromPath didn't really copy the GIF from the path.

At some point, you do have to trust that the kernel API's documentation (or whatever) is correct[2], simply because it's physically impossible for you to exhaustively verify that each piece of software you use (transitively) has correct documentation and consistent semantics. That doesn't mean that you shouldn't audit third-party code, do code reviews, write tests, fuzz your code, and use static analysis and formal methods - in fact, you should do all of those things, if you can.

But, "don't trust comments" is a gross oversimplification. Perhaps "trust, but verify" is a better pithy saying.

[1] https://googleprojectzero.blogspot.com/2021/12/a-deep-dive-i...

[2] technically, if you did all of the above things, or found other people that did them, then you wouldn't have to trust documentation - but the vast majority of the time, most of the software you encounter will not have been thoroughly audited, tested, and fuzzed, with a nice formal specification

Re:Don't trust comments by ncmncm on Wednesday February 02, 2022 @06:02PM (#30185435)
"Trust, but verify" is a semantically null expression that appears to have filtered out of the Soviet Union during arms reduction negotiations, and eagerly taken up by Reagan administration appointees.

You can only ever trust or verify. "Trust, but verify" is functionally identical to "verify", thus, equivalently, "distrust, therefore verify", with maybe a generous helping of cynicism, doublethink, and official mollification.

Re:Don't trust comments by Seattle3503 on Wednesday February 02, 2022 @07:16PM (#30186401)
> ncmncm 1 hour ago | parent | context | flag | on: Don't trust comments

"Trust, but verify" is a semantically null expression that appears to have filtered out of the Soviet Union during arms reduction negotiations, and eagerly taken up by Reagan administration appointees.

In a modern context it means, look for errors but not deception. It's how I approach code review.

Re:Don't trust comments by 62951413 on Wednesday February 02, 2022 @07:02PM (#30186248)
* I could be a verbatim translation and so lose subtle semantics; "don't expect what you don't inspect" would be idiomatic

* Any Soviet saying would come from a culture used to double-speak to survive government oppression and censorship. Which is probably still new to many Americans who remember good old days.

Re:Don't trust comments by blooalien on Thursday February 03, 2022 @04:29PM (#30199170)
> "Which is probably still new to many Americans who remember good old days."

It's been straight up surreal watching the world turn into the George Orwell "1984" world we were all warned about as children, and seeing the USA (Land of "Freedom") gleefully join in the dystopian "fun".

Re:Don't trust comments by Terr_ on Wednesday February 02, 2022 @06:41PM (#30185966)
That may be a confusion of different grades of trust. For example, the difference between trusting someone's intent versus trusting their capability or trusting an outcome in an imperfect universe. Alternately, the degree to which one cooperates in advance of getting verification. A "measure" of trust, if you will.

Either way, if you insist on an excessively narrow definition of trust as being "never verifying", then yes, they're mutually exclusive... but only because it's circular logic.

Re:Don't trust comments by Spivak on Wednesday February 02, 2022 @06:59PM (#30186209)
I’ve always taken it to mean “don’t block people you already trust waiting on the verification to come through but do check it eventually.”

Bar tabs are a good example of this behavior. Just get your regular a drink and assume their card will go through. In the past checks worked like this too.

  1. Let the person start doing what they set out to do.

  2. Check if they actually have permission.

  3a. If yes, stop.

  3b. If no, block their access.
Re:Don't trust comments by gxt on Wednesday February 02, 2022 @08:26PM (#30187102)
Would you bother to check something you distrust? I wouldn't, it would be a waste of time.
Re:Don't trust comments by ncmncm on Wednesday February 02, 2022 @10:23PM (#30188149)
You don't count your change?

I mean, when you get any. That is increasingly rare.

Re:Don't trust comments by strken on Wednesday February 02, 2022 @10:46PM (#30188333)
In this vein, "distrust" means you believe they may have shortchanged you, while "trust but verify" means you're also open to the possibility they gave you a $10 instead of a $5.
Re:Don't trust comments by gxt on Wednesday February 02, 2022 @11:37PM (#30188742)
A prerequisite to trust-but-verify is having the luxury of trust. What you describe is a scenario where you may not afford any. In that case it's verify-or-bust :)
Re:Don't trust comments by kingcharles on Wednesday February 02, 2022 @08:52PM (#30187361)
"This cat food is new and improved!"

"How can it be both NEW and IMPROVED?"

Re:Don't trust comments by jcelerier on Wednesday February 02, 2022 @06:25PM (#30185745)
> "Trust, but verify" is functionally identical to "verify"

is there some kind of equivalent of aphantasia but for the feeling of trusting something ?

Re:Don't trust comments by sk0g on Wednesday February 02, 2022 @06:40PM (#30185956)
It's like the rule I forget the name of - if a sentence has a but in it, everything before the but is filler :)
Re:Don't trust comments by naruhodo on Wednesday February 02, 2022 @07:48PM (#30186772)
Not just filler. Everything before the "but" is negated.

I'm not racist, but <some racist shit>.

Re:Don't trust comments by strken on Wednesday February 02, 2022 @10:48PM (#30188353)
This is trivially stupid. "I like the Corvette, but I'd get it in red" does not mean you hate Corvettes. "I like steak, but only medium or below" does not mean you hate steak.
Re:Don't trust comments by naruhodo on Friday February 11, 2022 @01:13AM (#30297686)
> I like the Corvette, but

You don't like the Corvette. Not that Corvette. However, you like Corvettes in general. Or you only like red Corvettes.

> I like steak, but

Turn the comma into a period: I like steak. It's unconditional; steak is a big yes for you. Except it's not. You have conditions. So sometimes you like steak and sometimes the opposite. You don't like steak.

I think the interpretation of but is not as trivially stupid as you say.

Re:Don't trust comments by ncmncm on Thursday February 03, 2022 @02:07AM (#30189580)
Do you understand what the word "filler" means?
Re:Don't trust comments by ncmncm on Thursday February 03, 2022 @04:30AM (#30190489)
Sorry, I misread.
Re:Don't trust comments by rodgerd on Wednesday February 02, 2022 @08:09PM (#30186962)
I trust the developers I work with to try and build code to spec.

I verify their code with testing because humans are fallable.

Re:Don't trust comments by lmm on Wednesday February 02, 2022 @07:25PM (#30186534)
You can't trust function names, but they have a better chance of being kept up to date than comments, since they're more likely to be in active use. But yeah, the only thing you can really trust is the type signature (and even that, only if the language has a strong culture of not doing random nonsense).
Re:Don't trust comments by jchw on Wednesday February 02, 2022 @05:10PM (#30184795)
On one hand, I agree.

On the other, this does feel a bit whatabouty. Because yeah, you can’t check the kernel code, but you can and should check the code of direct dependencies. Not every time you do anything, but certainly whenever there’s something to be feared. Running code against untrusted inputs from the Internet is one of the few places that would justify “reverse engineer the kernel to make sure it’s safe” levels of concern, in the right conditions.

Re:Don't trust comments by nerdponx on Wednesday February 02, 2022 @04:40PM (#30184436)
Can someone help me understand what actually happened here? As far as I can gather, the comment in the code wasn't a lie, but the overall system was complicated enough that there was a way for the thing-that-shouldn't-happen to happen anyway. So the docs weren't wrong, but there was a bug in the code that led to incorrect behavior that deviated from the docs.

Or am I misunderstanding something?

Re:Don't trust comments by xx_ns on Thursday February 03, 2022 @04:02AM (#30190316)
The comment did actually seem to be a flat out lie. It specifically states that include statements don't work when they did in fact work as normal.

I don't think the lie was deliberate - the comment was probably erroneously added.

Re:Don't trust comments by SahAssar on Wednesday February 02, 2022 @04:37PM (#30184399)
Comments state intent, code states reality. If those do not match one of them needs to change.

When it comes to security no one should trust that intent matches reality.

Re:Don't trust comments by wahern on Wednesday February 02, 2022 @04:40PM (#30184439)
Thus the hacker refrain, "lies, damned lies, and comments", for which oddly I'm unable to find any examples despite having seen it recited several times over the years. In fact, I believe I came across that rephrasing before learning of Twain's famous original. I always found it a more pithy justification for why source code comments should only explain why, not how or what.
Re:Don't trust comments by monetus on Wednesday February 02, 2022 @04:23PM (#30184249)
4 days between notification and propagation of the fix. Thank you for poking around OP. Sanitizing your inputs isn't always simple.
Re:Don't trust comments by xx_ns on Thursday February 03, 2022 @04:04AM (#30190335)
Aye, response was superb! It would've probably been less than 4 days had it not been on a weekend.
Re:Don't trust comments by hinkley on Wednesday February 02, 2022 @07:31PM (#30186600)
I don’t want comments, I want commentary. Every time I’m confidently wrong in a commit message - anything from the wrong bug ID to declaring victory prematurely - I wish I could go modify or amend it.

Commits need to be in a separate version tree from their commit messages.

Re:Don't trust comments by spicybright on Wednesday February 02, 2022 @04:53PM (#30184586)
I kind of wish there was a verifier for function/statement comments to flag inaccurate comments (besides interface descriptions + general comment at the top of a function.)

Sort of a combination of a reverse github auto-pilot metric and checking how old a comment is based on it's surrounding code.

You could even syntax highlight based on how accurate it thinks it is like how down voted HN comments fade out.

Re:Don't trust comments by Natsu on Wednesday February 02, 2022 @07:45PM (#30186746)
You could flag how many revisions it has been since the comments were updated in a function as compared to the code, but if that became a metric, someone would probably start optimizing for it by making trivial comment changes without doing real review.
Re:Don't trust comments by xwdv on Wednesday February 02, 2022 @04:54PM (#30184605)
People don’t care about accurate comments, they care about comments they agree with.
Re:Don't trust comments by tomcam on Wednesday February 02, 2022 @05:46PM (#30185216)
OK well you just rewrote my worldview. That observation can goes deep as one wishes go go with it...
Re:Don't trust comments by xwdv on Wednesday February 02, 2022 @07:09PM (#30186329)
It becomes obvious this is the way the world works the more you start to generate unique comments rather than simply agree or upvote other people’s comments.
Re:Don't trust comments by roylez on Wednesday February 02, 2022 @04:30PM (#30184332)
Yes, rst is more powerful. So powerful that it can cause CVE.
Re:Don't trust comments by longivitate on Wednesday February 02, 2022 @04:10PM (#30184111)
Especially this one.
Re:Don't trust comments by capableweb on Wednesday February 02, 2022 @04:11PM (#30184122)
You're missing a `.. include :: ./arc-admin-credentials.json`
Re:Don't trust comments by zatarc on Wednesday February 02, 2022 @04:19PM (#30184210)
Don't trust this comment.
Re:Don't trust comments by nathias on Wednesday February 02, 2022 @05:00PM (#30184673)
trust but verify
Re:Don't trust comments by xwdv on Wednesday February 02, 2022 @04:44PM (#30184479)
You can definitely trust comments on Hackernews more than other sources such as Reddit.
Re:Don't trust comments by thisisbrians on Wednesday February 02, 2022 @07:18PM (#30186429)
Yes; poor comments tend to get downvoted.