[PATCH bpf] bpf, lsm: Mark backing_file_alloc/free LSM hooks as untrusted

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Nov 11 21:02:58 UTC 2026


> The backing_file_alloc and backing_file_free LSM hooks get the backing
> file as "struct file *backing_file", but its f_path is not populated
> while they run:
> 
>  - security_backing_file_alloc() is called from init_backing_file() in
>    alloc_empty_backing_file(), before vfs_open() sets f_path, so
>    backing_file->f_path.dentry is NULL;
>  - security_backing_file_free() can run for a backing file whose open
>    failed and whose f_path was already cleared.
> 
> Neither hook is listed in untrusted_lsm_hooks, so bpf_lsm_is_trusted()
> lets BPF LSM programs use the argument as a trusted pointer.  A program
> attached to lsm/backing_file_alloc can pass &backing_file->f_path to the
> trusted-args kfunc bpf_path_d_path(), and d_path() dereferences the NULL
> dentry on the first open of a file on overlayfs:
> [ ... ]
> 
> Fixes: 6af36aeb147a ("lsm: add backing_file LSM hooks")
> Cc: stable at vger.kernel.org
> Assisted-by: Claude:claude-fable-5-2
> Signed-off-by: Sergei Nizovtsev <snizovtsev at cloudlinux.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261111203614.1221188-1-snizovtsev@cloudlinux.com?part=1




More information about the Linux-security-module-archive mailing list