{"id":"CVE-2024-36899","summary":"gpiolib: cdev: Fix use after free in lineinfo_changed_notify","details":"In the Linux kernel, the following vulnerability has been resolved:\n\ngpiolib: cdev: Fix use after free in lineinfo_changed_notify\n\nThe use-after-free issue occurs as follows: when the GPIO chip device file\nis being closed by invoking gpio_chrdev_release(), watched_lines is freed\nby bitmap_free(), but the unregistration of lineinfo_changed_nb notifier\nchain failed due to waiting write rwsem. Additionally, one of the GPIO\nchip's lines is also in the release process and holds the notifier chain's\nread rwsem. Consequently, a race condition leads to the use-after-free of\nwatched_lines.\n\nHere is the typical stack when issue happened:\n\n[free]\ngpio_chrdev_release()\n  --\u003e bitmap_free(cdev-\u003ewatched_lines)                  \u003c-- freed\n  --\u003e blocking_notifier_chain_unregister()\n    --\u003e down_write(&nh-\u003erwsem)                          \u003c-- waiting rwsem\n          --\u003e __down_write_common()\n            --\u003e rwsem_down_write_slowpath()\n                  --\u003e schedule_preempt_disabled()\n                    --\u003e schedule()\n\n[use]\nst54spi_gpio_dev_release()\n  --\u003e gpio_free()\n    --\u003e gpiod_free()\n      --\u003e gpiod_free_commit()\n        --\u003e gpiod_line_state_notify()\n          --\u003e blocking_notifier_call_chain()\n            --\u003e down_read(&nh-\u003erwsem);                  \u003c-- held rwsem\n            --\u003e notifier_call_chain()\n              --\u003e lineinfo_changed_notify()\n                --\u003e test_bit(xxxx, cdev-\u003ewatched_lines) \u003c-- use after free\n\nThe side effect of the use-after-free issue is that a GPIO line event is\nbeing generated for userspace where it shouldn't. However, since the chrdev\nis being closed, userspace won't have the chance to read that event anyway.\n\nTo fix the issue, call the bitmap_free() function after the unregistration\nof lineinfo_changed_nb notifier chain.","modified":"2026-04-02T12:16:33.268914Z","published":"2024-05-30T15:29:02.591Z","related":["ALSA-2024:6997","MGASA-2024-0263","MGASA-2024-0266","SUSE-SU-2024:2372-1","SUSE-SU-2024:2385-1","SUSE-SU-2024:2394-1","SUSE-SU-2024:2495-1","SUSE-SU-2024:2571-1","SUSE-SU-2024:2896-1","SUSE-SU-2024:2939-1","SUSE-SU-2024:2973-1","SUSE-SU-2024:3623-1","SUSE-SU-2024:3624-1","SUSE-SU-2024:3625-1","SUSE-SU-2024:3628-1","SUSE-SU-2024:3631-1","SUSE-SU-2024:3632-1","SUSE-SU-2024:3635-1","SUSE-SU-2024:3636-1","SUSE-SU-2024:3638-1","SUSE-SU-2024:3639-1","SUSE-SU-2024:3643-1","SUSE-SU-2024:3655-1","SUSE-SU-2024:3666-1","SUSE-SU-2024:3670-1","SUSE-SU-2024:3672-1","SUSE-SU-2024:3679-1","SUSE-SU-2024:3680-1","SUSE-SU-2024:3694-1","SUSE-SU-2024:3695-1","SUSE-SU-2024:3696-1","SUSE-SU-2024:3697-1","SUSE-SU-2024:3700-1","SUSE-SU-2024:3701-1","SUSE-SU-2024:3702-1","SUSE-SU-2024:3706-1","SUSE-SU-2024:3710-1","SUSE-SU-2024:3780-1","SUSE-SU-2024:3793-1","SUSE-SU-2024:3806-1","SUSE-SU-2024:3815-1","SUSE-SU-2024:3829-1","SUSE-SU-2024:3830-1","SUSE-SU-2024:3831-1","SUSE-SU-2024:3833-1","SUSE-SU-2024:3837-1","SUSE-SU-2024:3840-1","SUSE-SU-2024:3842-1","SUSE-SU-2024:3851-1","SUSE-SU-2024:3852-1","SUSE-SU-2024:3855-1","SUSE-SU-2024:3857-1","SUSE-SU-2024:3860-1","SUSE-SU-2024:3880-1","SUSE-SU-2024:3881-1","SUSE-SU-2024:4122-1","SUSE-SU-2024:4123-1","SUSE-SU-2024:4124-1","SUSE-SU-2024:4125-1","SUSE-SU-2024:4127-1","SUSE-SU-2024:4207-1","SUSE-SU-2024:4208-1","SUSE-SU-2024:4214-1","SUSE-SU-2024:4216-1","SUSE-SU-2024:4218-1","SUSE-SU-2024:4228-1","SUSE-SU-2024:4234-1","SUSE-SU-2024:4235-1","SUSE-SU-2024:4236-1","SUSE-SU-2024:4243-1","SUSE-SU-2024:4266-1","SUSE-SU-2024:4275-1","SUSE-SU-2025:0107-1","SUSE-SU-2025:0109-1","SUSE-SU-2025:0110-1","SUSE-SU-2025:0114-1","SUSE-SU-2025:0115-1","SUSE-SU-2025:0124-1","SUSE-SU-2025:0138-1","SUSE-SU-2025:0146-1","SUSE-SU-2025:0150-1","SUSE-SU-2025:0158-1","SUSE-SU-2025:0164-1","SUSE-SU-2025:0187-1","SUSE-SU-2025:0248-1","SUSE-SU-2025:0249-1","SUSE-SU-2025:0251-1","SUSE-SU-2025:0252-1","SUSE-SU-2025:0253-1","SUSE-SU-2025:0254-1","SUSE-SU-2025:0255-1","SUSE-SU-2025:0260-1","SUSE-SU-2025:0261-1","SUSE-SU-2025:0264-1","SUSE-SU-2025:0266-1","SUSE-SU-2025:20008-1","SUSE-SU-2025:20028-1"],"database_specific":{"cna_assigner":"Linux","osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/36xxx/CVE-2024-36899.json"},"references":[{"type":"WEB","url":"https://git.kernel.org/stable/c/02f6b0e1ec7e0e7d059dddc893645816552039da"},{"type":"WEB","url":"https://git.kernel.org/stable/c/2d008d4961b039d2edce8976289773961b7e5fb5"},{"type":"WEB","url":"https://git.kernel.org/stable/c/2dfbb920a89bdc58087672ad5325dc6c588b6860"},{"type":"WEB","url":"https://git.kernel.org/stable/c/95ca7c90eaf5ea8a8460536535101e3e81160e2a"},{"type":"WEB","url":"https://git.kernel.org/stable/c/ca710b5f40b8b16fdcad50bebd47f50e4c62d239"},{"type":"WEB","url":"https://git.kernel.org/stable/c/d38c49f7bdf14381270736299e2ff68ec248a017"},{"type":"WEB","url":"https://lists.debian.org/debian-lts-announce/2025/03/msg00001.html"},{"type":"WEB","url":"https://lists.debian.org/debian-lts-announce/2025/03/msg00002.html"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/36xxx/CVE-2024-36899.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-36899"},{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"51c1064e82e77b39a49889287ca50709303e2f26"},{"fixed":"2dfbb920a89bdc58087672ad5325dc6c588b6860"},{"fixed":"2d008d4961b039d2edce8976289773961b7e5fb5"},{"fixed":"d38c49f7bdf14381270736299e2ff68ec248a017"},{"fixed":"95ca7c90eaf5ea8a8460536535101e3e81160e2a"},{"fixed":"ca710b5f40b8b16fdcad50bebd47f50e4c62d239"},{"fixed":"02f6b0e1ec7e0e7d059dddc893645816552039da"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-36899.json"}}],"schema_version":"1.7.5"}