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: <ZJMEtGw+FYT8mRG+@araj-dh-work>
Date:   Wed, 21 Jun 2023 07:09:56 -0700
From:   Ashok Raj <ashok_raj@...ux.intel.com>
To:     linan666@...weicloud.com
Cc:     axboe@...nel.dk, linan122@...wei.com, dan.j.williams@...el.com,
        vishal.l.verma@...el.com, linux-block@...r.kernel.org,
        linux-kernel@...r.kernel.org, yukuai3@...wei.com,
        yi.zhang@...wei.com, houtao1@...wei.com, yangerkun@...wei.com,
        Ashok Raj <ashok.raj@...el.com>
Subject: Re: [PATCH v3 3/4] block/badblocks: fix badblocks loss when
 badblocks combine

On Thu, Jun 22, 2023 at 01:20:51AM +0800, linan666@...weicloud.com wrote:
> From: Li Nan <linan122@...wei.com>
> 
> badblocks will loss if we set it as below:
> 
>   # echo 1 1 > bad_blocks
>   # echo 3 1 > bad_blocks
>   # echo 1 5 > bad_blocks
>   # cat bad_blocks
>     1 3
> 
> In badblocks_set(), if there is an intersection between p[lo] and p[hi],
> we will combine them. The end of new badblocks is p[hi]'s end now. but
> p[lo] may cross p[hi] and new end should be the larger of p[lo] and p[hi].

Reconsider rewriting the commit log. It seems you converted code to
sentence ;-). 

Also it might help to show after the patch how the above example would be
for cat bad_blocks

> 
> Fixes: 9e0e252a048b ("badblocks: Add core badblock management code")
> Signed-off-by: Li Nan <linan122@...wei.com>
> ---
>  block/badblocks.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/block/badblocks.c b/block/badblocks.c
> index 7e6ebe2ac12c..2c2ef8284a3f 100644
> --- a/block/badblocks.c
> +++ b/block/badblocks.c
> @@ -267,16 +267,14 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors,
>  	if (sectors == 0 && hi < bb->count) {
>  		/* we might be able to combine lo and hi */
>  		/* Note: 's' is at the end of 'lo' */
> -		sector_t a = BB_OFFSET(p[hi]);
> -		int lolen = BB_LEN(p[lo]);
> -		int hilen = BB_LEN(p[hi]);
> -		int newlen = lolen + hilen - (s - a);
> +		sector_t a = BB_OFFSET(p[lo]);
> +		int newlen = max(s, BB_OFFSET(p[hi]) + BB_LEN(p[hi])) - a;
>  
> -		if (s >= a && newlen < BB_MAX_LEN) {
> +		if (s >= BB_OFFSET(p[hi]) && newlen < BB_MAX_LEN) {
>  			/* yes, we can combine them */
>  			int ack = BB_ACK(p[lo]) && BB_ACK(p[hi]);
>  
> -			p[lo] = BB_MAKE(BB_OFFSET(p[lo]), newlen, ack);
> +			p[lo] = BB_MAKE(a, newlen, ack);
>  			memmove(p + hi, p + hi + 1,
>  				(bb->count - hi - 1) * 8);
>  			bb->count--;
> -- 
> 2.39.2
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ