
Linus Torvalds continues with his recent uptick in kernel patches himself, assisted in part by AI with Claude Code. Merged today was removing the historical and unsafe __get_user() and __put_user() kernel functions.
Linus Torvalds merged his code branch removing the __get_user() and __put_user() functions inside the Linux kernel. These functions are the faster but less safe versions of get_user() and set_user() due to less safety checking. The __get_user() / get_user() function is used for copying a single simple variable from user-space to kernel-space while __put_user() / put_user() is used for writing a single variable from kernel space to user-space. The versions removed lack pointer validation checks making them unsafe. Linus describes their removal in the Git merge as:
"This is long over-due: the __get_user() and __put_user() functions are entirely historical, and are never the [right] thing to use any more. And when mis-used (read: every case) they are not only slower than the right thing, but also insecure because they don't check the user address range.Most of the usage sites have been converted long ago, but various left-overs remained. So this started out as a single patch that I wrote as a "show people how to convert __{get,put}_user() to modern code".
In particular, Thomas last year implemented the very nice new scoped user access region helpers (see commit e497310b4ffb: "uaccess: Provide scoped user access regions") that makes the modern interfaces particularly easy to use and really removes any excuse for the old horrors."
In the Git merge, Torvalds went on to describe the issues and horrors of __get_user() and __put_user().
The functions are removed from all the generic Linux kernel code and completes the final removal of the whole interface for x86/x86_64. There are remnants remaining in some of the other CPU architecture ports due to some non-trivial cases or like ARM64 having their functions already map to get_user() and put_user().
For those wondering about Linus Torvalds' AI coding or not given his work last week with using AI to decipher bugs and working on a nice performance improvement with Claude Code, this __get_user() and __put_user() removal did see some AI activity. Torvalds remarked on the on the mailing list that he was using Claude as a fancy sort of Coccinelle script, which is used for static analysis and source-to-source transformations.