Skip to content

Commit

Permalink
Vring descriptor count must be limited to 65k per device
Browse files Browse the repository at this point in the history
Code must ensure we don't overflow the 16-bit count in vring_alloc_info
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
  • Loading branch information
tammyleino committed Jul 26, 2022
1 parent afed3bd commit 4724527
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/include/openamp/remoteproc_virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
extern "C" {
#endif

/* maximum number of vring descriptors for a vdev */
#define RPROC_MAX_VRING_DESC 65535

/* define vdev notification function user should implement */
typedef int (*rpvdev_notify_func)(void *priv, uint32_t id);

Expand Down
2 changes: 1 addition & 1 deletion lib/remoteproc/remoteproc_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ int rproc_virtio_init_vring(struct virtio_device *vdev, unsigned int index,
unsigned int num_vrings;

num_vrings = vdev->vrings_num;
if (index >= num_vrings)
if ((index >= num_vrings) || (num_descs > RPROC_MAX_VRING_DESC))
return -RPROC_EINVAL;
vring_info = &vdev->vrings_info[index];
vring_info->io = io;
Expand Down

0 comments on commit 4724527

Please sign in to comment.