Linux 7.2 Removes String-Copying Function Strncpy After Six-Year Cleanup
Linux 7.2 Removes String-Copying Function Strncpy After Six-Year Cleanup
https://winbuzzer.com/2026/06/23/linux-72-removes-kernel-side-strncpy-after-six-year-cleanup-xcxwbn/
Publish Date: 2026-06-23 10:46:00
Source Domain: winbuzzer.com
TL;DR
- Kernel-Side Removal: Linux 7.2’s June 20 kernel merge has removed strncpy from kernel code.
- Cleanup Scale: The cleanup took about six years and more than 360 patches because calls blurred termination, padding, and raw-copy intent.
- Developer Impact: Developers now choose strscpy, strscpy_pad, strtomem_pad, memcpy_and_pad, or memcpy based on destination behavior.
- Migration Risk: Out-of-tree drivers and embedded platforms may need checks when existing string-copy assumptions surface.
Linux kernel maintainers released a June 20 Linux 7.2 merge that removes the legacy C string-copy function strncpy from kernel code. Kernel-side is the key scope: strncpy remains part of user-space C libraries and general C programming, but the Linux kernel no longer treats it as an in-tree application programming interface, or API, for string copying.
More than 360 patches across roughly six years turned a small-looking API deletion into a maintenance milestone. The merge removed the strncpy API from the kernel and moved former callers to safer alternatives. Old strncpy calls blurred whether code wanted a terminated string, a padded fixed-width field, or a raw memory copy, so the removal gives a clearer signal about what each call site is supposed to do.
What Changed Inside the Kernel
strncpy copies a fixed number of bytes. In kernel code, the awkward part was not the copy alone but the rules around the end of a string. A C string normally ends with a NUL terminator, the zero byte that marks where the string stops; when a source string was equal to or longer than the chosen size, strncpy could omit a NUL terminator, allowing later reads past the intended buffer.
Because strncpy also padded destinations with zero bytes even when padding was not the goal, kernel documentation tied that combination to ambiguous intent. A strncpy call might be building a string, filling a fixed-width character array, or copying known-length memory. Linus Torvalds called the old interface…