Skip to content

Commit db7ba07

Browse files
Stefan Haberlandaxboe
authored andcommitted
s390/dasd: fix Oops in dasd_alias_get_start_dev due to missing pavgroup
Fix Oops in dasd_alias_get_start_dev() function caused by the pavgroup pointer being NULL. The pavgroup pointer is checked on the entrance of the function but without the lcu->lock being held. Therefore there is a race window between dasd_alias_get_start_dev() and _lcu_update() which sets pavgroup to NULL with the lcu->lock held. Fix by checking the pavgroup pointer with lcu->lock held. Cc: <stable@vger.kernel.org> # 2.6.25+ Fixes: 8e09f21 ("[S390] dasd: add hyper PAV support to DASD device driver, part 1") Signed-off-by: Stefan Haberland <sth@linux.ibm.com> Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com> Link: https://lore.kernel.org/r/20220919154931.4123002-2-sth@linux.ibm.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c4fa368 commit db7ba07

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/s390/block/dasd_alias.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,12 +675,12 @@ int dasd_alias_remove_device(struct dasd_device *device)
675675
struct dasd_device *dasd_alias_get_start_dev(struct dasd_device *base_device)
676676
{
677677
struct dasd_eckd_private *alias_priv, *private = base_device->private;
678-
struct alias_pav_group *group = private->pavgroup;
679678
struct alias_lcu *lcu = private->lcu;
680679
struct dasd_device *alias_device;
680+
struct alias_pav_group *group;
681681
unsigned long flags;
682682

683-
if (!group || !lcu)
683+
if (!lcu)
684684
return NULL;
685685
if (lcu->pav == NO_PAV ||
686686
lcu->flags & (NEED_UAC_UPDATE | UPDATE_PENDING))
@@ -697,6 +697,11 @@ struct dasd_device *dasd_alias_get_start_dev(struct dasd_device *base_device)
697697
}
698698

699699
spin_lock_irqsave(&lcu->lock, flags);
700+
group = private->pavgroup;
701+
if (!group) {
702+
spin_unlock_irqrestore(&lcu->lock, flags);
703+
return NULL;
704+
}
700705
alias_device = group->next;
701706
if (!alias_device) {
702707
if (list_empty(&group->aliaslist)) {

0 commit comments

Comments
 (0)