SCSI fixes on 20151031

This is three essential bug fixes for various SCSI parts.  The only affected
 users are SCSI multi-path via device handler (basically all the enterprise)
 and mvsas users.  The dh bugs are an async entanglement in boot resulting in a
 serious WARN_ON trip and a use after free on remove leading to a crash with
 strict memory accounting.  The mvsas bug manifests as a null deref oops but
 only on abort sequences; however, these can commonly occur with SATA attached
 devices, hence the fix.
 
 Signed-off-by: James Bottomley <JBottomley@Odin.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQEcBAABAgAGBQJWNDcYAAoJEDeqqVYsXL0M20oH/ioR0SAFJx5YJRCU2y3aTmTd
 ZCcLaRJTHkdu+rObn+gU54q6eCrg9Z7+gj1DSb/B55nAgi8pK+bMd+Im/X+w4fG5
 4WIj9P2HJX5YliDFONf68XWCeFyfAMFScEkLY8raOaFU+KtZGvpb/RQRwce0eAMF
 OiV+NK65ENZdVnfTCR3btyBq+FDvPL2dX5a3VK3NpTArrH0BF4/ZuoC7E/tYkKgo
 CQ6bGSyvx/loJlopLr3tcf4+tzCi4H8gr0cRLm9SHLbEwP0oXXpN9juVjiUbACIb
 6etoyJJ+MjlQLofem2bJ4ftnP8cAju+EllfBkJXD3VEsqTAd0r9+B6Rx3YPlo10=
 =jo6V
 -----END PGP SIGNATURE-----

Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "This is three essential bug fixes for various SCSI parts.

  The only affected users are SCSI multi-path via device handler
  (basically all the enterprise) and mvsas users.  The dh bugs are an
  async entanglement in boot resulting in a serious WARN_ON trip and a
  use after free on remove leading to a crash with strict memory
  accounting.  The mvsas bug manifests as a null deref oops but only on
  abort sequences; however, these can commonly occur with SATA attached
  devices, hence the fix"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi_dh: don't try to load a device handler during async probing
  scsi_dh: fix use-after-free when removing scsi device
  mvsas: Fix NULL pointer dereference in mvs_slot_task_free
This commit is contained in:
Linus Torvalds 2015-10-31 21:26:04 -07:00
commit 060b85b0d3
4 changed files with 12 additions and 2 deletions

View file

@ -887,6 +887,8 @@ static void mvs_slot_free(struct mvs_info *mvi, u32 rx_desc)
static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,
struct mvs_slot_info *slot, u32 slot_idx)
{
if (!slot)
return;
if (!slot->task)
return;
if (!sas_protocol_ata(task->task_proto))

View file

@ -226,16 +226,20 @@ int scsi_dh_add_device(struct scsi_device *sdev)
drv = scsi_dh_find_driver(sdev);
if (drv)
devinfo = scsi_dh_lookup(drv);
devinfo = __scsi_dh_lookup(drv);
if (devinfo)
err = scsi_dh_handler_attach(sdev, devinfo);
return err;
}
void scsi_dh_remove_device(struct scsi_device *sdev)
void scsi_dh_release_device(struct scsi_device *sdev)
{
if (sdev->handler)
scsi_dh_handler_detach(sdev);
}
void scsi_dh_remove_device(struct scsi_device *sdev)
{
device_remove_file(&sdev->sdev_gendev, &scsi_dh_state_attr);
}

View file

@ -173,9 +173,11 @@ extern struct async_domain scsi_sd_probe_domain;
/* scsi_dh.c */
#ifdef CONFIG_SCSI_DH
int scsi_dh_add_device(struct scsi_device *sdev);
void scsi_dh_release_device(struct scsi_device *sdev);
void scsi_dh_remove_device(struct scsi_device *sdev);
#else
static inline int scsi_dh_add_device(struct scsi_device *sdev) { return 0; }
static inline void scsi_dh_release_device(struct scsi_device *sdev) { }
static inline void scsi_dh_remove_device(struct scsi_device *sdev) { }
#endif

View file

@ -399,6 +399,8 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
sdev = container_of(work, struct scsi_device, ew.work);
scsi_dh_release_device(sdev);
parent = sdev->sdev_gendev.parent;
spin_lock_irqsave(sdev->host->host_lock, flags);