All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Wake Liu <wakel@google.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] swapon04: Report TCONF when SELinux denies loop device I/O
Date: Mon, 19 Oct 2026 13:20:38 +0200	[thread overview]
Message-ID: <atX9BkzCNAyth6hm@yuki.lan> (raw)
In-Reply-To: <20261014093618.1475191-1-wakel@google.com>

Hi!
> +/*
> + * Kernels without commit f2fed441c69b ("loop: stop using
> + * vfs_iter_{read,write} for buffered I/O") access the backing file through
> + * vfs_iter_{read,write}(), which run LSM permission checks with the
> + * credentials of the loop worker kernel thread. Strict SELinux policies,
> + * such as Android's, do not allow the kernel to access the unlabeled files
> + * on the freshly formatted test filesystem, so any I/O on the loop device
> + * fails with EIO.
> + */
> +static void check_loop_io(void)
> +{
> +	char buf[512];
> +	int fd;
> +
> +	fd = SAFE_OPEN(loop_dev, O_RDONLY);
> +	TEST(read(fd, buf, sizeof(buf)));
> +	SAFE_CLOSE(fd);
> +
> +	if (TST_RET == (long)sizeof(buf))
> +		return;
> +
> +	if (TST_RET == -1 && TST_ERR == EIO && tst_selinux_enforcing())
> +		tst_brk(TCONF | TTERRNO, "I/O on %s is likely denied by SELinux", loop_dev);

If nothing else we whould check for the selinux as a first thing in the
function.

	if (!tst_selinux_enforcing())
		return;

	fd = SAFE_OPEN(loop_dev, ...);
	...

And the check should be skipped on 6.15 and newer, where this problem
does not happen.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2026-10-19 11:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14  9:36 [LTP] [PATCH] swapon04: Report TCONF when SELinux denies loop device I/O Wake Liu via ltp
2026-10-14 11:20 ` [LTP] " linuxtestproject.agent
2026-10-19 11:20 ` Cyril Hrubis [this message]
2026-10-19 13:26 ` [LTP] [PATCH v2] " Wake Liu via ltp
2026-10-19 19:06   ` [LTP] " linuxtestproject.agent
2026-10-19 20:02   ` [LTP] [PATCH v2] " Avinesh Kumar via ltp

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=atX9BkzCNAyth6hm@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=wakel@google.com \
    /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.