From: sashiko-bot@kernel.org
To: "Anton Protopopov" <a.s.protopopov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH v1 bpf-next 1/3] bpf: Let sleepable LSM programs attach to six more inode hooks
Date: Thu, 03 Dec 2026 13:54:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-247902@kernel.org> (raw)
In-Reply-To: <20261203134411.1092433-2-a.s.protopopov@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] bpf: deadlocks on iint->mutex via bpf_ima_inode_hash() on new
sleepable hooks
--
commit c74a8d22d2a0ea129adadaaf835239097c8412ae
Author: Anton Protopopov <a.s.protopopov@gmail.com>
bpf: Let sleepable LSM programs attach to six more inode hooks
This commit adds six inode LSM hooks to sleepable_lsm_hooks, adds three of
them to d_inode_locked_hooks for xattr setters, and blocks xattr setters on
inode_copy_up.
> diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c
> index 1e2acb7581e70..62303210dde91 100644
> --- a/kernel/bpf/bpf_lsm.c
> +++ b/kernel/bpf/bpf_lsm.c
> @@ -340,18 +340,24 @@ BTF_ID(func, bpf_lsm_file_open)
> BTF_ID(func, bpf_lsm_file_post_open)
> BTF_ID(func, bpf_lsm_file_receive)
>
> +BTF_ID(func, bpf_lsm_inode_copy_up)
> BTF_ID(func, bpf_lsm_inode_create)
> +BTF_ID(func, bpf_lsm_inode_file_setattr)
> BTF_ID(func, bpf_lsm_inode_free_security)
> BTF_ID(func, bpf_lsm_inode_getattr)
> BTF_ID(func, bpf_lsm_inode_getxattr)
> +BTF_ID(func, bpf_lsm_inode_link)
> +BTF_ID(func, bpf_lsm_inode_mkdir)
> BTF_ID(func, bpf_lsm_inode_mknod)
> BTF_ID(func, bpf_lsm_inode_need_killpriv)
> BTF_ID(func, bpf_lsm_inode_post_setxattr)
> BTF_ID(func, bpf_lsm_inode_post_removexattr)
> BTF_ID(func, bpf_lsm_inode_readlink)
> +BTF_ID(func, bpf_lsm_inode_remove_acl)
> BTF_ID(func, bpf_lsm_inode_removexattr)
> BTF_ID(func, bpf_lsm_inode_rename)
> BTF_ID(func, bpf_lsm_inode_rmdir)
> +BTF_ID(func, bpf_lsm_inode_set_acl)
> BTF_ID(func, bpf_lsm_inode_setattr)
> BTF_ID(func, bpf_lsm_inode_setxattr)
> BTF_ID(func, bpf_lsm_inode_symlink)
[Severity: High]
Can adding these hooks to sleepable_lsm_hooks deadlock on iint->mutex via
bpf_ima_inode_hash()?
bpf_ima_inode_hash_allowed() only checks bpf_lsm_is_sleepable_hook(), so
sleepable LSM programs on inode_set_acl, inode_remove_acl,
inode_file_setattr, and inode_copy_up can now call bpf_ima_inode_hash() on
dentry->d_inode, which locks iint->mutex in __ima_inode_hash().
vfs_set_acl(), vfs_remove_acl(), and vfs_fileattr_set() hold inode->i_rwsem
across their hooks, inverting IMA's iint->mutex -> inode->i_rwsem lock order
and causing an ABBA deadlock:
CPU0 CPU1
---- ----
lock(&iint->mutex)
lock(&inode->i_rwsem)
lock(&inode->i_rwsem)
lock(&iint->mutex)
*** DEADLOCK ***
CPU0: process_measurement() -> inode_lock() -> ima_appraise_measurement()
CPU1: vfs_set_acl() -> security_inode_set_acl() -> bpf_ima_inode_hash()
On overlayfs under IMA or EVM fix mode, security_inode_copy_up() can also run
while iint->mutex is already held, causing a single-thread AA deadlock (and
normal copy-up inverts OVL_I(inode)->lock against iint->mutex across CPUs):
process_measurement()
mutex_lock(&iint->mutex)
inode_lock(inode)
ima_appraise_measurement()
ima_fix_xattr()
__vfs_setxattr_noperm()
ovl_xattr_set()
ovl_copy_up()
ovl_copy_up_start() /* locks OVL_I(inode)->lock */
...
security_inode_copy_up()
bpf_ima_inode_hash()
mutex_lock(&iint->mutex) <-- deadlocks
Should bpf_ima_inode_hash_allowed() exclude hooks called with inode->i_rwsem
or OVL_I(inode)->lock held, or reachable under iint->mutex?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203134411.1092433-1-a.s.protopopov@gmail.com?part=1
next prev parent reply other threads:[~2026-12-03 13:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 13:44 [PATCH v1 bpf-next 0/3] bpf: Use the xattr kfuncs on six more inode hooks Anton Protopopov
2026-12-03 13:44 ` [PATCH v1 bpf-next 1/3] bpf: Let sleepable LSM programs attach to " Anton Protopopov
2026-12-03 13:54 ` sashiko-bot [this message]
2026-12-03 15:34 ` Anton Protopopov
2026-12-03 18:46 ` Anton Protopopov
2026-12-03 13:44 ` [PATCH v1 bpf-next 2/3] bpf: Add a bpf_get_inode_xattr kfunc Anton Protopopov
2026-12-03 14:01 ` sashiko-bot
2026-12-03 14:42 ` Anton Protopopov
2026-12-03 13:44 ` [PATCH v1 bpf-next 3/3] selftests/bpf: Test xattr kfuncs on the new sleepable inode hooks Anton Protopopov
2026-12-03 13:45 ` sashiko-bot
2026-12-03 14:25 ` Anton Protopopov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-247902@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a.s.protopopov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.