kernel/scsi-sd_revalidate_disk-prevent-NULL-ptr-deref.patch

40 lines
1.3 KiB
Diff
Raw Normal View History

2016-02-18 22:29:11 +00:00
From 7afe9a8d7dca86a8f35250f21f5f0a62ea2fedf7 Mon Sep 17 00:00:00 2001
From: "kernel-team@fedoraproject.org" <kernel-team@fedoraproject.org>
Date: Fri, 10 Feb 2012 14:56:13 -0500
Subject: [PATCH] scsi: sd_revalidate_disk prevent NULL ptr deref
Bugzilla: 754518
Upstream-status: Fedora mustard (might be worth dropping...)
---
drivers/scsi/sd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
2014-08-08 09:42:06 +00:00
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
2016-02-18 22:29:11 +00:00
index 3d22fc3..07aec76 100644
2014-08-08 09:42:06 +00:00
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
2016-02-18 22:29:11 +00:00
@@ -2825,7 +2825,7 @@ static inline u32 logical_to_sectors(struct scsi_device *sdev, u32 blocks)
static int sd_revalidate_disk(struct gendisk *disk)
{
struct scsi_disk *sdkp = scsi_disk(disk);
- struct scsi_device *sdp = sdkp->device;
+ struct scsi_device *sdp;
2016-02-18 22:29:11 +00:00
struct request_queue *q = sdkp->disk->queue;
unsigned char *buffer;
2016-02-18 22:29:11 +00:00
unsigned int dev_max, rw_max;
@@ -2833,6 +2833,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
"sd_revalidate_disk\n"));
+ if (WARN_ONCE((!sdkp), "Invalid scsi_disk from %p\n", disk))
+ goto out;
+
+ sdp = sdkp->device;
+
/*
* If the device is offline, don't try and read capacity or any
* of the other niceties.
2016-02-18 22:29:11 +00:00
--
2.5.0