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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181130195607.GA27411@vader>
Date:   Fri, 30 Nov 2018 11:56:07 -0800
From:   Omar Sandoval <osandov@...ndov.com>
To:     Huijin Park <huijin.park@...sung.com>
Cc:     Andreas Dilger <adilger.kernel@...ger.ca>,
        Michael Callahan <michaelcallahan@...com>,
        Omar Sandoval <osandov@...com>, js07.lee@...sung.com,
        Huijin Park <bbanghj.park@...il.com>,
        linux-block@...r.kernel.org, linux-ext4@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH,1/2] genhd: avoid overflow of sectors in disk_stats

On Fri, Nov 30, 2018 at 04:32:40AM -0500, Huijin Park wrote:
> From: "huijin.park" <huijin.park@...sung.com>
> 
> This patch changes the 'sectors' type to an u64.
> In 32 bit system, the 'sectors' can accumulate up to about 2TiB.
> If a 32 bit system makes i/o over 2TiB while running,
> the 'sectors' will overflow.
> As a result, the part_stat_read(sectors), the diskstats in proc and
> the (lifetime|session)_write_kbytes in sysfs return invalid statistic.

What about parsers which expect it to be an unsigned long? E.g., iostat:
https://github.com/sysstat/sysstat/blob/v12.1.1/rd_stats.c#L736

At least with glibc, scanf seems to truncate sanely, but this appears to
be undefined.

> Signed-off-by: huijin.park <huijin.park@...sung.com>
> ---
>  block/genhd.c         |    6 +++---
>  include/linux/genhd.h |    2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/block/genhd.c b/block/genhd.c
> index 0145bcb..7518dcd 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1343,10 +1343,10 @@ static int diskstats_show(struct seq_file *seqf, void *v)
>  		part_stat_unlock();
>  		part_in_flight(gp->queue, hd, inflight);
>  		seq_printf(seqf, "%4d %7d %s "
> -			   "%lu %lu %lu %u "
> -			   "%lu %lu %lu %u "
> +			   "%lu %lu %llu %u "
> +			   "%lu %lu %llu %u "
>  			   "%u %u %u "
> -			   "%lu %lu %lu %u\n",
> +			   "%lu %lu %llu %u\n",
>  			   MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
>  			   disk_name(gp, hd->partno, buf),
>  			   part_stat_read(hd, ios[STAT_READ]),
> diff --git a/include/linux/genhd.h b/include/linux/genhd.h
> index 0c5ee17..5bf86f9 100644
> --- a/include/linux/genhd.h
> +++ b/include/linux/genhd.h
> @@ -84,7 +84,7 @@ struct partition {
>  
>  struct disk_stats {
>  	u64 nsecs[NR_STAT_GROUPS];
> -	unsigned long sectors[NR_STAT_GROUPS];
> +	u64 sectors[NR_STAT_GROUPS];
>  	unsigned long ios[NR_STAT_GROUPS];
>  	unsigned long merges[NR_STAT_GROUPS];
>  	unsigned long io_ticks;
> -- 
> 1.7.9.5
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ