diff options
| author | Cai Xinchen <caixinchen1@huawei.com> | 2026-07-07 08:06:15 +0000 |
|---|---|---|
| committer | Paul Moore <paul@paul-moore.com> | 2026-08-31 16:14:12 -0400 |
| commit | 3a84fc1a21577dbc8da7e4b6a49c9d8b07c07000 (patch) | |
| tree | 5a03dcebaf78e6f3d7a208058a81b46ee12fd683 /scripts/Makefile.thinlto | |
| parent | f3efc8d3567ba16d349410df9046fcfc367b4bda (diff) | |
| download | linux-next-3a84fc1a21577dbc8da7e4b6a49c9d8b07c07000.tar.gz linux-next-3a84fc1a21577dbc8da7e4b6a49c9d8b07c07000.zip | |
lsm: don't call security_backing_file_free() multiple times
I found the following path:
alloc_empty_backing-file
init_file(&ff->file, xxx)
-> file_ref_init(&f->f_ref, 1); // only 1
error = init_backing_file
-> security_backing_file_alloc
-> rc = call_int_hook(backing_file_alloc, ...)
if (unlikely(rc))
security_backing_file_free(backing_file); // first call
if (unlikely(error)) {
fput(&ff->file);
-> if (unlikely(file_ref_put(&file->f_ref))) // zero
__fput_deferred(file);
-> ____fput -> __fput -> file_free(file);
-> backing_file_free(backing_file(f));
-> security_backing_file_free(&ff->file); // second call
Currently, only SELinux has the lsm backing_file_alloc hook, and it always
return 0. When security_backing_file_free is called for the first time,
the blobs pointer is set to NULL. Therefore, double free will not occur in
the code.
Fixes: 6af36aeb147a ("lsm: add backing_file LSM hooks")
Signed-off-by: Cai Xinchen <caixinchen1@huawei.com>
[PM: subject line tweaks]
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
