inotify: fix watch count leak when fsnotify_add_inode_mark_locked() fails
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 1cce1eea0aff51201753fcaca421df825b0813b6 · < fdaa42ca370d056428e5e171247c8fdce8dff36a| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
inotify: fix watch count leak when fsnotify_add_inode_mark_locked() fails
When fsnotify_add_inode_mark_locked() fails in inotify_new_watch(), the error path calls inotify_remove_from_idr() but does not call dec_inotify_watches() to undo the preceding inc_inotify_watches(). This leaks a watch count, and repeated failures can exhaust the max_user_watches limit with -ENOSPC even when no watches are active.
Prior to commit 1cce1eea0aff ("inotify: Convert to using per-namespace limits"), the watch count was incremented after fsnotify_add_mark_locked() succeeded, so this path was not affected. The conversion moved inc_inotify_watches() before the mark insertion without adding the corresponding rollback.
Add the missing dec_inotify_watches() call in the error path.
From the CVE record · Linux
The Linux kernel's inotify code can leak a watch count when adding an inode mark fails. A local user who repeatedly triggers this failure can exhaust the max_user_watches limit, causing new watch requests to fail with ENOSPC even when no watches are active.
Operators running Linux kernels with the affected inotify watch-count behavior should check their kernel vendor's advisory; affected versions were not specified.