diff options
| author | Matt Bobrowski <mattbobrowski@google.com> | 2026-04-30 07:38:36 +0000 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-05-11 11:23:00 +0200 |
| commit | 07410646f6ff1d23222f105ccab778957d401bbe (patch) | |
| tree | 81b52422a9faebc152d16cdf4ce1328490e2dbc5 /rust/kernel/alloc | |
| parent | 254f49634ee16a731174d2ae34bc50bd5f45e731 (diff) | |
bpf: fix crash in bpf_[set|remove]_dentry_xattr for negative dentriesrefs/merge-window/69e5cd1262043a6bfdd55693f1950119f50f0f77
bpf_set_dentry_xattr and bpf_remove_dentry_xattr BPF kfuncs attempt to
lock the inode of the supplied dentry without checking if it is
NULL. If a negative dentry is passed (e.g. from
security_inode_create), d_inode(dentry) returns NULL, and
inode_lock(inode) will cause a NULL pointer dereference.
Trivially fix this by adding a NULL check for inode before attempting
to lock it, returning -EINVAL if it is NULL.
Additionally, drop WARN_ON(!inode) in bpf_xattr_read_permission() and
bpf_xattr_write_permission(). These warnings could be triggered by
passing a negative dentry to bpf_get_dentry_xattr() or the _locked
variants of the xattr kfuncs, potentially causing a Denial of Service
on systems with panic_on_warn enabled. Instead, simply return -EINVAL.
Reported-by: Quan Sun <2022090917019@std.uestc.edu.cn>
Closes: https://lore.kernel.org/bpf/1587cbf4-1293-4e25-ad24-c970836a1686@std.uestc.edu.cn/
Fixes: 56467292794b ("bpf: fs/xattr: Add BPF kfuncs to set and remove xattrs")
Signed-off-by: Matt Bobrowski <mattbobrowski@google.com>
Link: https://patch.msgid.link/20260430073836.2894001-1-mattbobrowski@google.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'rust/kernel/alloc')
0 files changed, 0 insertions, 0 deletions
