Unverified Commit e3fdb6b6 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!15600 vfio/platform: check the bounds of read/write syscalls

parents a0f7a942 5fc74f7a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -413,6 +413,11 @@ static ssize_t vfio_platform_read_mmio(struct vfio_platform_region *reg,
{
	unsigned int done = 0;

	if (off >= reg->size)
		return -EINVAL;

	count = min_t(size_t, count, reg->size - off);

	if (!reg->ioaddr) {
		reg->ioaddr =
			ioremap_nocache(reg->addr, reg->size);
@@ -490,6 +495,11 @@ static ssize_t vfio_platform_write_mmio(struct vfio_platform_region *reg,
{
	unsigned int done = 0;

	if (off >= reg->size)
		return -EINVAL;

	count = min_t(size_t, count, reg->size - off);

	if (!reg->ioaddr) {
		reg->ioaddr =
			ioremap_nocache(reg->addr, reg->size);