News for hackers. Stuff that matters.
Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by Hello71 on Saturday October 05, 2019 @09:05PM (#21169102)
it's fairly well known that small kmallocs do not fail, and that there are many, many instances in the filesystem code which assume that small kmallocs do not fail. there have been two LWN articles on this exact subject.
Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by girvo on Saturday October 05, 2019 @09:14PM (#21169147)
And goto being used for error handling is pretty stock standard across most C codebases I’ve worked on or seen over the years, so I’m not sure what the particular gripe is there
Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by telanis on Saturday October 05, 2019 @09:26PM (#21169205)
Since when is "we do it all the time" the same as "it's a good thing"?
Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by nothrabannosir on Saturday October 05, 2019 @10:20PM (#21169404)
goto for error handling is not just "freeform anything goes goto". It's a very specific idiom, being an "error" label and a bunch of "if (resource) free(resource)" statements at the end of the function. It is essentially analogous to a common use case of Go's defer. Typically an accepted pattern when dealing with many resources and possible exit points. Prevalent in I/O heavy code.

Different ballgame from the subject of Dijkstra's manifesto.

Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by josteink on Sunday October 06, 2019 @05:25AM (#21170841)
> It is essentially analogous to a common use case of Go

Go, which is also known for its terrible error-handling.

Great.

Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by neop1x on Monday October 07, 2019 @05:26AM (#21178895)
Really? I have never seen a Go program to misbehave while not printing some meaningful output. It is possible but almost no one ignores the error parameter. Yet I have seen many, many Java and Python software which quit after the first Unhandled Exception. So often that I consider exceptions as the bad error handling mechanism.
Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by cjbprime on Saturday October 05, 2019 @11:39PM (#21169682)
It's both common and a good idea, when used purely internally to a function in order to redirect error paths to a standard set of cleanup code. It helps prevents memory errors and other problems.

This is the sense in which the Linux kernel uses goto.

Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by tmd83 on Saturday October 05, 2019 @11:45PM (#21169701)
I'm not experienced in C or kernel code but from my understanding they use it almost entirely like a catch/finally clause of many higher level language which is a widely accepted and successful pattern.
Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by kevin_thibedeau on Saturday October 05, 2019 @10:59PM (#21169534)
Properly used goto is essentially an inline exception handler. That is a good thing to eliminate repetitive fault checks and fragile cleanup code.
Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by __s on Saturday October 05, 2019 @09:47PM (#21169294)
Since when are standard practices the same as "it's a good thing"?

Well written code is the best code. Some well written code uses goto. Some not well written code doesn't use goto

Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by jumpingmice on Saturday October 05, 2019 @09:23PM (#21169196)
Yeah that’s the rumor but allocations of any size can fail when kmem cgroup accounting is enabled and the container is out of space.
Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by jnurmine on Sunday October 06, 2019 @09:32AM (#21171905)
Well, if the allocation is done with GFP_ACCOUNT bit set, i.e. kmemcg accounting enabled, isn't that the intended behaviour that the allocation can fail?
Re:Google, Xiaomi, and Huawei affected by zero-day flaw that... by jumpingmice on Sunday October 06, 2019 @12:13PM (#21172891)
Yes that is the point. In the relatively rare case of failure this particular function uses a goto to return without releasing a held mutex. Error paths within the kernel are a rich vein of malfunction.