RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2121972 - [virtiofs] Input/output error when creating file on host directly and then access it from guest with SELinux support enabled
Summary: [virtiofs] Input/output error when creating file on host directly and then ac...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: virtiofsd
Version: 9.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: German Maglione
QA Contact: xiagao
URL:
Whiteboard:
Depends On: 2123070
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-08-28 00:12 UTC by xiagao
Modified: 2023-05-09 09:02 UTC (History)
9 users (show)

Fixed In Version: virtiofsd-1.5.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 07:46:45 UTC
Type: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Gitlab virtio-fs virtiofsd merge_requests 132 0 None opened Fix `listxattr()` response when xattr name list is empty 2022-08-30 09:27:53 UTC
Red Hat Issue Tracker RHELPLAN-132512 0 None None None 2022-08-28 00:13:39 UTC
Red Hat Product Errata RHBA-2023:2334 0 None None None 2023-05-09 07:47:06 UTC

Description xiagao 2022-08-28 00:12:30 UTC
Description of problem:
As $subject.

Version-Release number of selected component (if applicable):
qemu-kvm-7.0.0-11.el9.x86_64
virtiofsd-1.4.0-1.el9.x86_64
seabios-bin-1.16.0-4.el9.noarch
edk2-ovmf-20220526git16779ede2d36-3.el9.noarch
kernel-5.14.0-149.el9.x86_64

How reproducible:
100%

Steps to Reproduce:

Enable selinux on host and guest.

1. Start virtiofsd with xattr remapping.
# /usr/libexec/virtiofsd -o source=/home/test  --socket-path=/tmp/sock1 --xattr --security-label -o xattrmap=:map:security.selinux:trusted.virtiofsd.: --modcaps=+sys_admin

2. Create a new file on shared directory inside host.
(host)# touch b
(host)# ll -Z
total 0
-rw-r--r--. 1 root root unconfined_u:object_r:user_home_t:s0 0 Aug  4 05:49 b
(host)# 
(host)# getfattr -m '' b
# file: b
security.selinux

3. Check the file attr inside guest
(guest)# ll -Z
total 0
-rw-r--r--. 1 root root system_u:object_r:unlabeled_t:s0     0 Aug  4 17:49 b
(guest)# getfattr -m '' b
b: Input/output error

Actual results:
(guest)# getfattr -m '' b
b: Input/output error

Expected results:
No error output.

Additional info:
This bug is from https://bugzilla.redhat.com/show_bug.cgi?id=2109178#c16 ,and Vivek opened an issue upstream, https://gitlab.com/virtio-fs/virtiofsd/-/issues/55 .

Comment 1 Vivek Goyal 2022-08-29 18:13:18 UTC
Changed component to virtiofsd as this is an virtiofsd (Rust) issue and not qemu-kvm issue.

Comment 4 German Maglione 2022-08-30 09:27:53 UTC
Just a clarification, this bug is related to how we handle an empty list of xattr names in listxattr. It shows up here because of the mapping of security.selinux.
You can also test it using the following script on a file without any xattr

#!/usr/bin/env python

import os
import sys

if len(sys.argv) < 2:
    print(f"Usage: {sys.argv[0]} <file name>")
    sys.exit(1)

xattrs = os.listxattr(sys.argv[1])

for a in xattrs:
    print(a)

Comment 5 xiagao 2022-09-21 09:16:39 UTC
Get the shared folder's extended attribution also failed with the same error. 
I though they are the same issue.

Steps:
1. enable SELinuxe in guest and host
2. start virtiofsd with --security-label.

/usr/libexec/virtiofsd --socket-path=/var/tmp/avocado_2bv4m51f/avocado-vt-vm1-fs-virtiofsd.sock -o source=/root/avocado/data/avocado-vt/virtio_fs_test/ --xattr --security-label -o xattrmap=:map:security.selinux:trusted.virtiofsd.: --modcaps=+sys_admin -o sandbox=chroot

3. start vm and mount virtiofs.

4. try to get extended attribution of the shared folder, but get input/output error.
[root@bootp-73-75-179 ~]# getfattr -d -m - /mnt/myfs/
/mnt/myfs/: Input/output error

Comment 6 German Maglione 2022-09-28 15:22:57 UTC
(In reply to xiagao from comment #5)
> Get the shared folder's extended attribution also failed with the same
> error. 
> I though they are the same issue.
> 
> Steps:
> 1. enable SELinuxe in guest and host
> 2. start virtiofsd with --security-label.
> 
> /usr/libexec/virtiofsd
> --socket-path=/var/tmp/avocado_2bv4m51f/avocado-vt-vm1-fs-virtiofsd.sock -o
> source=/root/avocado/data/avocado-vt/virtio_fs_test/ --xattr
> --security-label -o xattrmap=:map:security.selinux:trusted.virtiofsd.:
> --modcaps=+sys_admin -o sandbox=chroot
> 
> 3. start vm and mount virtiofs.
> 
> 4. try to get extended attribution of the shared folder, but get
> input/output error.
> [root@bootp-73-75-179 ~]# getfattr -d -m - /mnt/myfs/
> /mnt/myfs/: Input/output error

I tested, I cannot reproduce using the latest version that includes the listxattr fix.
So, this issue also will be fixed with the next version rebase.

Comment 7 xiagao 2022-11-24 01:56:17 UTC
Hi German
I see this bug is posted, could you pls set DTM for this bug?

Thanks,
Xiaoling

Comment 10 xiagao 2022-12-29 07:13:18 UTC
Test pass with the fixed virtiofsd version, there is no input/output error info, so set Verified status of this bug.
[root@bootp-73-75-32 mnt]# getfattr -d -m - mm
[root@bootp-73-75-32 mnt]# 
[root@bootp-73-75-32 mm]# getfattr -m '' b
[root@bootp-73-75-32 mm]# 


pkg:
virtiofsd-1.5.0-1.el9.x86_64
qemu-kvm-7.2.0-1.el9
5.14.0-219.el9.x86_64(host)
5.14.0-226.el9.x86_64(guest)

Comment 12 errata-xmlrpc 2023-05-09 07:46:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virtiofsd bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2334


Note You need to log in before you can comment on or make changes to this bug.