Skip to content

Commit

Permalink
Fix function call with uninitialized value in vdev_inuse
Browse files Browse the repository at this point in the history
LLVM's static analyzer reported that we could pass an uninitialized
pool_guid to spa_by_guid() in vdev_inuse(). Upon review, it is correct.
An attempt to repurpose a spare or L2ARC drive from an exported pool
will cause the pool_guid passed to spa_by_guid() to be unintialized
information from the stack. This will cause non-deterministic behavior.
Since there is no reason why we cannot repurpose such disks, we modify
vdev_inuse() to avoid calling spa_by_guid() when they are detected.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #2330
  • Loading branch information
ryao authored and behlendorf committed Sep 23, 2014
1 parent 928ee9f commit 485c581
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/zfs/vdev_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ vdev_inuse(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason,
* read-only. Instead we look to see if the pools is marked
* read-only in the namespace and set the state to active.
*/
if ((spa = spa_by_guid(pool_guid, device_guid)) != NULL &&
if (state != POOL_STATE_SPARE && state != POOL_STATE_L2CACHE &&
(spa = spa_by_guid(pool_guid, device_guid)) != NULL &&
spa_mode(spa) == FREAD)
state = POOL_STATE_ACTIVE;

Expand Down

0 comments on commit 485c581

Please sign in to comment.