The Linux Kernel Is Now VLA-Free: A Win For Security, Less Overhead and Better For Clang (phoronix.com)
With the in-development Linux 4.20 kernel, it is now effectively VLA-free. From a report: The variable-length arrays (VLAs) that can be convenient and part of the C99 standard but can have unintended consequences. VLAs allow for array lengths to be determined at run-time rather than compile time. The Linux kernel has long relied upon VLAs in different parts of the kernel -- including within structures -- but going on for months now (and years if counting the kernel Clang'ing efforts) has been to remove the usage of variable-length arrays within the kernel. The problems with them are:
1. Using variable-length arrays can add some minor run-time overhead to the code due to needing to determine the size of the array at run-time.
2. VLAs within structures is not supported by the LLVM Clang compiler and thus an issue for those wanting to build the kernel outside of GCC, Clang only supports the C99-style VLAs.
3. Arguably most importantly is there can be security implications from VLAs around the kernel's stack usage.
1. Using variable-length arrays can add some minor run-time overhead to the code due to needing to determine the size of the array at run-time.
2. VLAs within structures is not supported by the LLVM Clang compiler and thus an issue for those wanting to build the kernel outside of GCC, Clang only supports the C99-style VLAs.
3. Arguably most importantly is there can be security implications from VLAs around the kernel's stack usage.
VLAs within structures ... are not supported
Wut?
Flexible array members are part of the C standard:
6.7.2.1 Structure and union specifiers
18. As a special case, the last element of a structure with more than one named member may have an incomplete array type; this is called a flexible array member. In most situations, the flexible array member is ignored. In particular, the size of the structure is as if the flexible array member were omitted except that it may have more trailing padding than the omission would imply. However, when a . (or ->) operator has a left operand that is (a pointer to) a structure with a flexible array member and the right operand names that member, it behaves as if that member were replaced with the longest array (with the same element type) that would not make the structure larger than the object being accessed; the offset of the array shall remain that of the flexible array member, even if this would differ from that of the replacement array. If this array would have no elements, it behaves as if it had one element but the behavior is undefined if any attempt is made to access that element or to generate a pointer one past it.
Or maybe they're referring to something else?
However, it is not Code of Cancer-free.
Vla
"The Linux Kernel Is Now VLA-Free: "
It was already DDT-free, BPA-free and now also VLA-free, so it can be safely used at last?
YES!
The advantage of VLA is pushing items to it without knowing the max. capacity.
The risk of VLA-free is out of capacity, unknown max. capacity.
The stack is like VLA but for only 1 stack instead of many stacks as many VLAs.
Another example, the number of open files. I should not limit it to a small constant, by example, max. 1024 open files, but i need 1 million of open files (for P2P). With VLA it is more flexible under demand or needness.
Many current PCs are 64-bit and have much memory as 32 GB by example for preventing the bottleneck or the out of memory.
The first problem is that they can be dropped from future versions of GCC. They're not part of any standard, after all.
The second problem is that there are situations in which GCC isn't the most suitable compiler. You want to minimize hacks for each different compiler supported.
Security is a big thing, too. It's hard to audit fundamentally unpredictable code.
A major step forward.
It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
VLAs are an example of C becoming ever so slightly higher level. When the language does things under the hood without telling you it's just an invitation to bite you in the ass. Good purge.
I was thinking a different VLA and what the f*ck that had to do with the Linux kernel.
It must have been something you assimilated. . . .
I always knew GCC has better taste.
Klaang from Star Trek: http://memory-alpha.wikia.com/...
It helps with debugging too. Build with two unrelated compiler systems and bugs that don't stand out in one may stand out in the other. And I am talking run-time errors not compiler warnings.
Once we get rid of all the GNU'isms can we go back to simply calling it "Linux". ;-)
When Microsoft adds unique features to their C/C++ compiler, the open sores crowd complains about "proprietary extensions" and insists on "standards conformance".
When the Linux kernel depends on non-standard language extensions that only GCC implements, that's OK.
Your link may provide some links to interesting stories at Phoronix beyond what's posted in this Slashdot story: 1, 2, and 3. However, it would have been better to link directly to the Phoronix stories instead of your comments. Details are lacking in the Phoronix stories, such as why XArray was rejected for inclusion in the 4.19 branch. It is good to see improvements in the Linux kernel that result in cleaner and more secure code, like removing VLAs.
One criticism of Linux versus *BSD is that the *BSD kernel code is much cleaner and better written than many portions of the Linux kernel. Although it's good to see new features added to the Linux kernel, it's also very good to see efforts like this to clean up the existing code. For those who would say that *BSD code cleanliness comes at the expense of supporting newer hardware and features, there are also a lot more contributors (especially corporate contributors) to Linux than for the *BSDs.
By the way, this is the third time you've posted this comment. Even if your comment is on-topic, this is the third time you've posted the comment in this article. You have a tendency of doing this. Posting the same comment more than once makes any reports, by definition, redundant. The links are actually interesting, but you deserve your -1.
See, adopting a code of conduct is already undermining the foundations of the kernel.
Just memory addresses. *Foo could be one or a few or many. Pointer arithmetic.
So variable arrays feels odd.
If you did not like chasing down weird memory corruption problems then you would not be using C (or C++) in the first place.
It would have been trivial to add a little bit of sanity with syntax like
void foo(char buf[blen], int blen)
so a compiler could, in debug mode, check. But no, that would not be a hero's C. nor is variable length arrays.
Incidentally, C's lack of arrays is not efficient. E.g. it is the reason we need 64 bit pointers, namely that C can only address 4 gig in 32 bit pointers. Java can access 32 gig of memory with 32 bit pointers because mallocs are aligned, and 32 gig is more than enough for the vast majority of current applications, and likely to remain so for a long time to come. Doubling your pointer size with lots of zeros is expensive, it clogs caches etc.
See subject: Fastest things this machine understands IS a contiguous chunk of RAM array structure - linked lists "F" that up!
* I've heard it said "all things are array based" - bullshit. See above. Falls apart via pointer addresses all the FUCK all over. Does it work? Yes. Barely. It causes issues. These systems respond BEST to straight-up contiguous arrays in RAM.
Anything else? Bandaids (necessary but shitty).
FACT!
* You "F" memory up w/ enough pointer activity (especially w/ modern protective, yes good, mechanisms like ASRL)? It gets SLOPPY (just like a disk does fragmented - higher latency - imperceptible? BS - do it enough, it's HIGHLY perceptible).
Memmgt subsystem thrash (paging to disk = WORST latency).
APK
P.S.=> Good things coming for Linux goofs (me = one currently, BSD soon) offsetting SOME of it https://linux.slashdot.org/com... ... apk
The 4.20 kernel is gonna be "blazingly" fast. Sure to be popular in Canada and parts of the USA. 4.20 blaze it!
What an awful feature. Almost as bad as auto.
Holy shit! You're an alchemist and conjuror too?
ALL HAIL APK!!! Our new God has risen.
> Is it just me, or so other people think of Krang whenever they see the world "Clang"?
No, but I sometimes think of this: http://www.subutai.mn/clang.ph...
Remember what the doctor said!
Zing! What a great comeback. APK, you sure told that guy with your anonymous posts.
ZIP
P.S. => Grow a fucking pair you tremendous tool.
You're a BETTER programmer than I, quoted saying so below? WHERE'S PROOF OF WORK YOU DO EVEN /.ers LIKE & USE?
It's NOT!
"P.S. => I'm a much better programmer than APK, as has been proven." - by Anonymous Coward ZIP on Monday October 08, 2018 @11:27PM (#57449082)
FROM https://yro.slashdot.org/comme...
* I have DOZENS of /.ers saying they like & use my work - praising it & it's good effects on more speed, security, reliability & anonymity PLUS 100,000++ users of it worldwide - DO YOU??
HELL NO!
You also LIED trying to "take credit" for a SOLUTION to C++ string buffer overflow issues I SOLVED WAY BEFORE YOU https://tech.slashdot.org/comm... proof's right there scumbag punk you are.
I also shot you to pieces on your github LIE @ the root of all that too (yes that's you too scumbag) https://yro.slashdot.org/comme...
APK
P.S.=> CodeSigning you "praise" (I don't for GOOD REASONS & I use something better) can & HAS been STOLEN & ABUSED https://www.helpnetsecurity.co... MY METHOD CAN'T BE (upmodded +2 INTERESTING in CODING FOR DEFCON no less) https://it.slashdot.org/commen... ... apk
What the hell is APK? You're not talking about android app packages, right?
Trumpet a minor tech change that hardly anyone cares about, with negligible impact on users, and proclaim it a big win! This is everything that's wrong with Linux and the Linux culture, in a nutshell.
Just look at the proclaimed benefits of this change:
"1. Using variable-length arrays can add some minor run-time overhead to the code due to needing to determine the size of the array at run-time.
2. VLAs within structures is not supported by the LLVM Clang compiler and thus an issue for those wanting to build the kernel outside of GCC, Clang only supports the C99-style VLAs.
3. Arguably most importantly is there can be security implications from VLAs around the kernel's stack usage."
Words like "minor", "an issue" (but only outside of GCC), and "arguably" abound.
It's not that this change shouldn't have been made, and has some benefits. It's about what you choose to focus on. This is the ultimate in inside baseball, a tech issue that only programmers care about. Don't play up this sh*t! This entire announcement should have fallen into a news release phrase that reads like "and numerous technical improvements".
It's also not that Linux and Linux culture is "bad" or "wrong", it's about how it so quickly slips into navel-gazing about obscure internal matters. In the publishing business this is known as "burying the lede" and it is universally understood to be a Bad Thing. So why does Linux keep doing this? Even on /., this stuff is too trivial to matter.
Just so everyone knows Dr. Angelo is what Alexander Peter Kowalski has named the jar of mayonnaise he keeps forgetting to put in the refrigerator. His posts, like the one above, are a clear sign of his continuing untreated debilitating mental illness.
You also LIED trying to "take credit" for a SOLUTION to C++ string buffer overflow issues I SOLVED WAY BEFORE YOU https://tech.slashdot.org/comm... [slashdot.org] proof's right there scumbag punk you are.
You dumbass, that was in CUJ some 20 years ago. You didn't invent it. You're either a liar or a fool. Which is it?
ZIP