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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 06 Oct 2017 10:58:59 +1100
From:   NeilBrown <neilb@...e.com>
To:     Matthias Kaehlcke <mka@...omium.org>, Shaohua Li <shli@...nel.org>
Cc:     linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
        Arnd Bergmann <arnd@...db.de>,
        Michael Davidson <md@...gle.com>,
        Guenter Roeck <groeck@...omium.org>,
        Matthias Kaehlcke <mka@...omium.org>
Subject: Re: [PATCH] md: raid10: remove VLAIS

On Thu, Oct 05 2017, Matthias Kaehlcke wrote:

> The raid10 driver can't be built with clang since it uses a variable
> length array in a structure (VLAIS):
>
> drivers/md/raid10.c:4583:17: error: fields must have a constant size:
>   'variable length array in structure' extension will never be supported
>
> Allocate the r10bio struct with kmalloc instead of using the VLAIS
> construct.
>
> Signed-off-by: Matthias Kaehlcke <mka@...omium.org>
> ---
>  drivers/md/raid10.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 374df5796649..9616163eaf8c 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -4578,15 +4578,16 @@ static int handle_reshape_read_error(struct mddev *mddev,
>  	/* Use sync reads to get the blocks from somewhere else */
>  	int sectors = r10_bio->sectors;
>  	struct r10conf *conf = mddev->private;
> -	struct {
> -		struct r10bio r10_bio;
> -		struct r10dev devs[conf->copies];
> -	} on_stack;
> -	struct r10bio *r10b = &on_stack.r10_bio;
> +	struct r10bio *r10b;
>  	int slot = 0;
>  	int idx = 0;
>  	struct page **pages;
>  
> +	r10b = kmalloc(sizeof(*r10b) +
> +	       sizeof(struct r10dev) * conf->copies, GFP_KERNEL);

GFP_KERNEL isn't a good idea here.
This could wait for writeback, and if writeback tries to write to the
region of the array which is being reshaped, it might deadlock.

GFP_NOIO is safer.

given that conf->copies is almost always 2 it might be nicer to
have

	struct {
		struct r10bio r10_bio;
		struct r10dev devs[2];
	} on_stack;

        struct r10bio *r10b;

	if (conf->copies <= ARRAY_SIZE(on_stack.devs))
        	r10b = &on_stack.r10_bio;
        else
        	r10b = kmalloc(sizeof(*r10b) +
			       sizeof(struct r10dev) * conf->copies, GFP_NOIO);


Thanks,
NeilBrown


> +	if (!r10b)
> +		return -ENOMEM;
> +
>  	/* reshape IOs share pages from .devs[0].bio */
>  	pages = get_resync_pages(r10_bio->devs[0].bio)->pages;
>  
> @@ -4635,11 +4636,13 @@ static int handle_reshape_read_error(struct mddev *mddev,
>  			/* couldn't read this block, must give up */
>  			set_bit(MD_RECOVERY_INTR,
>  				&mddev->recovery);
> +			kfree(r10b);
>  			return -EIO;
>  		}
>  		sectors -= s;
>  		idx++;
>  	}
> +	kfree(r10b);
>  	return 0;
>  }
>  
> -- 
> 2.14.2.920.gcf0c67979c-goog

Download attachment "signature.asc" of type "application/pgp-signature" (833 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ