Torvalds Removes Unsafe __get_user() and __put_user() From Linux 7.4
Translated by a model; the original is in Russian.
Linus Torvalds has merged his branch removing the historical __get_user() and __put_user() functions from the Linux 7.4 kernel. It continues his recent uptick in hands-on kernel work, part of which has been done with AI assistance.
The removed functions are the faster but less safe versions of get_user() and put_user(). The first pair copies a single simple variable from user-space into kernel-space; the second writes a single variable from kernel-space out to user-space. The crucial difference with the underscore variants is that they do not check the user address range — they lack pointer validation, which is exactly what makes them unsafe.
"Long over-due"
Torvalds does not mince words in the merge message. The functions, he writes, are "entirely historical" and "never the right thing to use any more." And when misused — which he bluntly calls "every case" — they are not only slower than the correct interface but insecure, since they skip the user address range check.
Most call sites were converted long ago, but leftovers remained. The effort began modestly as a single patch meant to "show people how to convert __{get,put}_user() to modern code." Torvalds singled out praise for the scoped user access region helpers landed last year by Thomas, which make the modern interfaces especially easy to use and, in his words, remove any excuse for the old horrors.
The functions are gone from all the generic kernel code, and the entire interface is now fully removed for x86/x86_64. Remnants persist in some other CPU architecture ports, either due to non-trivial cases or — as with ARM64 — because those functions already map to get_user() and put_user().
AI as a fancy Coccinelle
There was an AI dimension to the work as well. For those wondering about Torvalds' use of AI tooling — after last week's bug-hunting and a performance win done with Claude Code — this removal saw some AI activity too. On the mailing list Torvalds remarked that he used Claude as "a fancy sort of Coccinelle script," referring to the tool used for static analysis and source-to-source transformations.
Source: Phoronix
Comments
Sign in, to comment.