CVE-2020-36775: Resolving f2fs Deadlock Issues in the Linux Kernel

In the world of Linux kernel development, the f2fs (Flash-Friendly File System) has been a popular file system choice for flash-based storage devices like SSDs and SD cards. As the kernel continues to evolve with newer versions and code enhancements, it is not uncommon for developers and researchers to find and fix vulnerabilities, making the kernel more secure and reliable.

Recently, a notable vulnerability, CVE-2020-36775, was identified and addressed in the Linux kernel concerning the f2fs file system. This vulnerability involves a potential deadlock situation occurring during the write process in the file system.

Deadlocks are a problem in multi-threaded programs where two or more threads are involved in lock conflicts, leading to an unresolvable situation. Each thread holds a lock and requests another lock held by another thread, unable to proceed until the other lock is available, causing the system to hang indefinitely.

This article will cover the identified vulnerability, the code snippets where the issue was situated, links to original references, and details about the exploit.

Vulnerability

The CVE-2020-36775 vulnerability affected the f2fs_write_compressed_pages() function in the f2fs file system. The issue arises due to a deadlock scenario involving the f2fs_trylock_op() function call, which is responsible for locking critical sections in the code. This flaw could have been exploited by an attacker to trigger a deadlock in the system and cause it to hang.

Solution

To resolve this issue, developers implemented the use of f2fs_trylock_op() in the f2fs_write_compressed_pages() function, avoiding the potential deadlock. This solution was inspired by another function - f2fs_write_single_data_page() - where a similar problem was addressed.

Before

...
static void f2fs_write_compressed_pages(struct compressed_page *head) {
...
    mutex_lock(&sbi->writepages);
...
}
...

After

...
static void f2fs_write_compressed_pages(struct compressed_page *head) {
...
    if (!f2fs_trylock_op(sbi))
        return;
    mutex_lock(&sbi->writepages);
...
    mutex_unlock(&sbi->writepages);
    f2fs_unlock_op(sbi);
}
...

By implementing this solution, developers ensure that the f2fs file system can now avoid the deadlock scenario in the write process, making it more reliable for usage in Linux systems.

References

To have a deeper understanding of the f2fs file system and the changes implemented to fix the deadlock vulnerability, please refer to the following resources:

1. Original commit addressing the vulnerability: https://github.com/torvalds/linux/commit/7ea9e592853166fe4db695decffe07fb582ab5b
2. CVE-2020-36775 in the National Vulnerability Database: https://nvd.nist.gov/vuln/detail/CVE-2020-36775
3. Documentation for the f2fs file system: https://www.kernel.org/doc/html/latest/filesystems/f2fs.html

Conclusion

The Linux kernel development community is continuously working to address and resolve vulnerabilities like CVE-2020-36775 to ensure the kernel remains secure and stable. By understanding and applying these fixes, we contribute to a more robust and reliable computing ecosystem.

It is essential to stay up to date on security patches and frequently update your systems to maintain their protection against potential exploits.

Timeline

Published on: 02/26/2024 18:15:07 UTC
Last modified on: 04/17/2024 17:32:18 UTC