News for hackers. Stuff that matters.
Re:Xz: Can you spot the single character that disabled Linux... by phoe-krk on Saturday March 30, 2024 @09:36AM (#39874736)
So that function checked if the following C code compiled, and only in that situation enabled the landlock?

Except that lone period, hard to recognize because of its small size and proximity to the left edge of the diff, caused the C code to become always invalid, hence keeping the landlock always disabled?

That's both vilely impressive and impressively vile. I didn't even spot it on my first read-through.

Re:Xz: Can you spot the single character that disabled Linux... by 082349872349872 on Saturday March 30, 2024 @10:12AM (#39875087)
I just got a little more respect for pythonic whitespace-sensitivity

EDIT: come to think of it, even that might not have done much here, where well-formedness is the issue :(

Re:Xz: Can you spot the single character that disabled Linux... by capitainenemo on Saturday March 30, 2024 @11:00AM (#39875495)
Yeah, if anything, python worsens the situation. I had a friend DOS our server because he accidentally inserted a tab, causing the illusion that one statement was inside a block but was actually outside it. He swore off python at that point. I personally avoid the language, but I understand due to issues like that these days mixing tabs and spaces is an error (or is it just a warning?) by default. Regardless, still pretty silly to me to have whitespace play such a major significant role, besides the fact that I find it visually harder to read, like text without punctuation or capitalisation.
Re:Xz: Can you spot the single character that disabled Linux... by secstate on Saturday March 30, 2024 @11:49AM (#39875988)
Mixing tabs and spaces usually throws a runtime exception. I'm not gonna make a value judgement about that, but your story doesn't make sense based on how I understand py3

Edit, sorry, shoulda read your whole commebt before replying

Re:Xz: Can you spot the single character that disabled Linux... by capitainenemo on Saturday March 30, 2024 @12:03PM (#39876104)
Yep. It was a few years ago while that was stilled allowed (as I'd noted ;) ) but regardless. Significant whitespace is just annoying.. There's a lot of things that render as whitespace, and source code one might be reviewing could be printed wrapped or copied and pasted in odd ways. Other languages are more robust to this.
Re:Xz: Can you spot the single character that disabled Linux... by _visgean on Saturday March 30, 2024 @07:24PM (#39879634)
Never had this happen, this is largely eliminated by using tools like black or other autoformatters.
Re:Xz: Can you spot the single character that disabled Linux... by eru on Saturday March 30, 2024 @10:18PM (#39880743)
And/or linters.

This issue is no worse that having multiple different variables that look the same and only in their obscure same-looking unicode symbols.

A linter can handle this. As can a decent font, or editor settings.

Re:Xz: Can you spot the single character that disabled Linux... by MrDresden on Sunday March 31, 2024 @03:52AM (#39882312)
The point still stands that this is an inherit possibility in the language it self.
Re:Xz: Can you spot the single character that disabled Linux... by eru on Sunday March 31, 2024 @04:15AM (#39882425)
Well, in C the visual indentation and the meaning of the code (given by {}) can diverge. That's even worse, and happens in practice. Many style guidelines for C have evolved specifically to address that problem with 'the language itself'.
Re:Xz: Can you spot the single character that disabled Linux... by worik on Sunday March 31, 2024 @04:35PM (#39887842)
> Well, in C the visual indentation and the meaning of the code (given by {}) can diverge.

How?

Re:Xz: Can you spot the single character that disabled Linux... by eru on Sunday March 31, 2024 @08:29PM (#39889596)
The compiler doesn't check your indentation at all. (OK, not true, these days you get warnings for misleading indentation.) But here's an example of misleading indentation in C:

    if(some condition)
        do something; {
        do something else;
    }
    do another thing;
You can stretch 'some condition' out over multiple lines and have some more parents inside of it, to make it more confusing.

See also https://softwareengineering.stackexchange.com/a/16530

Re:Xz: Can you spot the single character that disabled Linux... by worik on Monday April 01, 2024 @07:57PM (#39900854)
I see.

Yes

I class that as a bug in the original C specification

Re:Xz: Can you spot the single character that disabled Linux... by eru on Monday April 01, 2024 @10:38PM (#39901857)
But you either make visual indentation significant, or you risk having a discrepancy between visual indentation and what the language sees.
Re:Xz: Can you spot the single character that disabled Linux... by worik on Monday April 01, 2024 @10:55PM (#39901938)
> But you either make visual indentation significant...

That would be Python. I do not like it, which does not mean it is bad, it is a matter of taste

The alternative is you say "blocks are delimited by {}"

`if(foo) bar` should be invalid

`if(foo){bar}` is OK by me. Worik's tick of approval

(Neither is valid C I think)

Re:Xz: Can you spot the single character that disabled Linux... by eru on Tuesday April 02, 2024 @04:03AM (#39903367)
> That would be Python.

Not necessarily. In practice, in C-as-actually-used people (should) set up linters and formatters, so that you can rely on indentation.

When programming, this means that you can behave as if both curly braces and indentation are significant, and you get an error when they are out-of-sync.

Re:Xz: Can you spot the single character that disabled Linux... by _visgean on Sunday March 31, 2024 @06:41AM (#39883071)
I think its more of an tooling issue. If your editor / diff viewer cant differentiate between different whitespaces get a better one. Also if you want to ensure some function isnt in local scope etc just test it.
Re:Xz: Can you spot the single character that disabled Linux... by probably_wrong on Sunday March 31, 2024 @08:14AM (#39883563)
I feel that the main point still stands, though. Saying that Python doesn't have a whitespace problem because you can send the code through a tool that detects whitespace-related problems still acknowledges the existence of said problem.
Re:Xz: Can you spot the single character that disabled Linux... by heavenlyblue on Saturday March 30, 2024 @10:14PM (#39880726)
You can enable showing whitespace characters in your editor, in PyCharm they are visualised perfectly well as to not distract from the non-whitespace.
Re:Xz: Can you spot the single character that disabled Linux... by deanishe on Sunday March 31, 2024 @10:29AM (#39884609)
> There's a lot of things that render as whitespace

Like what? As you note, mixing tabs and spaces is now an error.

I've never understood the objection to semantic whitespace. Complaining about having to indent code correctly strikes me as being akin to complaining about having to pee in the toilet instead of the bathtub.

Re:Xz: Can you spot the single character that disabled Linux... by capitainenemo on Sunday March 31, 2024 @03:15PM (#39887149)
there is a huge difference between having a coding standard (handled easily by a linter on commit in most languages) and making a particular whitespace indentation a critical language feature.

Bonus, if there's a good reason to change the linter format, you can do so. Rust handles this rather well I think.

Re:Xz: Can you spot the single character that disabled Linux... by katbyte on Saturday March 30, 2024 @07:01PM (#39879515)
white space as a delimiter is why i never use python.
Re:Xz: Can you spot the single character that disabled Linux... by naikrovek on Saturday March 30, 2024 @07:07PM (#39879542)
> white space as a delimiter is why i never use python.

Whitespace is a delimiter in (almost?) all languages humans use.

Whitespace determining which scope you’re in is one of the many problems of making whitespace significant.

Re:Xz: Can you spot the single character that disabled Linux... by ratmice on Saturday March 30, 2024 @08:02PM (#39879910)
Regarding your almost query. There was a debate over Ogham space mark in unicode. It is considered whitespace though, with the rationale that it is sometimes visible, but sometimes invisible. Depending upon whether the text has a stem-line. That doesn't make the set of non-whitespace delimited languages empty. Perhaps there is one with an always-visible delimiter that didn't get the whitespace justification, but does at least give one human language delimited by a printable character (which happens to be whitespace).
Re:Xz: Can you spot the single character that disabled Linux... by eru on Saturday March 30, 2024 @10:17PM (#39880741)
> That doesn't make the set of non-whitespace delimited languages empty.

Well, there's also the opposite: Goldman Sachs's Slang allows space as part of identifiers.

Re:Xz: Can you spot the single character that disabled Linux... by skissane on Sunday March 31, 2024 @06:19AM (#39882959)
> Well, there's also the opposite: Goldman Sachs's Slang allows space as part of identifiers.

Many SQL implementations permit whitespace in identifiers, but then you need to use quoted identifiers.

Re:Xz: Can you spot the single character that disabled Linux... by eru on Sunday March 31, 2024 @06:21AM (#39882968)
That's reasonably sane of SQL. In Slang, you don't need to quote. (The syntax is still unambiguous. In principle, eg Python could do something similar, because they don't have any existing syntax where you just put two identifiers next to each other with only a space in between. But C could not, because variable declaration is just two identifiers, one for the type and one for the variable name, next to each other with a space in between.)
Re:Xz: Can you spot the single character that disabled Linux... by skissane on Sunday March 31, 2024 @06:44AM (#39883090)
In Slang, are “x y” with different number of spaces in the middle different identifiers or different spellings of the same identifier? SQL standard says different identifiers

> eg Python could do something similar, because they don't have any existing syntax where you just put two identifiers next to each other with only a space in between

The interaction with keywords would cause some issues. For example, right now, “if” is not a valid identifier (keyword), but “if_” and “_if” are. However, with this proposal “x y” could be a valid identifier, but “x if” would introduce ambiguity

> But C could not, because variable declaration is just two identifiers, one for the type and one for the variable name, next to each other with a space in between

This is one aspect of C syntax I have never liked. I always wish it had been Pascal-style `x:int;` instead of `int x;`

Re:Xz: Can you spot the single character that disabled Linux... by eru on Sunday March 31, 2024 @11:26AM (#39885103)
> In Slang, are “x y” with different number of spaces in the middle different identifiers or different spellings of the same identifier? SQL standard says different identifiers

Sorry, I don't remember, and I can't seem to find it out online. I could ask my friends who still work there, if it's important. (For what it's worth, I never remember anyone complaining about mixing up a different number of spaces in their variable names. So either all number of spaces were treated the same, or perhaps multiple spaces in a row in an identifier were just banned (via linter or via language?).)

> The interaction with keywords would cause some issues. For example, right now, “if” is not a valid identifier (keyword), but “if_” and “_if” are. However, with this proposal “x y” could be a valid identifier, but “x if” would introduce ambiguity

Yes, you would need to sort out these details, if you wanted to add this 'feature' to Python.

> This is one aspect of C syntax I have never liked. I always wish it had been Pascal-style `x:int;` instead of `int x;`

I'm glad Rust made the same decision.

I do like using the 'space operator' to denote functions calls, at least for a language like Haskell or OCaml.

Re:Xz: Can you spot the single character that disabled Linux... by tomoyoirl on Saturday March 30, 2024 @07:32PM (#39879692)
“The thing that controls scope is the count of certain nonprinting characters, which happen to come in multiple widths” is reasonably insane, yes
Re:Xz: Can you spot the single character that disabled Linux... by eru on Saturday March 30, 2024 @10:16PM (#39880734)
Which non-printing characters are you talking about? Whitespace characters are very much printable.

Yes, I agree that Python should just forbid tabs. As a second best, you can tell your linter (and/or formatter) to forbid tabs (and any weird unicode whitespace). That's basically the equivalent of compiling your C with -Wall.

Re:Xz: Can you spot the single character that disabled Linux... by takeda on Sunday March 31, 2024 @02:44AM (#39881994)
This was an issue in Python 2, where for some dumb reason it allowed mixing tabs and spaces and equated tab to 8 spaces (I think). Python 3 doesn't have that issue.
Re:Xz: Can you spot the single character that disabled Linux... by capitainenemo on Sunday March 31, 2024 @03:41PM (#39887361)
Of course, if one was coding an exploit, one could still use python2. It is still commonly available due to a long tail of legacy scripts and in some cases (like a script I use routinely but didn't write) the difficulty of porting it to python3 (I've asked over a dozen pythonistas over the years, they kept running into same problems)
Re:Xz: Can you spot the single character that disabled Linux... by WirelessGigabit on Saturday March 30, 2024 @11:10PM (#39881027)
Human language is also way more ambiguous. One of the reasons I love coding is a massively reduced vocabulary and a way more strict grammer.
Re:Xz: Can you spot the single character that disabled Linux... by throwaway2037 on Sunday March 31, 2024 @05:55AM (#39882851)
Really? Another one of these comments? Do we yet have an LLM plugin for HN reader app to auto-filter them? Right up there with "When I last used Java version 5..." and "When I last used C++ in 1998..."

Guido van Rossum has a famous retort to this comment. You can find it on YouTube.

Further, if you are so easy to knock a good programming language that has more than proven it's worth at this point, you can just as easily "cancel" ALL other programming languages for equally trivial reasons. If you dare, share your favourite languages, and the votes and replies will not be generous.

Re:Xz: Can you spot the single character that disabled Linux... by raverbashing on Saturday March 30, 2024 @07:32PM (#39879698)
Yes mixing tabs and spaces is a big no no and rightfully throws an error now
Re:Xz: Can you spot the single character that disabled Linux... by worik on Sunday March 31, 2024 @04:41PM (#39887899)
Not an improvement

Tabs still have syntactical meaning and are still invisible

Python will never be a success, I predict, because of this

Trust me

Re:Xz: Can you spot the single character that disabled Linux... by fragmede on Saturday March 30, 2024 @11:04PM (#39880986)
humans are weird creatures sometimes. there was this bad thing that happened that won't happen again now, but now I can't use the thing forever because Reasons.
Re:Xz: Can you spot the single character that disabled Linux... by yegle on Saturday March 30, 2024 @07:14PM (#39879581)
In Python, you only need to indent the `def test_foo` by an additional whitespace, to make it a locally scoped function instead of a proper test function.
Re:Xz: Can you spot the single character that disabled Linux... by eru on Saturday March 30, 2024 @10:14PM (#39880729)
No, not if you have any sane linter or formatter involved. They wouldn't let you get away with indenting by a single space, but only by multiples of whatever you normally use in the rest of your program.
Re:Xz: Can you spot the single character that disabled Linux... by jrockway on Saturday March 30, 2024 @11:33PM (#39881162)
I mean, some CI system should be checking that "if_code_compiles()" blocks compile somewhere. It should be an error until the CI system has that header and can test both variants.

People are really quick to add optionality like this without understanding the maintenance cost. (Every boolean feature flag increases the number of variants you need to test by 2!) Either make a decision, or check that both sides work. Don't let people check in dead code.

Re:Xz: Can you spot the single character that disabled Linux... by asddubs on Sunday March 31, 2024 @03:35AM (#39882235)
multiplies it by 2, not increases
Re:Xz: Can you spot the single character that disabled Linux... by jrockway on Sunday March 31, 2024 @01:48PM (#39886325)
yup, meant to say "a factor of 2".
Re:Xz: Can you spot the single character that disabled Linux... by philsnow on Saturday March 30, 2024 @07:23PM (#39879631)
AST diffs instead of textual diffs might have helped here (to spot the `.` making the code un-compilable).

Edit: oof, though the stray character in question is inside a perfectly legitimate C string, so to catch this, any such diffs would need to Matroyshka down and that seems unsolvable / intractable.

Re:Xz: Can you spot the single character that disabled Linux... by raverbashing on Saturday March 30, 2024 @07:31PM (#39879679)
Ah yes but thanks to C being cursed due to includes and macros this is harder to do
Re:Xz: Can you spot the single character that disabled Linux... by uecker on Saturday March 30, 2024 @07:36PM (#39879723)
Huh, the code with a dot is not legal C. It is CMake issue that the test breaks here.
Re:Xz: Can you spot the single character that disabled Linux... by acdha on Saturday March 30, 2024 @09:06PM (#39880359)
That’s what makes this so clever: these systems were born in the era where you couldn’t trust anything - compilers sometimes emitted buggy code, operating systems would claim to be Unix but had weird inconsistencies on everything from system calls to command line tool arguments, etc. - so they just try to compile a test script and if it fails assume that the feature isn’t supported. This is extremely easy to miss since the tool is working as it’s designed and since it’s running tons of stuff there’s a ton of noise to sort through to realize that something which failed was supposed to have worked.
Re:Xz: Can you spot the single character that disabled Linux... by josefx on Sunday March 31, 2024 @04:51AM (#39882573)
You could just run tests for the feature detection on a known system or a dozen(VMs are cheap). The big problem is that most code is not tested at all or test errors are flat out ignored.
Re:Xz: Can you spot the single character that disabled Linux... by acdha on Sunday March 31, 2024 @08:42AM (#39883744)
Nothing “just” about it. VMs weren’t cheap when the C world started using autoconf - that was a feature mostly known on IBM mainframes – and in any case that couldn’t do what you need. The goal is not to figure out what’s there on systems _you_ control, it’s to figure out what is actually available on the systems other users are building on. Think about just this library, for example, your dozen VMs wouldn’t even be enough to cover modern Linux much less other platforms but even if it was (drop most architectures and only support the latest stable versions for the sake of argument), you’d still need to build some reliable prober for a particular bug or odd configuration.

The problem here wasn’t the concept of feature detection but that it was sabotaged by someone trusted and easily missed in the noise of other work. What was needed was someone very carefully reviewing that commit or build output to notice that the lockdown feature was being disabled on systems where it was fully enabled, and we already know that maintainer time was in short supply. Any other approach would likely have failed because the attacker would have used the same plausible sounding language to explain why it needed to be a complicated dynamic check.

Re:Xz: Can you spot the single character that disabled Linux... by josefx on Sunday March 31, 2024 @12:42PM (#39885766)
The goal is to figure out if the optional features work at all. For that a system you control is required.

That the sabotage worked at all relied on the fact that nobody was testing those features.

How secure is a sandbox that may not even exist? Apparently its good enough for most.

Re:Xz: Can you spot the single character that disabled Linux... by hermitdev on Saturday March 30, 2024 @10:46PM (#39880897)
That's kind of the point. It's feature detection code. If the code cleanly compiles, the feature is assumed supported, otherwise, it's assumed not present/functional. This pretty common with autotools. The gotcha here is this innocuous period is not supposed to be syntactically valid. It's meant to be subtle and always disable the feature.
Re:Xz: Can you spot the single character that disabled Linux... by asvitkine on Saturday March 30, 2024 @11:45PM (#39881215)
Shouldn't whatever is depending on xz supporting landlock be verifying that it's the case through blackbox tests or something? Otherwise a check like this even without the bug could end up disabling landlock if e.g. the compiler environment was such that a given header wasn't available...
Re:Xz: Can you spot the single character that disabled Linux... by saagarjha on Sunday March 31, 2024 @12:34AM (#39881474)
Yes, this is intentionally how autoconf is supposed to work.
Re:Xz: Can you spot the single character that disabled Linux... by mewpmewp2 on Saturday March 30, 2024 @10:01PM (#39880656)
I think main issue was that it was embedded in the file itself like that. Would have preferred to have it in a separate valid C file with syntax highlighting etc and being parsed from that file.
Re:Xz: Can you spot the single character that disabled Linux... by tsimionescu on Sunday March 31, 2024 @03:23AM (#39882173)
Perhaps, but given how most build systems work, that would complicate things in other ways (since build systems often try to compile all .c files).
Re:Xz: Can you spot the single character that disabled Linux... by throwaway2037 on Sunday March 31, 2024 @05:59AM (#39882878)
I am a CMake novice. Is that true for CMake in this example?
Re:Xz: Can you spot the single character that disabled Linux... by jcelerier on Sunday March 31, 2024 @07:27AM (#39883258)
Definitely not, cmake's try_compile function even directly supports being passed a source file.
Re:Xz: Can you spot the single character that disabled Linux... by mewpmewp2 on Sunday March 31, 2024 @08:41AM (#39883740)
Put it in a special folder that is ignored from the build.
Re:Xz: Can you spot the single character that disabled Linux... by account42 on Monday April 08, 2024 @09:33AM (#39969562)
That's really not how most build systems work.
Re:Xz: Can you spot the single character that disabled Linux... by eru on Saturday March 30, 2024 @10:20PM (#39880757)
> Edit: oof, though the stray character in question is inside a perfectly legitimate C string, so to catch this, any such diffs would need to Matroyshka down and that seems unsolvable / intractable.

Not sure, you could also just forbid code that's too complex to analyse without going down a rabbit hole. Instead of trying to go down the rabbit hole.

In general, it's hard to analyse arbitrary code. But we don't have to allow arbitrarily complex code when doing code review.

Re:Xz: Can you spot the single character that disabled Linux... by sidewndr46 on Saturday March 30, 2024 @10:09AM (#39875054)
I agree. The way I read this, I missed it completely until I searched for it. I was looking too closely at the rest of the code around defines
Re:Xz: Can you spot the single character that disabled Linux... by patrakov on Saturday March 30, 2024 @11:08PM (#39881006)
Even more evil would have been to replace this line

    (void)SYS_landlock_create_ruleset;
with this:

    (void)SYS_landloсk_create_ruleset;
Re:Xz: Can you spot the single character that disabled Linux... by Terr_ on Saturday March 30, 2024 @11:18PM (#39881073)
For those squinting, the "landlock" regular "c" is replaced with a Cyrillic U+0441.
Re:Xz: Can you spot the single character that disabled Linux... by SV_BubbleTime on Saturday March 30, 2024 @11:57PM (#39881276)
Is there a GCC option to error on non-standard English characters?
Re:Xz: Can you spot the single character that disabled Linux... by Terr_ on Sunday March 31, 2024 @12:15AM (#39881382)
Disclosure: I've got zero C/C++ on my resume. I was asked to diagnose a kernel panic and backport kernel security patches once, but it was very uncomfortable. ("Hey, Terr knows the build system, get him to do it...") That said, perhaps something like disabling the default -fextended-identifiers [0], and enabling the -Wbidi-chars [1] warning.

[0] https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html...

[1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#inde...

Re:Xz: Can you spot the single character that disabled Linux... by pajko on Sunday March 31, 2024 @06:10AM (#39882921)
Cool, the latter was added to fix CVE-2021-42574: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103026
Re:Xz: Can you spot the single character that disabled Linux... by masklinn on Sunday March 31, 2024 @02:21AM (#39881906)
Error-ing is the point here and what the period achieved. It’s a feature detection snippet so if it fails to compile the feature is disabled.
Re:Xz: Can you spot the single character that disabled Linux... by rmast on Sunday March 31, 2024 @03:00AM (#39882056)
It seems like there should be a way to catch these types of “bugs” - some form of dynamic analysis tool that extracts the feature detection code snippets and tries to compile them; if they fail for something like a syntax error, flag it as a broken check.

Expanding macros on different OSes could complicate things though, and determining what flags to build the feature check code with — so perhaps filtering based on the type of error would be best done as part of the build system functionality for doing the feature checking.

Re:Xz: Can you spot the single character that disabled Linux... by masklinn on Sunday March 31, 2024 @03:20AM (#39882159)
> if they fail for something like a syntax error, flag it as a broken check.

A syntax error might be exactly what they’re looking for e.g. they’re feature testing a new bit of syntax or a compiler extension.

> so perhaps filtering based on the type of error would be best done as part of the build system functionality for doing the feature checking.

Which would require every compiler to have detailed, consistent, and machine-readable failure reporting.

Re:Xz: Can you spot the single character that disabled Linux... by humanrebar on Sunday March 31, 2024 @08:17AM (#39883580)
Universal support of SARIF by compilers would be most of that.
Re:Xz: Can you spot the single character that disabled Linux... by rmast on Sunday March 31, 2024 @10:59AM (#39884857)
At least for newer C++ standards it seems like there is decent support for feature test macros, which could reduce the need for a feature check involving compiling a snippet of test code to decide if a feature is available: https://en.cppreference.com/w/cpp/feature_test

Handling the output from several of the most recent GCC and Clang versions would probably cover the majority of cases, and add in MSVC for Windows. If the output isn’t from a recognized compiler or doesn’t match expectations, the only option is falling back to current behavior. Not ideal, but better than the current status quo…

Re:Xz: Can you spot the single character that disabled Linux... by estebank on Sunday March 31, 2024 @12:51PM (#39885840)
That would only work for projects that care only about current compilers, where C in general has more desire to support niche compilers.

A mitigation here would be to make result of autoconf only provide instructions for humans to change their build config, instead of doing it for them silently. The latter is an anti-pattern.

FWIW, the approach you propose is how the UI tests for rustc work, with checks for specific annotations on specific lines, but those have the benefit of being tied to a single implementation/version and modified in tandem with the app. Unless all compilers could be made to provide reasonable machine readable output for errors, doing that for this use case isn't workable.

Re:Xz: Can you spot the single character that disabled Linux... by humanrebar on Sunday March 31, 2024 @08:16AM (#39883575)
I'd prefer if the ecosystem standardized on some dependency management primitives so critical projects aren't expected to invent buggy and insecure hacks ("does this strong parse?") in order to accurately add dependencies.
Re:Xz: Can you spot the single character that disabled Linux... by rmast on Sunday March 31, 2024 @10:48AM (#39884762)
It would be interesting to see what the most common compile feature checks are for, and see what alternative ways could be used to make the same information available to a build system — it seems like any solution that requires libraries being updated to “export” information on the features they provide would have difficulties getting adoption (and not be backwards compatible with older versions of desired dependencies).
Re:Xz: Can you spot the single character that disabled Linux... by estebank on Sunday March 31, 2024 @12:45PM (#39885791)
From my experience looking at rust builds, Pareto applies here: most checks are trivial and used by a lot, and a handful are super complex and niche.
Re:Xz: Can you spot the single character that disabled Linux... by rurban on Sunday March 31, 2024 @03:35AM (#39882231)
Not yet. I was working on the standardization for C23, but this was postponed to C26, and has not much support. MSVC and SDCC liked it, CLANG and GC not so much.

Here is my bad variant of the feature, via confusables: https://github.com/rurban/gcc/tree/homoglyph-pr103027

The better variant would be to use my libu8ident, following UTR 39. I only did that for binutils.

Re:Xz: Can you spot the single character that disabled Linux... by fweimer on Sunday March 31, 2024 @04:34AM (#39882503)
The -fno-extended-identifiers option seems to do something in this area, but I don't know if it is sufficient. But it may block some characters which are used in standard English (for some values of standard).
Re:Xz: Can you spot the single character that disabled Linux... by account42 on Monday April 08, 2024 @09:23AM (#39969471)
> But it may block some characters which are used in standard English

So what? Source code was fine with ASCII for a long time, this push for unicode symbols is a recent endeavor and IMO a huge mistake not just because of the security impliciations.

Re:Xz: Can you spot the single character that disabled Linux... by pajko on Sunday March 31, 2024 @06:33AM (#39883018)
Probably the code review tools should be hardened as well, to indicate if extended identifiers had been introduced to a line where there wasn't any. That would help catching the replacement of a 'c' character with a Russian one.

Btw, the -fno-extended-identifiers compiler parameter gives an error if UTF-8 identifiers are used in the code: <source>:3:11: error: stray '\317' in program float <U+03C9><U+2083> = 0.5f;

Re:Xz: Can you spot the single character that disabled Linux... by Terr_ on Sunday March 31, 2024 @01:25PM (#39886124)
> Probably the code review tools should be hardened as well, to indicate if extended identifiers had been introduced to a line where there wasn't any.

Maybe in the future more languages/ tools will have the concept of per-project character sets, as opposed to trying to wrangle all possible Unicode ambiguity problems.

I suppose then the problem is how to permit exceptions when integrating with some library written in another (human) language.

Re:Xz: Can you spot the single character that disabled Linux... by account42 on Monday April 08, 2024 @09:20AM (#39969453)
Or we could just accept English as the lingua franca of computing and not try to support anything other than ASCII in source code (at least not outside string constants). That way not only do we eliminate a whole class of possible exploits but also widen the number of people who can understand the code and spot issues.
Re:Xz: Can you spot the single character that disabled Linux... by jcelerier on Sunday March 31, 2024 @07:20AM (#39883229)
I mean, GCC erroring is how the exploit works here. cmake tries to compile the source code: if it works then the feature is available, if it fails then the feature is not available. Forcing the build to fail is what the attacker wants.
Re:Xz: Can you spot the single character that disabled Linux... by patrakov on Sunday March 31, 2024 @10:25AM (#39884567)
Well - that would be exactly the point of the attacker. GCC errors out, and it does not matter whether this is because the intentionally typoed header does not exist or because non-English characters are not allowed. Errors encountered during compilation of test programs go to /dev/null anyway, as they are expected not to compile successfully on some systems - that's exactly the point of the test. So no, this option would not have helped.
Re:Xz: Can you spot the single character that disabled Linux... by ak39 on Sunday March 31, 2024 @08:18AM (#39883581)
Yip, this was impressive. Only a copy & paste into VSCode (Windows) revealed the rectangle around the "c" in the second line.

Impressive.

Re:Xz: Can you spot the single character that disabled Linux... by signa11 on Saturday March 30, 2024 @11:16PM (#39881065)
compiler would perhaps "see" it ?
Re:Xz: Can you spot the single character that disabled Linux... by josephg on Sunday March 31, 2024 @12:05AM (#39881334)
Sure; but so long as the compiler error is silently discarded (as it is here), the configure script will assume landlock isn't available and never use it.
Re:Xz: Can you spot the single character that disabled Linux... by smashed on Sunday March 31, 2024 @01:22AM (#39881677)
A misplaced punctuation has some plausible deniability. Like the author could say he was distracted and fat fingered nonsense, honest mistake.

A utf character from a language that has zero chance of being mapped to your programmer's keyboard in the middle of a code line, that would be obvious intentional tampering or at the very least raise some eyebrows.

Re:Xz: Can you spot the single character that disabled Linux... by yeputons on Sunday March 31, 2024 @04:44AM (#39882544)
> A utf character from a language that has zero chance of being mapped to your programmer's keyboard in the middle of a code line, that would be obvious intentional tampering or at the very least raise some eyebrows.

I accidentally get Cyrillic "с" in my code few times a year. It's on the same key as Latin "c", so if I switch keyboard layout, I don't notice until the compiler warns me. Easy to do if I switch between chats and coding. Now my habit is to always type a few characters in addition to "c" to check what layout I'm _really_ using.

Granted, it's easier with a one-letter variable called "c", but with longer names I can easily see myself not typing "c" the first time (e.g. not pressing hard enough), starting build, chatting in some windows, getting back, facepalming, "fixing" the error by adding "c" or "с" depending on my keyboard layout.

Re:Xz: Can you spot the single character that disabled Linux... by Bulat_Ziganshin on Sunday March 31, 2024 @05:29AM (#39882727)
even worse, I have Punto switcher that automatically switches language when I start typing. With default config, it changes latin c to russian one because russian language includes word "c" while it's non-sense in English.

and since it's the only Cyrillic character that's placed on the same key as the same-looking english character, I don't even see the problem with my eyes when the autoreplacement fires

Re:Xz: Can you spot the single character that disabled Linux... by skywhopper on Sunday March 31, 2024 @05:52AM (#39882834)
I mean, I agree that the punctuation mishap is a better cover story, but why would any particular language have “zero chance” of being mapped to the programmer’s keyboard?
Re:Xz: Can you spot the single character that disabled Linux... by deanishe on Sunday March 31, 2024 @09:50AM (#39884243)
> why would any particular language have “zero chance” of being mapped to the programmer’s keyboard?

You left out a very important qualifier: in the middle of a code line

The chances of someone accidentally fat-fingering a keyboard layout switch, typing one character, then switching back again without noticing while typing a line of code are very slight indeed.

Plus the fact that you'd need to speak a language written in that alphabet to have a plausible reason for having the keyboard layout enabled in the first place.

Re:Xz: Can you spot the single character that disabled Linux... by saagarjha on Sunday March 31, 2024 @12:33AM (#39881472)
Putting random Unicode confusables in source code would be far easier to consider malicious
Re:Xz: Can you spot the single character that disabled Linux... by mgaunard on Sunday March 31, 2024 @07:05AM (#39883165)
Except many people have a policy of ASCII only in source code and therefore would catch it immediately.
Re:Xz: Can you spot the single character that disabled Linux... by dathinab on Sunday March 31, 2024 @04:46AM (#39882552)
After the concept of such attacks had blow up idk. 1?2?3? years ago a lot of places now warn at least when mixing "languages"/ranges or sometimes on any usage of non us-ascii printable characters.

So stuff like that is increasingly more reliable caught.

Including by 3rd parties doing any ad-hoc scanning.

Through adding `compiles check` fail with syntax errors definitely should be added tot he list of auto scan checks, at least in C/C++ (it's not something you would do in most languages tbh. even in C it seems to be an antipatters).

Re:Xz: Can you spot the single character that disabled Linux... by Etheryte on Sunday March 31, 2024 @07:57AM (#39883450)
Nearly every modern IDE and diff viewer instantly highlights this though? I doubt this would get far.
Re:Xz: Can you spot the single character that disabled Linux... by kaashif on Sunday March 31, 2024 @10:09AM (#39884429)
With the . the author can claim it was unintentional. It's impossible (or at least very hard) to claim the Cyrillic c is unintentional.

To me, that makes the . more evil.

Re:Xz: Can you spot the single character that disabled Linux... by cocoa19 on Sunday March 31, 2024 @11:44AM (#39885269)
Plausible deniability
Re:Xz: Can you spot the single character that disabled Linux... by itsTyrion on Wednesday April 03, 2024 @05:21PM (#39923341)
also applies for c/с - the с (Cyrillic s) is on the same key as the Latin c on a Russian keyboard. bottom row starts with zxc/ячс respectively.
Re:Xz: Can you spot the single character that disabled Linux... by patrakov on Sunday March 31, 2024 @10:16AM (#39884490)
Well, on Russian keyboards, they are on the same key.
Re:Xz: Can you spot the single character that disabled Linux... by kaashif on Sunday March 31, 2024 @01:44PM (#39886286)
Good point - it might be plausible if the author actually were Russian, but they aren't.
Re:Xz: Can you spot the single character that disabled Linux... by dilyevsky on Sunday March 31, 2024 @05:23PM (#39888185)
Or are they?
Re:Xz: Can you spot the single character that disabled Linux... by account42 on Monday April 08, 2024 @09:27AM (#39969505)
Even someone provably not russian can just claim that they were learning the language (or a different one that also uses cyrillic).
Re:Xz: Can you spot the single character that disabled Linux... by bschwindHN on Monday April 01, 2024 @09:16AM (#39893855)
Another point where I appreciate the Rust compiler:

    warning: the usage of Script Group `Cyrillic` in this crate consists solely of mixed script confusables
     --> src/lib.rs:1:4
      |
    1 | fn SYS_landloсk_create_ruleset() {
      |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = note: the usage includes 'с' (U+0441)
      = note: please recheck to make sure their usages are indeed what you want
      = note: `#[warn(mixed_script_confusables)]` on by default

https://play.rust-lang.org/?version=stable&mode=debug&editio...
Re:Xz: Can you spot the single character that disabled Linux... by nebulous1 on Tuesday April 02, 2024 @11:36AM (#39906975)
The character was in a string, not directly in what was being compiled. The contents of the string failing to compile was the point, as landlock was then disabled.

From what I understand, this landlock disabling wasn't relevant to the sshd attack. It appears it was setting up for something else.

Re:Xz: Can you spot the single character that disabled Linux... by dathinab on Sunday March 31, 2024 @04:41AM (#39882532)
It's also iffy tbh. that the compilation check functionality:

- doesn't force users to differentiate between syntax errors and other errors (e.g. symbols not found). Partially you can't even make it work properly if you want due to C macros.

- it seems sensible, tbh. if "does compile" checks for compatibility seems sensible then there is so much wrong with the ecosystem in so many ways

Re:Xz: Can you spot the single character that disabled Linux... by mysidia on Sunday March 31, 2024 @05:50AM (#39882824)
It's standard autoconf stuff, BUT... the right thing to do for a security option should be to throw an error at the configure stage If the Option is requested but can't be supported, And not to silently turn it off.

That is because a human should have to Look at the build and manually make the decision to switch off a security feature from the build.

Re:Xz: Can you spot the single character that disabled Linux... by lazide on Sunday March 31, 2024 @10:15AM (#39884480)
Autocomf output is so incredibly noisy though, still long odds someone would notice anytime soon.
Re:Xz: Can you spot the single character that disabled Linux... by dullcrisp on Sunday March 31, 2024 @01:35PM (#39886202)
If you break the build they’ll notice
Re:Xz: Can you spot the single character that disabled Linux... by lazide on Sunday March 31, 2024 @02:10PM (#39886550)
Good thing they disabled the check that would have broken the build/tests in this case eh?
Re:Xz: Can you spot the single character that disabled Linux... by BenFrantzDale on Sunday March 31, 2024 @03:39PM (#39887345)
Agreed. I just opened https://gitlab.kitware.com/cmake/cmake/-/issues/25846 although I have no idea how hard it is to address this sort of issue robustly.
Re:Xz: Can you spot the single character that disabled Linux... by kevincox on Sunday March 31, 2024 @11:05AM (#39884905)
It also shows how brittle these sorts of checks are in general. I really think that this auto-disable of features based on compilation was a big mistake. It is not only very annoying when packaging things (Why does feature X not work? Because you forgot to include libY in the build environment of course) but they also fail silently even if intended. While this `.` was almost certainly malicious it is easy to imagine an accidental break. Maybe a minor typo or `-Werror`is enabled any one of these functions was marked as must use or something similar.

It seems like it is infinitely better to have a default set of features and explicitly require the user to say `--enable-x --disable-y` as needed. Then error out if a required library isn't available. (Preferably saying which feature requires it.)

Re:Xz: Can you spot the single character that disabled Linux... by TsiCClawOfLight on Tuesday April 02, 2024 @04:04AM (#39903369)
This is what the cargo/rust ecosystem does :)