Skip to content

Commit

Permalink
lguest: fix descriptor corruption in example launcher
Browse files Browse the repository at this point in the history
1d589bb "Add serial number support
for virtio_blk, V4a" extended 'struct virtio_blk_config' to 536 bytes.
Lguest and S/390 both use an 8 bit value for the feature length, and
this change broke them (if the code is naive).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: John Cooper <john.cooper@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
  • Loading branch information
Rusty Russell committed Jul 30, 2009
1 parent f294526 commit 8ef562d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Documentation/lguest/lguest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,9 @@ static void set_config(struct device *dev, unsigned len, const void *conf)
/* Copy in the config information, and store the length. */
memcpy(device_config(dev), conf, len);
dev->desc->config_len = len;

/* Size must fit in config_len field (8 bits)! */
assert(dev->desc->config_len == len);
}

/* This routine does all the creation and setup of a new device, including
Expand Down Expand Up @@ -1515,7 +1518,8 @@ static void setup_block_file(const char *filename)
add_feature(dev, VIRTIO_BLK_F_SEG_MAX);
conf.seg_max = cpu_to_le32(VIRTQUEUE_NUM - 2);

set_config(dev, sizeof(conf), &conf);
/* Don't try to put whole struct: we have 8 bit limit. */
set_config(dev, offsetof(struct virtio_blk_config, geometry), &conf);

verbose("device %u: virtblock %llu sectors\n",
++devices.device_num, le64_to_cpu(conf.capacity));
Expand Down

0 comments on commit 8ef562d

Please sign in to comment.