Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2111524

Summary: Remote TLS connections sometimes fail with nbd_pread: nothing to poll for in state REPLY.START: Invalid argument
Product: Red Hat Enterprise Linux 9 Reporter: Richard W.M. Jones <rjones>
Component: libnbdAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Vera <vwu>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.1CC: lersek, mxie, rjones, tyan, tzheng, virt-maint, vwu, xiaodwan
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libnbd-1.12.6-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 09:50:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
make-pki.sh
none
test-read.py
none
make-pki.sh none

Description Richard W.M. Jones 2022-07-27 12:29:14 UTC
Description of problem:

Upstream a strange bug was reported when libnbd connects to a
remote server over TLS and tries to read.  The error happens
randomly but is reproducible if you run the test many times.

We have identified the problem and fixed it upstream.

Version-Release number of selected component (if applicable):

libnbd-1.12.5-1.el9

How reproducible:

Quite rare.

Steps to Reproduce:

1. Set up X.509 certificates using the "make-pki.sh" script attached.
I created certificates in /var/tmp/pki/.

2. Take a random qcow2 file, eg. a virtual machine disk image.
I'm using a Fedora cloud image.

3. Run qemu-nbd on the server, enabling TLS:

$ qemu-nbd -t -f qcow2 Fedora-Cloud-Base-35-1.2.x86_64.qcow2  --object tls-creds-x509,id=tls0,endpoint=server,dir=/var/tmp/pki,verify-peer=false --tls-creds tls0

4. Copy /var/tmp/pki to another machine.

5. On the second machine run the second attached test program.

/var/tmp/test-read.py

6. It should eventually fail with:

nbd_pread: nothing to poll for in state REPLY.START: Invalid argument

Comment 1 Richard W.M. Jones 2022-07-27 12:31:24 UTC
Created attachment 1899642 [details]
make-pki.sh

NB: You need to adjust the SERVER=... in the script!

Comment 2 Richard W.M. Jones 2022-07-27 12:34:39 UTC
Created attachment 1899643 [details]
test-read.py

Note: You need to adjust the server name in the script.

Comment 3 Richard W.M. Jones 2022-07-27 12:35:25 UTC
You may also have to open port 10809 on the server's firewall.

Comment 5 Richard W.M. Jones 2022-07-28 10:32:42 UTC
I bumped the version to 1.12.6, but this isn't really a rebase, it's
a move along the stable branch bringing in only small bug fixes:

https://gitlab.com/nbdkit/libnbd/-/commits/rhel-9.1/

Comment 8 Richard W.M. Jones 2022-08-04 10:55:37 UTC
Created attachment 1903530 [details]
make-pki.sh

This is a slightly modified make-pki.sh which sets the cn, dns_name
and ip_address fields of the server certificate.

Comment 9 Vera 2022-08-05 03:05:01 UTC
Reproduce with 
qemu-img-7.0.0-9.el9.x86_64
libnbd-1.12.5-1.el9.x86_64

Steps to Reproduce:
1. Set up a qemu-nbd + TLS server using steps 1.-4

2. On the client machine run the test program.(client and server should be in bad network.Using "tc" to make pkt loss and corruption.)

# tc qdisc add dev enp0s31f6 root netem loss 30%
# ./test-read.py 
...................................................................Traceback (most recent call last):
  File "/home/pki/./test-read.py", line 11, in <module>
    h.pread(4*1024*1024, 1024)
  File "/usr/lib64/python3.9/site-packages/nbd.py", line 1595, in pread
    return libnbdmod.pread(self._o, count, offset, flags)
nbd.Error: nbd_pread: nothing to poll for in state REPLY.START: Invalid argument (EINVAL)


Verified with 
qemu-img-7.0.0-9.el9.x86_64
libnbd-1.12.6-1.el9.x86_64

Steps:
1. Set up a qemu-nbd + TLS server using steps 1.-4

2. On the client machine run the test program.

# ./test-read.py 
.............................................
(As expected dotting)

Mark Verified:Tested. Moving to VERIFIED.

Comment 11 errata-xmlrpc 2022-11-15 09:50:16 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 (libnbd 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-2022:7944