Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[metadata] uninitialized members in struct pv_list #10

Closed
mingnus opened this issue Dec 14, 2018 · 5 comments
Closed

[metadata] uninitialized members in struct pv_list #10

mingnus opened this issue Dec 14, 2018 · 5 comments

Comments

@mingnus
Copy link
Contributor

mingnus commented Dec 14, 2018

Scenario: Given an existed LV lvol0, I want to create another LV on the PVs used by lvol0

I use build_parallel_areas_from_lv() to obtain the pv_list of each segments. However, the returned pv_list is not properly initialized, which causes segfault in subsequent operations.

Here's the patch:

diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 2c569d8f9..27c40d710 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5962,7 +5962,7 @@ static int _add_pvs(struct cmd_context *cmd, struct pv_segment *peg,
        if (find_pv_in_pv_list(&spvs->pvs, peg->pv))
                return 1;
 
-       if (!(pvl = dm_pool_alloc(cmd->mem, sizeof(*pvl)))) {
+       if (!(pvl = dm_pool_zalloc(cmd->mem, sizeof(*pvl)))) {
                log_error("pv_list allocation failed");
                return 0;
        }
@zkabelac
Copy link

zkabelac commented Dec 14, 2018 via email

@mingnus
Copy link
Contributor Author

mingnus commented Dec 15, 2018

Thanks. Could you help backport to the 2018-06-01-stable branch, please?

@csonto
Copy link
Contributor

csonto commented Dec 19, 2018

Done. Thank you!

@csonto csonto closed this as completed Dec 19, 2018
csonto pushed a commit that referenced this issue Feb 20, 2019
Scenario: Given an existed LV `lvol0`, I want to create another LV
on the PVs used by `lvol0`.

I use `build_parallel_areas_from_lv()` to obtain the `pv_list` of each segments.
However, the returned `pv_list` is not properly initialized, which causes
segfault in subsequent operations.

(cherry picked from commit 859feb8)
(cherry picked from commit 219ba4f)

Conflicts:
	WHATS_NEW
@wangwang3210
Copy link

@mingnus could you tell me how to reproduce the segmentfault issue, I run
lvcreate -i 2 -L 30G -n lv1 vg
lvcreate -i 2 -L 30G -n lv2 vg
, while build_parallel_areas_from_lv is not called, segfault does not occur neither.
thanks a lot!

@mingnus
Copy link
Contributor Author

mingnus commented Apr 17, 2019

@wangwang3210
It's a "potential" bug, and cannot be reproduced via command line. I found it while I was modifying the code.

tasleson pushed a commit that referenced this issue Apr 18, 2019
Scenario: Given an existed LV `lvol0`, I want to create another LV
on the PVs used by `lvol0`.

I use `build_parallel_areas_from_lv()` to obtain the `pv_list` of each segments.
However, the returned `pv_list` is not properly initialized, which causes
segfault in subsequent operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants