All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers
@ 2018-05-22 15:27 Bart Van Assche
  2018-05-22 17:58 ` Jens Axboe
  2018-05-23 14:57   ` Damien Le Moal
  0 siblings, 2 replies; 6+ messages in thread
From: Bart Van Assche @ 2018-05-22 15:27 UTC (permalink / raw
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche, Shaun Tancheff,
	Damien Le Moal, Martin K . Petersen, Hannes Reinecke, stable

Avoid that complaints similar to the following appear in the kernel log
if the number of zones is sufficiently large:

  fio: page allocation failure: order:9, mode:0x140c0c0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null)
  Call Trace:
  dump_stack+0x63/0x88
  warn_alloc+0xf5/0x190
  __alloc_pages_slowpath+0x8f0/0xb0d
  __alloc_pages_nodemask+0x242/0x260
  alloc_pages_current+0x6a/0xb0
  kmalloc_order+0x18/0x50
  kmalloc_order_trace+0x26/0xb0
  __kmalloc+0x20e/0x220
  blkdev_report_zones_ioctl+0xa5/0x1a0
  blkdev_ioctl+0x1ba/0x930
  block_ioctl+0x41/0x50
  do_vfs_ioctl+0xaa/0x610
  SyS_ioctl+0x79/0x90
  do_syscall_64+0x79/0x1b0
  entry_SYSCALL_64_after_hwframe+0x3d/0xa2

Fixes: 3ed05a987e0f ("blk-zoned: implement ioctls")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Shaun Tancheff <shaun.tancheff@seagate.com>
Cc: Damien Le Moal <damien.lemoal@hgst.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: <stable@vger.kernel.org>
---
 block/blk-zoned.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 20bfc37e1852..92e6108487c4 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -328,7 +328,11 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!rep.nr_zones)
 		return -EINVAL;
 
-	zones = kcalloc(rep.nr_zones, sizeof(struct blk_zone), GFP_KERNEL);
+	if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone))
+		return -ERANGE;
+
+	zones = kvmalloc(rep.nr_zones * sizeof(struct blk_zone),
+			GFP_KERNEL | __GFP_ZERO);
 	if (!zones)
 		return -ENOMEM;
 
@@ -350,7 +354,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
 	}
 
  out:
-	kfree(zones);
+	kvfree(zones);
 
 	return ret;
 }
-- 
2.16.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers
  2018-05-22 15:27 [PATCH] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers Bart Van Assche
@ 2018-05-22 17:58 ` Jens Axboe
  2018-06-13 15:20   ` Bart Van Assche
  2018-05-23 14:57   ` Damien Le Moal
  1 sibling, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2018-05-22 17:58 UTC (permalink / raw
  To: Bart Van Assche
  Cc: linux-block, Christoph Hellwig, Shaun Tancheff, Damien Le Moal,
	Martin K . Petersen, Hannes Reinecke, stable

On 5/22/18 9:27 AM, Bart Van Assche wrote:
> Avoid that complaints similar to the following appear in the kernel log
> if the number of zones is sufficiently large:
> 
>   fio: page allocation failure: order:9, mode:0x140c0c0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null)
>   Call Trace:
>   dump_stack+0x63/0x88
>   warn_alloc+0xf5/0x190
>   __alloc_pages_slowpath+0x8f0/0xb0d
>   __alloc_pages_nodemask+0x242/0x260
>   alloc_pages_current+0x6a/0xb0
>   kmalloc_order+0x18/0x50
>   kmalloc_order_trace+0x26/0xb0
>   __kmalloc+0x20e/0x220
>   blkdev_report_zones_ioctl+0xa5/0x1a0
>   blkdev_ioctl+0x1ba/0x930
>   block_ioctl+0x41/0x50
>   do_vfs_ioctl+0xaa/0x610
>   SyS_ioctl+0x79/0x90
>   do_syscall_64+0x79/0x1b0
>   entry_SYSCALL_64_after_hwframe+0x3d/0xa2

Applied, thanks.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers
  2018-05-22 15:27 [PATCH] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers Bart Van Assche
@ 2018-05-23 14:57   ` Damien Le Moal
  2018-05-23 14:57   ` Damien Le Moal
  1 sibling, 0 replies; 6+ messages in thread
From: Damien Le Moal @ 2018-05-23 14:57 UTC (permalink / raw
  To: Bart Van Assche, Jens Axboe
  Cc: linux-block@vger.kernel.org, Christoph Hellwig, Damien Le Moal,
	Martin K . Petersen, Hannes Reinecke, stable@vger.kernel.org

T24gMjAxOC8wNS8yMiA4OjI3LCBCYXJ0IFZhbiBBc3NjaGUgd3JvdGU6DQo+IEF2b2lkIHRoYXQg
Y29tcGxhaW50cyBzaW1pbGFyIHRvIHRoZSBmb2xsb3dpbmcgYXBwZWFyIGluIHRoZSBrZXJuZWwg
bG9nDQo+IGlmIHRoZSBudW1iZXIgb2Ygem9uZXMgaXMgc3VmZmljaWVudGx5IGxhcmdlOg0KPiAN
Cj4gICBmaW86IHBhZ2UgYWxsb2NhdGlvbiBmYWlsdXJlOiBvcmRlcjo5LCBtb2RlOjB4MTQwYzBj
MChHRlBfS0VSTkVMfF9fR0ZQX0NPTVB8X19HRlBfWkVSTyksIG5vZGVtYXNrPShudWxsKQ0KPiAg
IENhbGwgVHJhY2U6DQo+ICAgZHVtcF9zdGFjaysweDYzLzB4ODgNCj4gICB3YXJuX2FsbG9jKzB4
ZjUvMHgxOTANCj4gICBfX2FsbG9jX3BhZ2VzX3Nsb3dwYXRoKzB4OGYwLzB4YjBkDQo+ICAgX19h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o+IC0Ja2ZyZWUoem9uZXMpOw0K
PiArCWt2ZnJlZSh6b25lcyk7DQo+ICANCj4gIAlyZXR1cm4gcmV0Ow0KPiAgfQ0KPiANClJldmll
d2VkLWJ5OiBEYW1pZW4gTGUgTW9hbCA8ZGFtaWVuLmxlbW9hbEB3ZGMuY29tPg0KDQotLSANCkRh
bWllbiBMZSBNb2FsDQpXZXN0ZXJuIERpZ2l0YWwgUmVzZWFyY2g=

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers
@ 2018-05-23 14:57   ` Damien Le Moal
  0 siblings, 0 replies; 6+ messages in thread
From: Damien Le Moal @ 2018-05-23 14:57 UTC (permalink / raw
  To: Bart Van Assche, Jens Axboe
  Cc: linux-block@vger.kernel.org, Christoph Hellwig, Damien Le Moal,
	Martin K . Petersen, Hannes Reinecke, stable@vger.kernel.org

On 2018/05/22 8:27, Bart Van Assche wrote:
> Avoid that complaints similar to the following appear in the kernel log
> if the number of zones is sufficiently large:
> 
>   fio: page allocation failure: order:9, mode:0x140c0c0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null)
>   Call Trace:
>   dump_stack+0x63/0x88
>   warn_alloc+0xf5/0x190
>   __alloc_pages_slowpath+0x8f0/0xb0d
>   __alloc_pages_nodemask+0x242/0x260
>   alloc_pages_current+0x6a/0xb0
>   kmalloc_order+0x18/0x50
>   kmalloc_order_trace+0x26/0xb0
>   __kmalloc+0x20e/0x220
>   blkdev_report_zones_ioctl+0xa5/0x1a0
>   blkdev_ioctl+0x1ba/0x930
>   block_ioctl+0x41/0x50
>   do_vfs_ioctl+0xaa/0x610
>   SyS_ioctl+0x79/0x90
>   do_syscall_64+0x79/0x1b0
>   entry_SYSCALL_64_after_hwframe+0x3d/0xa2
> 
> Fixes: 3ed05a987e0f ("blk-zoned: implement ioctls")
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Shaun Tancheff <shaun.tancheff@seagate.com>
> Cc: Damien Le Moal <damien.lemoal@hgst.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Martin K. Petersen <martin.petersen@oracle.com>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: <stable@vger.kernel.org>
> ---
>  block/blk-zoned.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 20bfc37e1852..92e6108487c4 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -328,7 +328,11 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
>  	if (!rep.nr_zones)
>  		return -EINVAL;
>  
> -	zones = kcalloc(rep.nr_zones, sizeof(struct blk_zone), GFP_KERNEL);
> +	if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone))
> +		return -ERANGE;
> +
> +	zones = kvmalloc(rep.nr_zones * sizeof(struct blk_zone),
> +			GFP_KERNEL | __GFP_ZERO);
>  	if (!zones)
>  		return -ENOMEM;
>  
> @@ -350,7 +354,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
>  	}
>  
>   out:
> -	kfree(zones);
> +	kvfree(zones);
>  
>  	return ret;
>  }
> 
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>

-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers
  2018-05-22 17:58 ` Jens Axboe
@ 2018-06-13 15:20   ` Bart Van Assche
  2018-06-13 15:25     ` Jens Axboe
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2018-06-13 15:20 UTC (permalink / raw
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Shaun Tancheff, Damien Le Moal,
	Martin K . Petersen, Hannes Reinecke, stable

On 05/22/18 10:58, Jens Axboe wrote:
> On 5/22/18 9:27 AM, Bart Van Assche wrote:
>> Avoid that complaints similar to the following appear in the kernel log
>> if the number of zones is sufficiently large:
>>
>>    fio: page allocation failure: order:9, mode:0x140c0c0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null)
>>    Call Trace:
>>    dump_stack+0x63/0x88
>>    warn_alloc+0xf5/0x190
>>    __alloc_pages_slowpath+0x8f0/0xb0d
>>    __alloc_pages_nodemask+0x242/0x260
>>    alloc_pages_current+0x6a/0xb0
>>    kmalloc_order+0x18/0x50
>>    kmalloc_order_trace+0x26/0xb0
>>    __kmalloc+0x20e/0x220
>>    blkdev_report_zones_ioctl+0xa5/0x1a0
>>    blkdev_ioctl+0x1ba/0x930
>>    block_ioctl+0x41/0x50
>>    do_vfs_ioctl+0xaa/0x610
>>    SyS_ioctl+0x79/0x90
>>    do_syscall_64+0x79/0x1b0
>>    entry_SYSCALL_64_after_hwframe+0x3d/0xa2
> 
> Applied, thanks.

Thank you Jens. This patch (commit 327ea4adcfa3) is now in Linus tree.
We would like this patch to appear in the v4.14 and v4.17 kernel series 
too. Since this patch does not have a stable tag, how do you want us
to proceed? Do you want to send this patch yourself to Greg or do you
rather expect us to do that?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers
  2018-06-13 15:20   ` Bart Van Assche
@ 2018-06-13 15:25     ` Jens Axboe
  0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2018-06-13 15:25 UTC (permalink / raw
  To: Bart Van Assche
  Cc: linux-block, Christoph Hellwig, Shaun Tancheff, Damien Le Moal,
	Martin K . Petersen, Hannes Reinecke, stable

On 6/13/18 9:20 AM, Bart Van Assche wrote:
> On 05/22/18 10:58, Jens Axboe wrote:
>> On 5/22/18 9:27 AM, Bart Van Assche wrote:
>>> Avoid that complaints similar to the following appear in the kernel log
>>> if the number of zones is sufficiently large:
>>>
>>>    fio: page allocation failure: order:9, mode:0x140c0c0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null)
>>>    Call Trace:
>>>    dump_stack+0x63/0x88
>>>    warn_alloc+0xf5/0x190
>>>    __alloc_pages_slowpath+0x8f0/0xb0d
>>>    __alloc_pages_nodemask+0x242/0x260
>>>    alloc_pages_current+0x6a/0xb0
>>>    kmalloc_order+0x18/0x50
>>>    kmalloc_order_trace+0x26/0xb0
>>>    __kmalloc+0x20e/0x220
>>>    blkdev_report_zones_ioctl+0xa5/0x1a0
>>>    blkdev_ioctl+0x1ba/0x930
>>>    block_ioctl+0x41/0x50
>>>    do_vfs_ioctl+0xaa/0x610
>>>    SyS_ioctl+0x79/0x90
>>>    do_syscall_64+0x79/0x1b0
>>>    entry_SYSCALL_64_after_hwframe+0x3d/0xa2
>>
>> Applied, thanks.
> 
> Thank you Jens. This patch (commit 327ea4adcfa3) is now in Linus tree.
> We would like this patch to appear in the v4.14 and v4.17 kernel series 
> too. Since this patch does not have a stable tag, how do you want us
> to proceed? Do you want to send this patch yourself to Greg or do you
> rather expect us to do that?

You can do it - just send an email go greg/stable saking for that commit
sha to be marked for stable.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-13 15:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-22 15:27 [PATCH] blkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers Bart Van Assche
2018-05-22 17:58 ` Jens Axboe
2018-06-13 15:20   ` Bart Van Assche
2018-06-13 15:25     ` Jens Axboe
2018-05-23 14:57 ` Damien Le Moal
2018-05-23 14:57   ` Damien Le Moal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.