From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796306090; b=AX0P1vMXg0vJFm59pwCEBJWhIzsdL5JsMWbz1JwkoGNeVvWtxGhgr/IPCXO2JyGh1yKu uwAQucmOqlHGHW44r3sOdKk17Pss8NDoSwZBgL7lwpmRwB8ZXiHiz23gsmt/kSjfdG6pt dQilVkaDrBT8/p5UOsxX5sg/b7PlZ7WvSuYbuia5A4X2lnPZxJO+s1MYBFs2+BoKjhbVQ +w9HdZSSF0Fd4q3cepZfTeUbJxzeAljgiKzaRTvEDkEqR5RREmTPtnwxJYNlCyhRdka7b ypGP6CwV9lediqy5GsoVVYFP91ixG+AVe+IorYma6BMEIag3jyJAMVDjARKklDegTdg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796306090; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=4DyylSSjKM5wEkPpPbuNJYJiWnNsmv08XMV8Z7C64bs=; b=0tG4W/r3xakJyeEfwy9wqbqXyL6UkP19gxHbohNCCns5Wl7nvCUGC1SlLaVKqMokth/v XXK4spFyjgNzTJRFQThFImVNbQ86taWQvfI7+DFwn8I3BMsEy0U2N/AZWbT9DVuhUM1EL 2NfSpT3/+9q00SDrXlmfm5tdjaeY1zlMqEa6UFViqEvjrKnrMIjGXjYRw70qDb43pDi/z 4cV8iMv4fH4Op0MapMpb6G7YCF1mfHls6Wt9zuJ0omsBBGyt/n44PNJIn3bCWs7Uy+JdX GBqOyBFJZkzLQBiEUkbJ3ITgpk11ujQ6ewsHWPGHXpfk4rtXGuIYlXHj+T4OsnQrjGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Tc5xNLir; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0FBB606A32D for ; Thu, 3 Dec 2026 13:54:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Tc5xNLir Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EA4D1F00898; Thu, 3 Dec 2026 13:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796306090; bh=4DyylSSjKM5wEkPpPbuNJYJiWnNsmv08XMV8Z7C64bs=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Tc5xNLirW/9pFTVYV/OfWshX98ZyekbRB/MMwWq6ZGIOe2wu2p5btweyOym/UaXtA u3tgzF8GIlIAYowGrzleTkpXNGNvdVq+JGl+5MKLBfR/oW83CEFGw9PItjPkI0MDlM LaaB6bk1a0Rx7VwG+I2jq18ir5FumnSRHbKAjp2/gplDHA6VrwawfqUMB7i/Yjlk2H 8RC35EpFAIcZ060qpL+6cdock/xojbPuCz7PHem8DK/1LvRJppatirD1hnVzAq/Ube YbbOEzooFfJJiYGq7oHC1qlM+wd1TQbEV2aFJ2w6pSlKC50JxkVL3RP7ejhLX1sgmZ UvqFjBtdinRZw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v1 bpf-next 1/3] bpf: Let sleepable LSM programs attach to six more inode hooks Reply-To: sashiko-reviews@lists.linux.dev To: "Anton Protopopov" , bpf@vger.kernel.org In-Reply-To: <20261203134411.1092433-2-a.s.protopopov@gmail.com> References: <20261203134411.1092433-1-a.s.protopopov@gmail.com> <20261203134411.1092433-2-a.s.protopopov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 13:54:50 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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) > =20 > +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 r= un 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? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203134411.1092= 433-1-a.s.protopopov@gmail.com?part=3D1