Bug 1905072
| Summary: | "fsadm resize /dev/foo" without size argument crashes [rhel-7.9.z] | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Marius Vollmer <mvollmer> | |
| Component: | lvm2 | Assignee: | Zdenek Kabelac <zkabelac> | |
| lvm2 sub component: | Command-line tools | QA Contact: | cluster-qe <cluster-qe> | |
| Status: | CLOSED ERRATA | Docs Contact: | ||
| Severity: | high | |||
| Priority: | urgent | CC: | agk, ajschorr, cmarthal, dlawrenc, heinzm, jbrassow, jreznik, mcsontos, mjuricek, mpitt, msnitzer, prajnoha, thornber, zkabelac | |
| Version: | 7.9 | Keywords: | Regression, ZStream | |
| Target Milestone: | rc | |||
| Target Release: | 7.9 | |||
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | lvm2-2.02.187-6.el7_9.4 | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 1905705 (view as bug list) | Environment: | ||
| Last Closed: | 2021-03-16 13:57:09 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: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 1905705 | |||
|
Description
Marius Vollmer
2020-12-07 12:47:45 UTC
Fixed by this patch: https://www.redhat.com/archives/lvm-devel/2020-December/msg00005.html Feel free to apply this patch on your locally installed /usr/sbin/fsadm bash script to get an instant fix on your system. Introduced regression causes troubles for a specific use-case of fsadm - where the resize without size parameter has resized the filesystem to match device size. Provided fixing patch is very and has no impact on other things than validating input parameters for fsadm which is now 'guarded' by prohibiting of use of unbound shell variables. Tested by this upstream testing case: https://www.redhat.com/archives/lvm-devel/2020-December/msg00003.html This also happens on RHEL 8.4 -- should this bug be cloned? See bug 1905705 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 (lvm2 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-2021:0863 This patch can't be right. The new version of detect_device_size in fsadm says:
# get the full size of device in bytes
detect_device_size() {
# check if blockdev supports getsize64
DEVSIZE=$("$BLOCKDEV" --getsize64 "$VOLUME" 2>"$NULL" || true)
if test -n "$DEVSIZE" ; then
DEVSIZE=$("$BLOCKDEV" --getsize "$VOLUME" || true)
test -n "$DEVSIZE" || error "Cannot read size of device \"$VOLUME\"."
SSSIZE=$("$BLOCKDEV" --getss "$VOLUME" || true)
test -n "$SSSIZE" || error "Cannot read sector size of device \"$VOLUME\"."
DEVSIZE=$(( $DEVSIZE * $SSSIZE ))
fi
}
So it tries to get the size using --getsize64, and then it seems to attempt to test whether
it got back a non-empty result, but the sense of the test is inverted. It should say:
if test -z "$DEVSIZE" ; then
before falling back to using getsize/getss. As written, it falls back to using
getsize/getss when getsize64 actually works, but if getsize64 is absent, then it won't
fall back, and the user is screwed. And isn't getsize deprecated in favor of getsz?
Shouldn't this function actually read:
# get the full size of device in bytes
detect_device_size() {
# check if blockdev supports getsize64
DEVSIZE=$("$BLOCKDEV" --getsize64 "$VOLUME" 2>"$NULL" || true)
if test -z "$DEVSIZE" ; then
DEVSIZE=$("$BLOCKDEV" --getsz "$VOLUME" || true)
test -n "$DEVSIZE" || error "Cannot read size of device \"$VOLUME\"."
SSSIZE=$("$BLOCKDEV" --getss "$VOLUME" || true)
test -n "$SSSIZE" || error "Cannot read sector size of device \"$VOLUME\"."
DEVSIZE=$(( $DEVSIZE * $SSSIZE ))
fi
}
In other words, please patch as follows:
detect_device_size() {
# check if blockdev supports getsize64
DEVSIZE=$("$BLOCKDEV" --getsize64 "$VOLUME" 2>"$NULL" || true)
- if test -n "$DEVSIZE" ; then
- DEVSIZE=$("$BLOCKDEV" --getsize "$VOLUME" || true)
+ if test -z "$DEVSIZE" ; then
+ DEVSIZE=$("$BLOCKDEV" --getsz "$VOLUME" || true)
test -n "$DEVSIZE" || error "Cannot read size of device \"$VOLUME\"."
SSSIZE=$("$BLOCKDEV" --getss "$VOLUME" || true)
test -n "$SSSIZE" || error "Cannot read sector size of device \"$VOLUME\"."
Regards,
Andy
This still crashes in exactly the same way with lvm2-2.02.187-6.el7_9.5.x86_64 . Same in RHEL 8.4, as our automatic OS issue tracker shows: https://github.com/cockpit-project/bots/issues/1453 Please reopen (for some weird reason I can't) I can't reproduce the crash with lvm2-2.02.187-6.el7_9.5.x86_64 on rhel-7-9. The last time it happened in our CI on rhel-7-9 was 2021-02-04T03:14:56.333597. So I'd say this is fixed on rhel-7-9 and there is no need to reopen this report. Thanks Marius, you are right of course -- we still see that on CentOS 7 which hasn't picked up that fix yet. Sorry for the noise! (In reply to Andrew Schorr from comment #25) > This patch can't be right. The new version of detect_device_size in fsadm > says: I think you have a point, but it is unrelated to this bug report here as far as I can see. Could you open a new bug report? There is actually no need to open a new bug for comment 25. The incorrect logic just caused 2 extra calls of blockdev command - but all the numbers were still correct and there is no bug in fsadm behavior. Also the issue has been already fixed upstream: https://listman.redhat.com/archives/lvm-devel/2021-March/msg00263.html |