Skip to content

Conversation

Syed-Shahrukh-OSSRevival
Copy link
Contributor

Motivation and Context

This change fixes the zpool get state command segfault issue if you pass
two or vdevs to zpool get state <pool_name> <vdev1> <vdev2>.
#15972

Description

The problem was identified in handling of the zpool get state command
line arguments. A pointer vdev was used to point to the argv[1], and
its address set to cb.cb_vdevs.cb_names(pointer to array of strings)
so any increment to cb_names resulted in a segfault. Fix covers a
special case of root parameter at argv[1] and remaining cases are
handled by passing in the argv + 1, which allows cb_names iteration
of next command line arguments (vdevs).

How Has This Been Tested?

zpool get state is a command so the testing was done manualy using
command line arguments.
There are there types of arguments for
zpool get state <poolname>

  1. all-vdevs
  2. root
  3. <vdev1> <vdev2>

The third type of argument resulted in segfault without the fix.
With the fix all three types of arguments are handled properly.

./zpool get state zpool root
NAME    PROPERTY  VALUE  SOURCE
root-0  state     ONLINE  -

./zpool get state zpool all-vdevs
NAME    PROPERTY  VALUE  SOURCE
root-0  state     ONLINE  -
/tmp/1.img  state     ONLINE  -
/tmp/2.img  state     ONLINE  -
./zpool get state zpool /tmp/1.img /tmp/2.img
NAME        PROPERTY  VALUE  SOURCE
/tmp/1.img  state     ONLINE  -
/tmp/2.img  state     ONLINE  -

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

…fs#15972).

The problem was identified in handling of the zpool get state command
line arguments. A pointer vdev was used to point to the argv[1], and
its address set to cb.cb_vdevs.cb_names(pointer to array of strings)
so any increment to cb_names resulted in a segfault. Fix covers a
special case of root parameter at argv[1] and remaining cases are
handled by passing in the argv + 1, which allows cb_names iteration
of next command line arguments (vdevs).

Signed-off-by: Syed Shahrukh Hussain <syed.shahrukh@ossrevival.org>
Copy link
Contributor

@tonyhutter tonyhutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I tested this patch and can confirm it fixes the issue.

@tonyhutter tonyhutter added the Status: Code Review Needed Ready for review and testing label Apr 4, 2025
@tonyhutter
Copy link
Contributor

Could we get one more reviewer to give this a quick look?

@tonyhutter tonyhutter merged commit 78a7c78 into openzfs:master Apr 4, 2025
21 of 23 checks passed
fuporovvStack pushed a commit to fuporovvStack/zfs that referenced this pull request Apr 11, 2025
…fs#15972). (openzfs#17213)

The problem was identified in handling of the zpool get state command
line arguments. A pointer vdev was used to point to the argv[1], and
its address set to cb.cb_vdevs.cb_names(pointer to array of strings)
so any increment to cb_names resulted in a segfault. Fix covers a
special case of root parameter at argv[1] and remaining cases are
handled by passing in the argv + 1, which allows cb_names iteration
of next command line arguments (vdevs).

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>

Signed-off-by: Syed Shahrukh Hussain <syed.shahrukh@ossrevival.org>
fuporovvStack pushed a commit to fuporovvStack/zfs that referenced this pull request Apr 11, 2025
…fs#15972). (openzfs#17213)

The problem was identified in handling of the zpool get state command
line arguments. A pointer vdev was used to point to the argv[1], and
its address set to cb.cb_vdevs.cb_names(pointer to array of strings)
so any increment to cb_names resulted in a segfault. Fix covers a
special case of root parameter at argv[1] and remaining cases are
handled by passing in the argv + 1, which allows cb_names iteration
of next command line arguments (vdevs).

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>

Signed-off-by: Syed Shahrukh Hussain <syed.shahrukh@ossrevival.org>
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Apr 15, 2025
…fs#15972). (openzfs#17213)

The problem was identified in handling of the zpool get state command
line arguments. A pointer vdev was used to point to the argv[1], and
its address set to cb.cb_vdevs.cb_names(pointer to array of strings)
so any increment to cb_names resulted in a segfault. Fix covers a
special case of root parameter at argv[1] and remaining cases are
handled by passing in the argv + 1, which allows cb_names iteration
of next command line arguments (vdevs).

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>

Signed-off-by: Syed Shahrukh Hussain <syed.shahrukh@ossrevival.org>
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Apr 16, 2025
…fs#15972). (openzfs#17213)

The problem was identified in handling of the zpool get state command
line arguments. A pointer vdev was used to point to the argv[1], and
its address set to cb.cb_vdevs.cb_names(pointer to array of strings)
so any increment to cb_names resulted in a segfault. Fix covers a
special case of root parameter at argv[1] and remaining cases are
handled by passing in the argv + 1, which allows cb_names iteration
of next command line arguments (vdevs).

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>

Signed-off-by: Syed Shahrukh Hussain <syed.shahrukh@ossrevival.org>
snajpa pushed a commit to vpsfreecz/zfs that referenced this pull request May 2, 2025
…fs#15972). (openzfs#17213)

The problem was identified in handling of the zpool get state command
line arguments. A pointer vdev was used to point to the argv[1], and
its address set to cb.cb_vdevs.cb_names(pointer to array of strings)
so any increment to cb_names resulted in a segfault. Fix covers a
special case of root parameter at argv[1] and remaining cases are
handled by passing in the argv + 1, which allows cb_names iteration
of next command line arguments (vdevs).

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>

Signed-off-by: Syed Shahrukh Hussain <syed.shahrukh@ossrevival.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants