lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <4CFCB0AE.8050804@jp.fujitsu.com>
Date:	Mon, 06 Dec 2010 18:45:18 +0900
From:	Yasuaki Ishimatsu <isimatu.yasuaki@...fujitsu.com>
To:	jaxboe@...ionio.com, vgoyal@...hat.com, jmarchan@...hat.com,
	torvalds@...ux-foundation.org, linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] Change a argument of disk_map_sector_rcu() to hd_part->start_sect
 from req->__sector

From: Yasuaki Ishimatsu <isimatu.yasuaki@...fujitsu.com>

PROBLEM:

The previous patch does not fix the problem completely, since the problem occurs
on following case.

When sdX region is between sdX1 partition and sdX2 partition, a sdX region's
I/O is merged sdX1 partition's I/O or sdX2 partition's I/O.

1. sdX region is between sdX1 partition and sdX2 partition

    sdX1 partition   sdX region   sdX1 partition
  |----------------|------------|----------------|

2. issue a sdX region's I/O and increment a in_flight of sdX

    sdX1 partition   sdX region   sdX1 partition
  |----------------|------------|----------------|
                    <-   I/O  ->

3. issue a sdX1 partition's I/O

    sdX1 partition   sdX region   sdX1 partition
  |----------------|------------|----------------|
       <-   I/O  -> <-   I/O  ->

4. merge a sdX1 partition's I/O and a sdX region's I/O, since the previous patch
   cannot care this case.

    sdX1 partition   sdX region   sdX1 partition
  |----------------|------------|----------------|
       <-         I/O         ->

5. finish a I/O and decrement a in_flight of sdX1 even though it was not
   incremented

HOW TO FIX:

The patch fixes avobe case by changing a argument of disk_map_sector_rcu().

The problem also is caused by merging different partition's I/Os. But, it is not easy
to fix, when I/O is sdX region. So the patch allows step 4, when I/O is only sdX
region. But, it does not change a result of disk_map_sector_rcu() by using partition's
start sector ot original I/O , even if the I/O is merged.

Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@...fujitsu.com>

---
 block/blk-core.c  |   10 ++++++----
 block/blk-merge.c |    2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

Index: linux-2.6.37-rc3/block/blk-core.c
===================================================================
--- linux-2.6.37-rc3.orig/block/blk-core.c	2010-12-03 17:15:50.000000000 +0900
+++ linux-2.6.37-rc3/block/blk-core.c	2010-12-03 17:15:54.000000000 +0900
@@ -64,11 +64,13 @@ static void drive_stat_acct(struct reque
 		return;

 	cpu = part_stat_lock();
-	part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq));

-	if (!new_io)
+	if (!new_io) {
+		part = disk_map_sector_rcu(rq->rq_disk, blk_rq_part_sector(rq));
 		part_stat_inc(cpu, part, merges[rw]);
+	}
 	else {
+		part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq));
 		part_round_stats(cpu, part);
 		part_inc_in_flight(part, rw);
 		rq->__part_start_sect = part->start_sect;
@@ -1778,7 +1780,7 @@ static void blk_account_io_completion(st
 		int cpu;

 		cpu = part_stat_lock();
-		part = disk_map_sector_rcu(req->rq_disk, blk_rq_pos(req));
+		part = disk_map_sector_rcu(req->rq_disk, blk_rq_part_sector(req));
 		part_stat_add(cpu, part, sectors[rw], bytes >> 9);
 		part_stat_unlock();
 	}
@@ -1798,7 +1800,7 @@ static void blk_account_io_done(struct r
 		int cpu;

 		cpu = part_stat_lock();
-		part = disk_map_sector_rcu(req->rq_disk, blk_rq_pos(req));
+		part = disk_map_sector_rcu(req->rq_disk, blk_rq_part_sector(req));

 		part_stat_inc(cpu, part, ios[rw]);
 		part_stat_add(cpu, part, ticks[rw], duration);
Index: linux-2.6.37-rc3/block/blk-merge.c
===================================================================
--- linux-2.6.37-rc3.orig/block/blk-merge.c	2010-12-03 17:15:50.000000000 +0900
+++ linux-2.6.37-rc3/block/blk-merge.c	2010-12-03 17:15:54.000000000 +0900
@@ -356,7 +356,7 @@ static void blk_account_io_merge(struct
 		int cpu;

 		cpu = part_stat_lock();
-		part = disk_map_sector_rcu(req->rq_disk, blk_rq_pos(req));
+		part = disk_map_sector_rcu(req->rq_disk, blk_rq_part_sector(req));

 		part_round_stats(cpu, part);
 		part_dec_in_flight(part, rq_data_dir(req));

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ