← Retour au blog
tech 21 June 2026

Linux Eliminates strncpy API After Six Years of Hard Work

After six years and over 360 patches, Linux 7.2 bids farewell to the strncpy API, a persistent source of bugs. Discover why this decision was crucial for kernel stability and performance.

Article inspired by the original source
Linux eliminates the strncpy API after six years of work, 360 patches ↗ www.phoronix.com

Introduction

The open-source software world is dynamic, constantly evolving to incorporate improvements in security, performance, and simplicity. The recent removal of the strncpy API from the Linux kernel exemplifies this ongoing evolution. After six years of hard work involving over 360 patches, this aging and problematic API has been definitively removed in version 7.2 of the kernel.

Why strncpy Was Problematic

The strncpy API has long been a thorn in the side of Linux developers. This function, designed to copy a specific number of bytes from a source to a destination, is notorious for its counterintuitive behaviors, particularly regarding NUL termination. Additionally, strncpy zero-fills the remainder of the destination after copying, leading to significant performance slowdowns.

Bugs and Vulnerabilities

The implementation of strncpy has been a persistent source of bugs. Incorrect NUL termination can lead to security vulnerabilities, particularly buffer overflows, which can be exploited by attackers to execute malicious code.

The Solution: Modern Alternatives

To replace strncpy, several alternatives have been adopted in the Linux kernel:

  • strscpy(): For destinations requiring NUL termination.
  • strscpy_pad(): For NUL-terminated destinations with zero-padding.
  • strtomem_pad(): For fixed-width fields without NUL termination.
  • memcpy_and_pad(): For bounded copies with explicit padding.
  • memcpy(): For known-length memory copies.

These alternatives are safer and more performant, eliminating termination issues and the performance costs associated with strncpy.

Impact on Kernel Development

The removal of strncpy is a crucial step in improving the quality of Linux kernel code. This move is part of a broader effort to make kernel development more secure and efficient.

Figures and Statistics

Removing strncpy required approximately 362 patches, affecting thousands of lines of code in the kernel. These changes were spread across multiple kernel releases, ensuring a smooth transition.

Conclusion

The elimination of the strncpy API marks a significant milestone for Linux, enhancing the kernel's robustness and performance. For developers and businesses relying on Linux, these improvements mean more secure and reliable systems.

Let's discuss your project in 15 minutes.

Linux strncpy kernel API removal software security
Deepthix newsletter · 100% AI · every Monday 8am

An AI agent reads tech for you.

Our AI agent scans ~200 sources per week and ships the best articles to your inbox Monday 8am. Free. One click to unsubscribe.

Visit the newsletter page →

Want to automate your operations?

Let's talk about your project in 15 minutes.

Book a call