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 1990135 - Fix data corruption in nbdkit-cow-filter and nbdkit-cache-filter
Summary: Fix data corruption in nbdkit-cow-filter and nbdkit-cache-filter
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: nbdkit
Version: 8.5
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: mxie@redhat.com
URL:
Whiteboard:
: 2040775 (view as bug list)
Depends On: 1990134
Blocks: 2040775 2040781
TreeView+ depends on / blocked
 
Reported: 2021-08-04 19:57 UTC by Richard W.M. Jones
Modified: 2022-05-10 13:28 UTC (History)
12 users (show)

Fixed In Version: nbdkit-1.24.0-3.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1990134
: 2040775 (view as bug list)
Environment:
Last Closed: 2022-05-10 13:20:17 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-92398 0 None None None 2021-08-04 19:58:36 UTC
Red Hat Product Errata RHSA-2022:1759 0 None None None 2022-05-10 13:22:07 UTC

Description Richard W.M. Jones 2021-08-04 19:57:45 UTC
+++ This bug was initially created as a clone of Bug #1990134 +++

Description of problem:

A data corrupter bug has been identified in the following
nbdkit filters:

https://libguestfs.org/nbdkit-cow-filter.1.html
https://libguestfs.org/nbdkit-cache-filter.1.html

It's quite subtle, but it affects modular virt-v2v and was
picked up by Ming Xie during testing.

The full bug is described in this link, as well as a simple way
to reproduce it, and the fix:

https://listman.redhat.com/archives/libguestfs/2021-August/msg00044.html

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

All versions of nbdkit since 1.14 up to 1.27.4

How reproducible:

100%

Steps to Reproduce:
1. See link above.

Comment 3 Richard W.M. Jones 2021-08-05 09:31:06 UTC
Upstream fix is:
https://gitlab.com/nbdkit/nbdkit/-/commit/c0b15574647672cb5c48178333acdd07424692ef

Comment 4 Richard W.M. Jones 2021-08-05 11:36:59 UTC
Waiting on RHEL AV 8.6 branch to open before I can push this.

Comment 7 mxie@redhat.com 2021-09-16 10:47:11 UTC
Test the bug with below builds:
nbdkit-1.24.0-3.module+el8.6.0+12512+6129c95d.x86_64
libnbd-1.6.0-4.module+el8.6.0+12490+ec3e565c.x86_64
python3-libnbd-1.6.0-4.module+el8.6.0+12490+ec3e565c.x86_64

Steps:
1.# nbdkit --filter=cow data "33 * 100000" --run 'nbdsh -u $uri -c "h.trim(100000, 0)" ; nbdcopy $uri - | hexdump -C'
nbdsh: command line script failed: nbd_trim: server does not support trim operations: Invalid argument
00000000  21 21 21 21 21 21 21 21  21 21 21 21 21 21 21 21  |!!!!!!!!!!!!!!!!|
*
00018000


Result:
   Got unexpected result, bug is not fixed.

Comment 9 Richard W.M. Jones 2021-09-16 11:44:12 UTC
Actually the problem is with the test itself:

  nbdsh: command line script failed: nbd_trim: server does not support trim operations: Invalid argument

Replacing ";" with "&&" shows that the script failed:

  $ nbdkit --filter=cow data "33 * 100000" --run 'nbdsh -u $uri -c "h.trim(100000, 0)" && nbdcopy $uri - | hexdump -C'
  nbdsh: command line script failed: nbd_trim: server does not support trim operations: Invalid argument
  $ echo $?
  1

I believe it's not possible to hit this code path with nbdkit 1.24.
This is because trim is not support in the cache and cow filters in
1.24.  zero is supported, but is not reachable because:

  https://gitlab.com/nbdkit/nbdkit/-/blob/7f4f80fd418452ffcc29e3f4d99e7ae90880dbde/filters/cow/cow.c#L415

I still want to keep this patch in 1.24 because it is possible
that future changes on this branch (eg. enabling trim support)
could trigger this bug.

Comment 10 Richard W.M. Jones 2021-09-16 11:45:23 UTC
May be best to check that the patch is applied in build.log?
In other words, simple sanity only check.

Comment 11 John Ferlan 2021-09-29 11:55:07 UTC
Rich - assigning to you directly since we have an ITM/release+ and you've made the change. Feel free to move to eblake if he's doing the downstream work for nbdkit.

Comment 14 mxie@redhat.com 2021-10-12 08:58:29 UTC
Verify the bug with nbdkit-1.24.0-3.module+el8.6.0+12861+13975d62.x86_64

Steps:
1.According to comment10, check if the patch 'https://gitlab.com/nbdkit/nbdkit/-/commit/c0b15574647672cb5c48178333acdd07424692ef' is added to nbdkit-1.24.0-3

# rpmbuild -rp nbdkit-1.24.0-3.module+el8.6.0+12861+13975d62.src.rpm

# cat /root/rpmbuild/BUILD/nbdkit-1.24.0/filters/cache/cache.c |grep memset
      memset (&block[blkoffs], 0, n);
    memset (block, 0, blksize);
      memset (block, 0, count);

# cat /root/rpmbuild/BUILD/nbdkit-1.24.0/filters/cow/cow.c |grep memset
      memset (&block[blkoffs], 0, n);
    memset (block, 0, BLKSIZE);
      memset (block, 0, count);


Hi Richard,

    I found the code changes of https://gitlab.com/nbdkit/nbdkit/-/commit/c0b15574647672cb5c48178333acdd07424692ef are different with the changes of https://gitlab.com/nbdkit/nbdkit/-/commit/a0ae7b2158598ce48ac31706319007f716d01c87, which commit is expected for the bug?

Check the code changes for the bug in nbdkit-1.28.0-1.el9.src.rpm, the result of cow.c is different with nbdkit-1.24.0-3

# cat /root/rpmbuild/BUILD/nbdkit-1.28.0/filters/cow/cow.c |grep memset
      memset (&block[blkoffs], 0, n);
    memset (block, 0, blksize);
      memset (block, 0, count);
      memset (&block[blkoffs], 0, n);
      memset (block, 0, count);

Comment 15 Richard W.M. Jones 2021-10-12 12:07:21 UTC
The reason for the difference is because nbdkit 1.24 cow/cache
filters did not support the TRIM operation.  So the whole function
(cow_trim, cache_trim) is missing in 1.24.  This leads to fewer
calls to memset (only cow_zero/cow_trim).  In addition the *_zero
functions call memset three times because they actually zero the
head, main body of data, and tail.  But the *_trim functions call
memset twice because they only zero the head and tail (there's a trim-
specific operation for the main body of data).

Anyway, these match the patched files, so the verification is
correct, thanks.

Comment 16 mxie@redhat.com 2021-10-12 15:07:46 UTC
Thanks Richard, move the bug from ON_QA to VERIFIED according to comment14 and comment15

Comment 17 Yash Mankad 2022-01-14 17:24:08 UTC
*** Bug 2040775 has been marked as a duplicate of this bug. ***

Comment 20 errata-xmlrpc 2022-05-10 13:20:17 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 (Moderate: virt:rhel and virt-devel:rhel security, 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/RHSA-2022:1759


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