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]
Date:   Thu, 5 Mar 2020 11:49:35 +0100
From:   Roger Pau Monné <roger.pau@...rix.com>
To:     Juergen Gross <jgross@...e.com>
CC:     <xen-devel@...ts.xenproject.org>, <linux-block@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>,
        Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
        Boris Ostrovsky <boris.ostrovsky@...cle.com>,
        Stefano Stabellini <sstabellini@...nel.org>,
        Jens Axboe <axboe@...nel.dk>
Subject: Re: [PATCH] xen/blkfront: fix ring info addressing

On Thu, Mar 05, 2020 at 11:03:31AM +0100, Juergen Gross wrote:
> Commit 0265d6e8ddb890 ("xen/blkfront: limit allocated memory size to
> actual use case") made struct blkfront_ring_info size dynamic. This is
> fine when running with only one queue, but with multiple queues the
> addressing of the single queues has to be adapted as the structs are
> allocated in an array.

Thanks, and sorry for not catching this during review.

> 
> Fixes: 0265d6e8ddb890 ("xen/blkfront: limit allocated memory size to actual use case")
> Signed-off-by: Juergen Gross <jgross@...e.com>
> ---
>  drivers/block/xen-blkfront.c | 82 ++++++++++++++++++++++++--------------------
>  1 file changed, 45 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index e2ad6bba2281..a8d4a3838e5d 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -213,6 +213,7 @@ struct blkfront_info
>  	struct blk_mq_tag_set tag_set;
>  	struct blkfront_ring_info *rinfo;
>  	unsigned int nr_rings;
> +	unsigned int rinfo_size;
>  	/* Save uncomplete reqs and bios for migration. */
>  	struct list_head requests;
>  	struct bio_list bio_list;
> @@ -259,6 +260,21 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo);
>  static void blkfront_gather_backend_features(struct blkfront_info *info);
>  static int negotiate_mq(struct blkfront_info *info);
>  
> +#define rinfo_ptr(rinfo, off) \
> +	(struct blkfront_ring_info *)((unsigned long)(rinfo) + (off))
                                      ^ void * would seem more natural IMO.

Also if you use void * you don't need the extra (struct
blkfront_ring_info *) cast I think?

I however think this macro is kind of weird, since it's just doing an
addition. I would rather have that calculation in get_rinfo and code
for_each_rinfo on top of that.

I agree this might be a question of taste, so I'm not going to insist
but that would reduce the number of helpers from 3 to 2.

> +
> +#define for_each_rinfo(info, rinfo, idx)				\
> +	for (rinfo = info->rinfo, idx = 0;				\
> +	     idx < info->nr_rings;					\
> +	     idx++, rinfo = rinfo_ptr(rinfo, info->rinfo_size))

I think the above is missing proper parentheses around macro
parameters.

> +
> +static struct blkfront_ring_info *get_rinfo(struct blkfront_info *info,
> +					    unsigned int i)

inline attribute might be appropriate here.

Thanks, Roger.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ