CVE-2021-47043 - Linux Kernel's Media Venus Core Resource Leaks and Fixes involving 'venus_probe()'

A recent Linux kernel vulnerability, identified as CVE-2021-47043, has been discovered and resolved, involving resource leaks in the media: venus: core code. The vulnerability was specifically found in the 'venus_probe()' function error path. In this post, we will discuss the vulnerability, provide a code snippet demonstrating the issue and the fix, and offer references to the original sources.

Vulnerability Details

The vulnerability in question is related to the proper handling of resource leaks if an error occurs following a successful 'of_icc_get()' function call within the 'venus_probe()' function. The function 'of_icc_get()' is used for acquiring interconnect constraints bindings in the Linux kernel. To prevent the resource leak, the solution implemented makes use of 'devm_of_icc_get()' instead of 'of_icc_get()'. Furthermore, the remove function is updated, and the unnecessary 'icc_put()' calls are removed.

The following code snippet demonstrates the original error which resulted in resource leaks

static int venus_probe(struct platform_device *pdev)
{
    ...
    venus->core_icc_path = of_icc_get(pdev->dev.of_node, "core");
    if (IS_ERR(venus->core_icc_path)) {
        ret = PTR_ERR(venus->core_icc_path);
        goto err_put_icc;
    }
    ...
err_put_icc:
    icc_put(venus->vcodec_icc_path);
err_icc_remove:
    icc_put(venus->core_icc_path);
    ...
}

To resolve the vulnerability, the code was modified, replacing the 'of_icc_get()' call with 'devm_of_icc_get()' to prevent resource leaks. The updated code snippet with the fix:

static int venus_probe(struct platform_device *pdev)
{
    ...
    venus->core_icc_path = devm_of_icc_get(&pdev->dev, "core");
    if (IS_ERR(venus->core_icc_path)) {
        ret = PTR_ERR(venus->core_icc_path);
        goto err_put_icc;
    }
    ...
err_put_icc:
    // No need for icc_put() calls here, as they are now handled by devm
    ...
}

References

You can find more information regarding this vulnerability, its resolution, and the related code changes in the Linux kernel source code repositories and additional references.

1. Linux kernel source code repository: Link
2. Commit with the implemented fix: Link
3. CVE-2021-47043 on the National Vulnerability Database (NVD): Link

Conclusion

The CVE-2021-47043 vulnerability involving resource leaks in the Linux kernel's 'venus_probe()' function has been resolved, providing a more robust and reliable code for Linux kernel-based systems. Users and developers are advised to check the original references for updated information and apply the necessary fixes as needed to ensure a secure environment.

Timeline

Published on: 02/28/2024 09:15:40 UTC
Last modified on: 12/19/2024 07:34:10 UTC