diff options
| author | Aldo Ariel Panzardo <qwe.aldo@gmail.com> | 2026-09-21 12:19:39 -0300 |
|---|---|---|
| committer | Viacheslav Dubeyko <slava@dubeyko.com> | 2026-09-22 14:49:30 -0700 |
| commit | 2cb947450e0e5a88bb6bb5fca6dbfda1910e74b0 (patch) | |
| tree | 77ec1a6b8597f14c4a53055a0f987af71e1c05fb /tools/perf/scripts/python | |
| parent | 081653dbead3aa92f9f3bf303ed9c71b35484c85 (diff) | |
| download | linux-2cb947450e0e5a88bb6bb5fca6dbfda1910e74b0.tar.gz linux-2cb947450e0e5a88bb6bb5fca6dbfda1910e74b0.zip | |
nilfs2: fix checkpoint root lifetime on sysfs errors
nilfs_find_or_create_root() links a new checkpoint root into the
checkpoint tree and drops ns_cptree_lock before creating the root's
sysfs group. If nilfs_sysfs_create_snapshot_group() then fails, the
root is freed while it is still reachable from ns_cptree, so a
concurrent nilfs_lookup_root() can dereference freed memory.
nilfs_sysfs_create_snapshot_group() allocates memory and creates sysfs
nodes and may sleep, so it cannot run under the ns_cptree_lock spinlock.
Reorder the creation path so that the sysfs group is set up before the
root is published: initialize the root, create its sysfs group outside
the lock, and only then take ns_cptree_lock to link it into the tree.
On sysfs failure the root was never visible and is freed directly; in
the unlikely case a root with the same checkpoint number is already
present, the sysfs group of the new root is removed before it is freed.
Concurrent insertions are already serialized by ns_snapshot_mount_mutex,
so only the race against nilfs_lookup_root() needs to be closed.
Because kobject_put() does not guarantee that the embedded kobject's
release callback has run by the time it returns
(CONFIG_DEBUG_KOBJECT_RELEASE defers it), the container must not be
freed until the release completes. Keep that wait_for_completion() of
snapshot_kobj_unregister inside the sysfs helpers, so both the creation
error path and nilfs_sysfs_delete_snapshot_group() wait for the release
before their callers free the root.
Fixes: dd70edbde262 ("nilfs2: integrate sysfs support into driver")
Cc: stable@vger.kernel.org
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
