Bug 2215328

Summary: thin_rmap should fail and return an error message when using invalid range
Product: Red Hat Enterprise Linux 9 Reporter: Filip Suba <fsuba>
Component: device-mapper-persistent-dataAssignee: Ming-Hung Tsai <mtsai>
Status: CLOSED MIGRATED QA Contact: Filip Suba <fsuba>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.3CC: agk, heinzm, lvm-team, msnitzer, mtsai, thornber
Target Milestone: rcKeywords: MigratedToJIRA, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-23 19:14:31 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:

Description Filip Suba 2023-06-15 14:36:57 UTC
Description of problem:
thin_rmap returns 0 when using invalid range. It should return 1 and an error message. 


Version-Release number of selected component (if applicable):
device-mapper-persistent-data-1.0.4-1.el9


How reproducible:
always


Steps to Reproduce:
1. thin_rmap /dev/mapper/vgtest-swapvol --region 10..0

Actual results:
thin_rmap returns 0 and no output

Expected results:
Should return 1 for using invalid range and print error message similar to one in 0.9.0 version


Additional info:
In 0.9.0 thin_rmap returns following error message for invalid regions:

# thin_rmap /dev/mapper/vgtest-swapvol --region 0..0
badly formed region (end <= begin)

# thin_rmap /dev/mapper/vgtest-swapvol --region 10..0
badly formed region (end <= begin)

Comment 1 Ming-Hung Tsai 2023-07-11 12:17:47 UTC
Send a patch upstream: https://github.com/jthornber/thin-provisioning-tools/commit/aa5a10af

Now the Rust version validates the range size (i.e., end > begin or not), and prohibits negative numbers (in contrast, the v0.9.0 allows negative numbers by type casting). Here are some negative test cases: 

thin_rmap --region 0..0   // end <= begin
thin_rmap --region 10..0  // end <= begin
thin_rmap --region -1..0  // negative begin
thin_rmap --region 0..-1  // negative end

Does that match our conclusions before?

Comment 2 Filip Suba 2023-07-11 14:43:10 UTC
Yes, it matches what we've concluded.

Comment 3 Ming-Hung Tsai 2023-07-24 17:33:46 UTC
Update: correct the commit id
https://github.com/jthornber/thin-provisioning-tools/commit/185cf53c15

and there are unit tests (via cargo test [--release] --test lib)
```
test commands::utils::range_parsing_tests::test_invalid_end ... ok
test commands::utils::range_parsing_tests::test_dots_only ... ok
test commands::utils::range_parsing_tests::test_invalid_begin ... ok
test commands::utils::range_parsing_tests::test_end_not_greater_than_begin ... ok
test commands::utils::range_parsing_tests::test_negative_begin ... ok
test commands::utils::range_parsing_tests::test_extra_characters ... ok
test commands::utils::range_parsing_tests::test_negative_end ... ok
test commands::utils::range_parsing_tests::test_normal ... ok
test commands::utils::range_parsing_tests::test_no_dots ... ok
```

Comment 4 Ming-Hung Tsai 2023-08-22 15:12:13 UTC
Fixed in v1.0.5 & v1.0.6 upstream

Additional info: we decided to drop the negative number support since it was undocumented and might be misleading. The corresponding CI gating test should be removed as well.

Comment 5 RHEL Program Management 2023-09-23 19:12:11 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 6 RHEL Program Management 2023-09-23 19:14:31 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.