Re: [PATCH v2 7/7] blk-zoned: implement ioctls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 26, 2016 at 11:37 AM, Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
>> +     zones = kzalloc(sizeof(struct blk_zone) * rep.nr_zones,
>> +                     GFP_KERNEL);
>> +     if (!zones)
>> +             return -ENOMEM;
>
> This should use kcalloc to get us underflow checking for the user
> controlled allocation size.

Ah. yes. Will fix that.

>> +     if (copy_to_user(argp, &rep, sizeof(struct blk_zone_report))) {
>> +             ret = -EFAULT;
>> +             goto out;
>> +     }
>> +
>> +     if (rep.nr_zones) {
>> +             if (copy_to_user(argp + sizeof(struct blk_zone_report), zones,
>> +                              sizeof(struct blk_zone) * rep.nr_zones))
>> +                     ret = -EFAULT;
>> +     }
>
> We could actually do this with a single big copy_to_user.  Not that
> it really matters, though..

Except our source locations are disjoint (stack and kcalloc'd).

>> -/*
>> - * Zone type.
>> - */
>> -enum blk_zone_type {
>> -     BLK_ZONE_TYPE_UNKNOWN,
>> -     BLK_ZONE_TYPE_CONVENTIONAL,
>> -     BLK_ZONE_TYPE_SEQWRITE_REQ,
>> -     BLK_ZONE_TYPE_SEQWRITE_PREF,
>> -};
>
> Please don't move this code around after it was added just two
> patches earlier.  I'd say just split adding the new blkzoned.h
> uapi header into a patch of it's own and add that before the
> core block code.

Sounds good. Will reshuffle the patchset tonight.

Thanks!
-- 
Shaun Tancheff
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux