From: Petr Lautrbach <lautrbach@redhat.com>
To: Cathy Hu <cahu@suse.de>, selinux@vger.kernel.org
Subject: Re: [PATCH] restorecon: Only log error on readonly fs (bsc#1257996)
Date: Tue, 28 Apr 2026 12:44:06 +0200 [thread overview]
Message-ID: <87tssvs6tl.fsf@redhat.com> (raw)
In-Reply-To: <53d9cc60-73a0-4c65-90c7-58cb51f1f6a5@suse.de>
Cathy Hu <cahu@suse.de> writes:
> On 4/27/26 6:52 PM, Petr Lautrbach wrote:
>> Cathy Hu <cahu@suse.de> writes:
>>
>>> Signed-off-by: Cathy Hu <cahu@suse.de>
>>> ---
>>> RFC Patch for the issue described in thread "Question regarding restorecon and btrfs read-only snapshots"
>>>
>>
>> Could you point me where I can find the thread and is bsc#1257996?
>
> "Question regarding restorecon and btrfs read-only snapshots" Thread:
> https://lore.kernel.org/selinux/98f87fd6-6d3e-4539-ad8f-1a0dc09aa890@suse.de/
>
> bsc#1257996: Good point, that is the wrong bug number, the right one is:
> https://bugzilla.suse.com/show_bug.cgi?id=1232226
> I will refresh the patch after the discussion
>
>
>>
>> What's the expected outcome? Before this change I see:
>>
>> $ sudo restorecon -R -v /mnt/
>> restorecon: Could not set context for /mnt: Read-only file system
>> restorecon: Could not set context for /mnt/lost+found: Read-only file system
>> restorecon: Could not set context for /mnt/a: Read-only file system
>> restorecon: Could not set context for /mnt/1: Read-only file system
>>
>> After:
>>
>> $ sudo restorecon -R -v /mnt/
>> Read only filesystem, relabel not possible: /mnt
>> Read only filesystem, relabel not possible: /mnt/lost+found
>> Read only filesystem, relabel not possible: /mnt/a
>> Read only filesystem, relabel not possible: /mnt/1
>>
>> This seems to be only a cosmetic change.
>
> return value should be 0 with the change, before that it was 255.
> So before it was failing, now it is traverse and log only
>
thanks for the pointers, it's clear now.
Is it expected that it would work only in first level of subdirectories?
$ mount | grep /mnt
/dev/loop0 on /mnt type ext4 (ro,relatime,seclabel)
/dev/loop1 on /mnt/rw type ext4 (rw,relatime,seclabel)
/dev/loop2 on /mnt/a/b/c/d/rw type ext4 (rw,relatime,seclabel)
$ sudo restorecon -R -v /mnt
Read only filesystem, relabel not possible: /mnt
Read only filesystem, relabel not possible: /mnt/lost+found
Read only filesystem, relabel not possible: /mnt/a
Relabeled /mnt/rw from system_u:object_r:user_home_t:s0 to system_u:object_r:mnt_t:s0
Read only filesystem, relabel not possible: /mnt/1
It seems to be useful just for one specific use case.
Also could you please improve the commit message so it contains some
reason, uses case and the final effect? it will help future reviewers to better
understand this change.
Petr
>>
>> Petr
>>
>>
>>> libselinux/src/selinux_restorecon.c | 8 ++++++--
>>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
>>> index 8fadf4d2..e8545e27 100644
>>> --- a/libselinux/src/selinux_restorecon.c
>>> +++ b/libselinux/src/selinux_restorecon.c
>>> @@ -774,10 +774,14 @@ static int restorecon_sb(const char *pathname, const struct stat *sb,
>>> if (!flags->nochange) {
>>> if (lsetfilecon(pathname, newcon) < 0) {
>>> /* Ignore files removed during relabeling if ignore_noent is set */
>>> - if (flags->ignore_noent && errno == ENOENT)
>>> + if (flags->ignore_noent && errno == ENOENT) {
>>> goto out;
>>> - else
>>> + } else if (errno == EROFS) {
>>> + selinux_log(SELINUX_INFO, "Read only filesystem, relabel not possible: %s\n", pathname);
>>> + goto out;
>>> + } else {
>>> goto err;
>>> + }
>>> }
>>>
>>> updated = true;
>>> --
>>> 2.53.0
>>
next prev parent reply other threads:[~2026-04-28 10:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 15:32 [PATCH] restorecon: Only log error on readonly fs (bsc#1257996) Cathy Hu
2026-04-27 16:52 ` Petr Lautrbach
2026-04-28 9:18 ` Cathy Hu
2026-04-28 10:44 ` Petr Lautrbach [this message]
2026-04-30 10:58 ` Cathy Hu
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=87tssvs6tl.fsf@redhat.com \
--to=lautrbach@redhat.com \
--cc=cahu@suse.de \
--cc=selinux@vger.kernel.org \
/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.