Thread (18 messages) 18 messages, 5 authors, 2016-09-27

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

From: Christoph Hellwig <hch@infradead.org>
Date: 2016-09-26 16:37:52
Also in: linux-scsi

+	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.
+	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..
-/*
- * 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help