[PATCH] apparmor: don't take chroot root refs in d_namespace_path()

Guicai Ma maguicai at kylinos.cn
Wed Dec 2 09:09:44 UTC 2026


On Tue, Dec 01, 2026 at 03:27:26PM +0000, Arun Iyengar wrote:
>  	/* resolve paths relative to chroot?*/
>  	if (flags & PATH_CHROOT_REL) {
> +		struct fs_struct *fs = current->fs;
>  		struct path root;
> -		get_fs_root(current->fs, &root);
> +		unsigned int seq;
> +
> +		rcu_read_lock();
> +		do {
> +			seq = read_seqbegin(&fs->seq);
> +			root = fs->root;
> +		} while (read_seqretry(&fs->seq, seq));
>  		res = __d_path(path, &root, buf, buflen);
> -		path_put(&root);
> +		rcu_read_unlock();
>  	} else {

Checked the rest of unix_fs_perm() -> aa_path_perm() -> aa_audit_file()
with your unix peer checks patch applied as well, and I don't see any
other sleeping calls left under unix_state_lock().

Nit: security/apparmor/path.c only gets rcu_read_lock() transitively,
so adding <linux/rcupdate.h> would be nice if you respin.

Tested on v7.4-rc5 (arm64 KVM, KASAN + lockdep + DEBUG_ATOMIC_SLEEP +
PROVE_RCU + UBSAN) on top of that patch, using a chroot_relative
profile over AF_UNIX stream and dgram sockets with concurrent chroot()
churn. Without this patch I hit the dput() sleeping-in-atomic splat via
both apparmor_unix_stream_connect() and apparmor_unix_may_send(). With
it applied, both run clean.

Reviewed-by: Guicai Ma <maguicai at kylinos.cn>
Tested-by: Guicai Ma <maguicai at kylinos.cn>



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