Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 03/13] ide: Potential null pointer dereference in ide_queue_pc_tail()

The function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-atapi.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index fac3d9d..8bf4109 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
 <at>  <at>  -93,6 +93,12  <at>  <at>  int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
 	int error;

 	rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
+
+	if (!rq) {
+		printk(KERN_ERR PFX"ide_queue_pc_tail: blk_get_request() failed. \n");
+		return 1;
+	}
(Continue reading)

Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 05/13] ide: Potential null pointer dereference in ide_raw_taskfile()

The function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-taskfile.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 729428e..655d894 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
 <at>  <at>  -432,6 +432,10  <at>  <at>  int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
 	int rw = !(cmd->tf_flags & IDE_TFLAG_WRITE) ? READ : WRITE;

 	rq = blk_get_request(drive->queue, rw, __GFP_WAIT);
+
+	if (!rq)
+		return -EIO;
+
 	rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
(Continue reading)

Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 11/13] ide: Potential null pointer dereference in idetape_queue_rw_tail()

The function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-tape.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index ce8237d..c27b05c 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
 <at>  <at>  -853,6 +853,8  <at>  <at>  static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
 	BUG_ON(size < 0 || size % tape->blk_size);

 	rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
+	if (!rq)
+		return -EIO;
 	rq->cmd_type = REQ_TYPE_SPECIAL;
 	rq->cmd[13] = cmd;
 	rq->rq_disk = tape->disk;
(Continue reading)

Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 12/13] ide: Potential null pointer dereference in issue_park_cmd()

The function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-park.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index 6ab9ab2..4d178bd 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
 <at>  <at>  -32,6 +32,8  <at>  <at>  static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
 	spin_unlock_irq(&hwif->lock);

 	rq = blk_get_request(q, READ, __GFP_WAIT);
+	if (!rq)
+		goto out;
 	rq->cmd[0] = REQ_PARK_HEADS;
 	rq->cmd_len = 1;
 	rq->cmd_type = REQ_TYPE_SPECIAL;
(Continue reading)

Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 10/13] ide: Potential null pointer dereference in ide_cd_queue_pc()

The function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-cd.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 8126824..9dd575d 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
 <at>  <at>  -443,6 +443,9  <at>  <at>  int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,

 		rq = blk_get_request(drive->queue, write, __GFP_WAIT);

+		if (!rq)
+			return -EIO;
+
 		memcpy(rq->cmd, cmd, BLK_MAX_CDB);
 		rq->cmd_type = REQ_TYPE_ATA_PC;
(Continue reading)

Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 09/13] ide: Potential null pointer dereference in set_multcount()

The function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-disk.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 16f69be..538d206 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
 <at>  <at>  -479,6 +479,10  <at>  <at>  static int set_multcount(ide_drive_t *drive, int arg)
 		return -EBUSY;

 	rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
+	if (!rq) {
+		printk(KERN_ERR PFX"set_multcount: blk_get_request() failed. \n");
+		return 1;
+	}
 	rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
(Continue reading)

Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 04/13] ide: Potential null pointer dereference in ide_cdrom_reset()

The function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-cd_ioctl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index 02caa7d..e29588f 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
 <at>  <at>  -304,6 +304,10  <at>  <at>  int ide_cdrom_reset(struct cdrom_device_info *cdi)
 	int ret;

 	rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
+
+	if (!rq)
+		return -EIO;
+
 	rq->cmd_type = REQ_TYPE_SPECIAL;
(Continue reading)

Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 08/13] ide: Potential null pointer dereference in ide_devset_execute()

The function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-devsets.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c
index 9e98122..acdb87f 100644
--- a/drivers/ide/ide-devsets.c
+++ b/drivers/ide/ide-devsets.c
 <at>  <at>  -166,6 +166,8  <at>  <at>  int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
 		return setting->set(drive, arg);

 	rq = blk_get_request(q, READ, __GFP_WAIT);
+	if (!rq)
+		return -EIO;
 	rq->cmd_type = REQ_TYPE_SPECIAL;
 	rq->cmd_len = 5;
 	rq->cmd[0] = REQ_DEVSET_EXEC;
(Continue reading)

Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 07/13] ide: Potential null pointer dereference in ide_cmd_ioctl()

The function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-ioctls.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index 4d19eb9..463f0ff 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
 <at>  <at>  -126,6 +126,8  <at>  <at>  static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
 		struct request *rq;

 		rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
+		if (!rq)
+			return err;
 		rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
 		err = blk_execute_rq(drive->queue, NULL, rq, 0);
 		blk_put_request(rq);
(Continue reading)

Marina Makienko | 9 Aug 2012 15:55
Picon

[PATCH 06/13] ide: Potential null pointer dereference in generic_ide_resume()

he function blk_get_request() can return NULL in some cases. There are
checks on it if function is called with argumetns one of which is
GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
blk_get_request() return NULL.

But if there is function call with argument __GFP_WAIT
the system will wait until get request or the queue becomes
dead. If something kills the queue, blk_get_request()
return NULL and next operations will lead to errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Marina Makienko <makienko <at> ispras.ru>
---
 drivers/ide/ide-pm.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index 9240609..4412f24 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
 <at>  <at>  -19,6 +19,10  <at>  <at>  int generic_ide_suspend(struct device *dev, pm_message_t mesg)

 	memset(&rqpm, 0, sizeof(rqpm));
 	rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
+
+	if (!rq)
+		return -EIO;
+
 	rq->cmd_type = REQ_TYPE_PM_SUSPEND;
(Continue reading)

Alan Cox | 9 Aug 2012 16:13
Face
Picon

Re: [PATCH 03/13] ide: Potential null pointer dereference in ide_queue_pc_tail()

On Thu,  9 Aug 2012 17:55:20 +0400
Marina Makienko <makienko <at> ispras.ru> wrote:

> The function blk_get_request() can return NULL in some cases. There are
> checks on it if function is called with argumetns one of which is
> GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
> blk_get_request() return NULL.

drivers/ide is obsolete and scheduled for removal. I'm not sure messing
with it is remotely useful at this point ?
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

David Miller | 9 Aug 2012 23:49
Favicon

Re: [PATCH 03/13] ide: Potential null pointer dereference in ide_queue_pc_tail()

From: Alan Cox <alan <at> lxorguk.ukuu.org.uk>
Date: Thu, 9 Aug 2012 15:13:42 +0100

> On Thu,  9 Aug 2012 17:55:20 +0400
> Marina Makienko <makienko <at> ispras.ru> wrote:
> 
>> The function blk_get_request() can return NULL in some cases. There are
>> checks on it if function is called with argumetns one of which is
>> GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
>> blk_get_request() return NULL.
> 
> drivers/ide is obsolete and scheduled for removal. I'm not sure messing
> with it is remotely useful at this point ?

Agreed, I'm not applying this stuff.
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Sergei Shtylyov | 17 Aug 2012 19:00

Re: [PATCH 03/13] ide: Potential null pointer dereference in ide_queue_pc_tail()

Hello.

On 09.08.2012 18:13, Alan Cox wrote:

> On Thu,  9 Aug 2012 17:55:20 +0400
> Marina Makienko <makienko <at> ispras.ru> wrote:

>> The function blk_get_request() can return NULL in some cases. There are
>> checks on it if function is called with argumetns one of which is
>> GFP_ATOMIC/GFP_NOIO/etc. If system couldn't find request
>> blk_get_request() return NULL.

> drivers/ide is obsolete and scheduled for removal.

    When it was scheduled for removal? I can't find an entry in 
Documentation/feature-removal-schedule.txt. And how can that be when there 
are still many unconverted drivers?

> I'm not sure messing with it is remotely useful at this point ?

    It's being maintained for bug fixes still, AFAIK.

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

(Continue reading)


Gmane