Message ID | 20180522152722.15920-1-bart.vanassche@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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.
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
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.
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.
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; }
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(-)